1

I have the following output for my default route :

Kernel IP routing table Destination     Gateway         Genmask        Flags Metric Ref    Use Iface
0.0.0.0         192.168.167.1   0.0.0.0         UG    100    0        0 enp1s0
192.168.167.0   0.0.0.0         255.255.255.0   U     100    0        0 enp1s0

And here the selected route to 8.8.8.8. Until here, nothing extraordinary.

traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  192.168.167.1 (192.168.167.1)  0.326 ms  0.465 ms  0.527 ms
 2  192.168.1.254 (192.168.1.254)  1.409 ms  1.422 ms  1.429 ms

When I activate the VPN, the route becomes :

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.8.0.13       128.0.0.0       UG    0      0        0 tun0
0.0.0.0         192.168.167.1   0.0.0.0         UG    100    0        0 enp1s0
10.8.0.1        10.8.0.13       255.255.255.255 UGH   0      0        0 tun0
10.8.0.13       0.0.0.0         255.255.255.255 UH    0      0        0 tun0
128.0.0.0       10.8.0.13       128.0.0.0       UG    0      0        0 tun0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 tun0
192.168.167.0   0.0.0.0         255.255.255.0   U     100    0        0 enp1s0
213.246.56.21   192.168.167.1   255.255.255.255 UGH   0      0        0 enp1s0

Whatever value I set for tun0 metric :

sudo ifmetric tun0 3000

route -n output :

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.8.0.13       128.0.0.0       UG    3000   0        0 tun0
0.0.0.0         192.168.167.1   0.0.0.0         UG    100    0        0 enp1s0
10.8.0.1        10.8.0.13       255.255.255.255 UGH   3000   0        0 tun0
10.8.0.13       0.0.0.0         255.255.255.255 UH    3000   0        0 tun0
128.0.0.0       10.8.0.13       128.0.0.0       UG    3000   0        0 tun0
169.254.0.0     0.0.0.0         255.255.0.0     U     3000   0        0 tun0
192.168.167.0   0.0.0.0         255.255.255.0   U     100    0        0 enp1s0
213.246.56.21   192.168.167.1   255.255.255.255 UGH   0      0        0 enp1s0

The selected route is always going through interface tun0 :

traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  10.8.0.1 (10.8.0.1)  28.510 ms  33.924 ms  33.941 ms
 2  ik056002.ikoula.com (213.246.56.2)  33.960 ms
...

Why ??

Thanks !

1

Routes are process from most specific to least specific, if there are two routes with the same level of specificity, only then is the metric checked.

You are using the route -n format, which kinda sucks IMO, it would look better and be more obvious if you did an ip route show, which has output probably looks like this for you.

default via 192.168.167.1 dev enp1s0 metric 100
0.0.0.0/1 via 10.8.0.13 dev tun0 metric 3000
128.0.0.0/1 via 10.8.0.13 dev tun0 metric 3000
...

The two routes have different specificity, so the metric is irrelevant. The /1 is more specific (by 1 bit) then the /0 route.

When you are looking at the route -n output, you must remember that you have to consider both the 1st and 3rd columns. A route is the network address and the mask.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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