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.

I have set up a Ubuntu server, that I want to use as a router for my local office.

  1. The problem is, that I want to make 2 VPN connections, to remote branches, and then I want to route all traffic to the subnet of these two branches through the VPN connections, ppp0 and ppp1, and route the rest of the traffic to eth0.

How can I do this?

  1. I also want to route a part of my internet traffic through ppp0, because we have some service subscription, that is based on our IP at one of the branches, and therefor, I need to route this part of the internet traffic through ppp0.

Is this possible to set up in the same way as issue 1?

I have tried to read about iptables, iproute2 and ipchains, and have tried setting it up, but with no success so far.

Thanks a lot for your help.

--- EDITED ---

Ok. I found an answer on this page: http://pptpclient.sourceforge.net/routing.phtml#lan-to-lan-via-adsl

This seems to be working:

route add -net 192.168.0.0 netmask 255.255.0.0 dev ppp0
iptables --insert OUTPUT 1 --source 0.0.0.0/0.0.0.0 --destination 192.168.0.0/16 --jump ACCEPT --out-interface ppp0
iptables --insert INPUT 1 --source 192.168.0.0/16 --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface ppp0
iptables --insert FORWARD 1 --source 0.0.0.0/0.0.0.0 --destination 192.168.0.0/16 --jump ACCEPT --out-interface ppp0
iptables --insert FORWARD 1 --source 192.168.0.0/16 --destination 0.0.0.0/0.0.0.0 --jump ACCEPT
iptables --table nat --append POSTROUTING --out-interface ppp0 --jump MASQUERADE
iptables --append FORWARD --protocol tcp --tcp-flags SYN,RST SYN --jump TCPMSS --clamp-mss-to-pmtu
share|improve this question
3  
Instead of editing your question, you should add an answer and accept it. –  Kevin M Jan 18 '12 at 21:26
add comment

2 Answers 2

Assuming the VPN are all up and running you would need to add an entry to the routing table that specifies over which interface send traffic to X and Y networks.

How to do this may vary from one Linux distro to another, but this will give you an idea -- For example, let's assume that over ppp0 you want to reach 192.168.255.0/24

route add -net 192.168.255.0 netmask 255.255.255.0 gw 192.168.255.2 dev pp0

OR

route add -net 192.168.255.0/24 dev ppp0

And this should route traffic to a specific network over a specific interface. Hope it helps.

share|improve this answer
    
I have tried this, but it does not work, the traffic is not routed to these networks. It works perfectly on my server, and the local traffic is routed as it should, but not rest of the LAN traffic. –  Sylvester78 Jan 18 '12 at 16:11
add comment

Edit by OP:

Ok. I found an answer on this page: http://pptpclient.sourceforge.net/routing.phtml#lan-to-lan-via-adsl

This seems to be working:

route add -net 192.168.0.0 netmask 255.255.0.0 dev ppp0
iptables --insert OUTPUT 1 --source 0.0.0.0/0.0.0.0 --destination 192.168.0.0/16 --jump ACCEPT --out-interface ppp0
iptables --insert INPUT 1 --source 192.168.0.0/16 --destination 0.0.0.0/0.0.0.0 --jump ACCEPT --in-interface ppp0
iptables --insert FORWARD 1 --source 0.0.0.0/0.0.0.0 --destination 192.168.0.0/16 --jump ACCEPT --out-interface ppp0
iptables --insert FORWARD 1 --source 192.168.0.0/16 --destination 0.0.0.0/0.0.0.0 --jump ACCEPT
iptables --table nat --append POSTROUTING --out-interface ppp0 --jump MASQUERADE
iptables --append FORWARD --protocol tcp --tcp-flags SYN,RST SYN --jump TCPMSS --clamp-mss-to-pmtu
share|improve this answer
add comment

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.