Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 20 to 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 ppp0 from 192.168.0.48 using tcpdump -i ppp0

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.