Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

Assuming that the internal interface on Ubuntu gateway is eth0.

Add more 2 below rules:

iptables -A FORWARD -i eth0 -o ppp0 -s 10.0.0.51 -j ACCEPT
iptables -A FORWARD -i ppp0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT

and make sure that you removed the old gateway on the client:

route del default gw 10.0.0.1 dev <ethx>
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.