1

I'm connected to a network using VPN (Managed byt NetworkManager, Fedora 23), and I want to route all traffica via the VPN network. But for some reason nothing happens when I run ip route add or ip route default

root@laptop:~ $ ip route 
default via 192.168.144.1 dev wlp68s0b1  proto static  metric 600 
10.135.0.0/16 dev tap0  proto kernel  scope link  src 10.135.100.16  metric 50 
192.168.144.0/24 dev wlp68s0b1  proto kernel  scope link  src 192.168.144.136  metric 600

And wen running ip route replace:

root@laptop:~ $ ip route replace default via 10.135.0.2 dev tap0
root@laptop:~ $ ip route 
default via 192.168.144.1 dev wlp68s0b1  proto static  metric 600 
10.135.0.0/16 dev tap0  proto kernel  scope link  src 10.135.100.16  metric 50 
192.168.144.0/24 dev wlp68s0b1  proto kernel  scope link  src 192.168.144.136  metric 600

Same thing when running ip route add

root@laptop:~ $ ip route add default via 10.135.0.2 dev tap0
root@laptop:~ $ ip route 
default via 192.168.144.1 dev wlp68s0b1  proto static  metric 600 
10.135.0.0/16 dev tap0  proto kernel  scope link  src 10.135.100.16  metric 50 
192.168.144.0/24 dev wlp68s0b1  proto kernel  scope link  src 192.168.144.136  metric 600

The default gateway is not updated, does anyone know why?

1 Answer 1

2

The correct way to replace the default gateway is

 ip route del default via 192.168.144.1 
 ip route add default via x.y.w.z dev $DEV

The reason why I did not include the values you would like to see (10.135.0.2 and tap0) in the previous command is that this is not the correct way to force all traffic thru the VPN. However, you cannot have a correct routing table because you have not bridged the virtual interface with the ethernet NIC. Normally, this is done automatically, thus the lack of a proper bridge indicates that you are missing some component.

Perhaps, you are missing the bridge-utils package. But there is also another possibility, that you have created the wrong virtual interface. tap0 is not supposed to receive an IP address, but tun0 is. tap0 must be inserted into a bridge, and it is the new bridge, br0 which receives the IP address. tun0 does receive an IP address, but it does not require being inserted into a bridge.

So, which one do you need? It depends on your server. Which kind of VPN are you tring to connect to? OpenVPN? And if so, is that a routed or bridged VPN? Once you have answered these questions, I might be able to help you more.

2
  • I'm connected to an OpenVPN. OK, so there is some kind of silent failure happening then? By experience I've seen that bridging is not set up correctly by NetworkManager. Perhaps that could be part of the problem.I've reconfigured network manager to expose a tun interface instead (but I see a lot of errors regarding "Invalid argument" in the syslog). How would I go about manually bridging? I don't seem to be able to add tun0 to bridge
    – Kotte
    Dec 21, 2015 at 13:38
  • @Kotte You cannot bridge a tun interface. Please read here, superuser.com/questions/818347/… Dec 21, 2015 at 13:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .