Masquerade traffic from certain source IP to VPN connection

Posted by Shuo Ran on Server Fault See other posts from Server Fault or by Shuo Ran
Published on 2011-08-29T06:10:56Z Indexed on 2014/06/04 9:27 UTC
Read the original article Hit count: 161

Filed under:
|
|

Network Setup:

10.0.0.1 Router: to internet
10.0.0.70 Server: Ubuntu based server,default gateway is 10.0.0.1
10.0.0.51 PC

I created a PPTP connection(interface: ppp0) on Server to a machine on the internet, what I want to do is route all the traffic from certain IP address(10.0.0.51) through the PPTP connection and then to the internet. What I did are:

  1. Set the gateway on PC(10.0.0.51) as 10.0.0.70
  2. Enabled ipv4 forward on 10,0,0,70
  3. Add the masquerade rule to iptable:
    iptables -t nat -A POSTROUTING -o ppp0 -s 10.0.0.51 -j MASQUERADE

After that, it seems none of the traffic from 10.0.0.51 be redirected to ppp0, instead these traffic are still going through 10.0.0.1 directly.

Any thoughts on it?

© Server Fault or respective owner

Related posts about vpn

Related posts about iptables