Linux – Sending all traffic through a tunnel

linuxnetworkingroutingtunneling

I have set up a IPIP tunnel between my workstation and my server. I can add routes manually to have traffic going through the tunnel like this:

ip route ad 216.221.35.27 dev foo

I'm not sure however how I should configure my routes to have all my traffic (except traffic for the local network 192.168.1.0/24) going through the tunnel.

Best Answer

other posters are right - you route all traffic via tunnel... except traffic to the other endpoint of tunnel that should go via public internet.

ip route del default
ip route add default via 10.1.2.3 dev tun0
ip route add 192.168.5.1 via 192.168.1.3 dev eth0

[ example assumes that you terminate tunnel at 192.168.1.3; your local gateway is at 192.168.5.1; your far end address of vpn tunnel tun0 is 10.1.2.3 ]

if you use openvpn - here's the description.

Related Topic