This question is very similar to what I am trying to do: iptables --set-mark - Route diferent ports through different interfaces However I attempted to follow the answer but I was unable to make it work.
I have one device that I would like to route through a PPTP VPN connection. If I do it on my router it will put all users through the VPN I decided to try and use the same server I am using as a proxy server to connect to the VPN.
I currently have my router (DD-WRT) routing packets to my proxy server using this script:
iptables -t mangle -A PREROUTING -p tcp --dport 80 -j MARK --set-mark 10 ip rule add fwmark 10 table 10 ip route add default via 192.168.0.10 table 10
That is working fine. On my server end I am trying to route 192.168.0.48 through my VPN and all of the others through my proxy server. I am using the following script on my server:
#Redirect all traffic on 80 to proxy except 192.168.0.48 (WORKING) iptables -t nat -A PREROUTING -p tcp -m tcp ! -s 192.168.0.48 --dport 80 -j REDIRECT --to-ports 3127 #Mark packets from 192.168.0.48 with 20 iptables -t mangle -A PREROUTING -p tcp -s 192.168.0.48 --dport 80 -j MARK --set-mark 20
I then tried to forward traffic marked with
ppp0 using the following:
ip rule add fwmark 20 table 20 ip route add default via 192.168.1.2 dev ppp0 table 20
All computers can load webpages successfully except for
192.168.0.48 which sits at loading forever. I have confirmed I am getting traffic on
tcpdump -i ppp0