15

I just setup the OpenVPN and it is working as expected. However, the routing table of the client is confusing me to no end. Here is the route table:

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.8.0.5        0.0.0.0         255.255.255.255 UH    0      0        0 tun0
10.8.0.1        10.8.0.5        255.255.255.255 UGH   0      0        0 tun0
54.202.18.143   10.0.2.2        255.255.255.255 UGH   0      0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     1      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
0.0.0.0         10.8.0.5        128.0.0.0       UG    0      0        0 tun0
128.0.0.0       10.8.0.5        128.0.0.0       UG    0      0        0 tun0
0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0

So lets dissect it line-by-line

  1. Any packet destined for 10.8.0.5 has no gateway and will use tun0
  2. any packet destined for 10.8.0.1 will use 10.8.0.5 as gateway via tun0
  3. any packet destined for 54.202.18.143 will use 10.0.2.2 as gateway via eth0
  4. any packet destined for 10.0.2.0/24 has no gateway and will use eth0
  5. Lets ignore the 169.254.0.0 part
  6. All other packets (destined for 0.0.0.0) will us 10.8.0.5 as default gateway via tun0. So this is default gateway, isn't it?
  7. Any packet destined for 128.0.0.0/7 will use 10.8.0.5 as default gateway via tun0
  8. All other packets (0.0.0.0) will use 10.0.2.2 as default gateway via eth0

Questions:

  • Do I have 2 default gateways if we consider point 6 and 8? (there can be only 1 Default Gateway though, so I know I am wrong but can't justify) (probably answered, see below)
  • Considering point 1 and 2, anything going for 10.8.0.1 is not really using any gateway via tun0. Is this correct?
  • Considering point 3 and 4, anything going for 54.202.18.143 is not really using any gateway via eth0. Is this correct?

UPDATE...

After reading this, I found some more information. The below lines makes a lot of sense to me now:

0.0.0.0         10.8.0.5        128.0.0.0       UG    0      0        0 tun0
128.0.0.0       10.8.0.5        128.0.0.0       UG    0      0        0 tun0

So, the 1st line is defining 0.0.0.0/128.0.0.0 and second one is defining 128.0.0.0/128.0.0.0. Essentially:

0.0.0.0/128.0.0.0 = 0.0.0.0/1 = 0.0.0.0 TO 127.255.255.255
128.0.0.0/128.0.0.0 = 128.0.0.0/1 = 128.0.0.0 TO 255.255.255.255

So, above 2 routes are covering the entire IPv4 Address range [0.0.0.0 TO 255.255.255.255]. It is a clever way of OpenVPN to add a default route without replacing the original default route and this default route will be routed via tun0.

So I think I have an answer for my first question:

Do I have 2 default gateways if we consider point 6 and 8?

NO, there is only one default gateway and that is :

0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
6
  • 2
    The first 0.0.0.0 route has Genmask 128.0.0.0 which probably doesn't make it a default route. I have to say though that I don't have the slightest idea what this mask means and what is route is there for :/ Commented Jan 24, 2014 at 9:14
  • Also be awarfe that routing 128.0.0.0 inside your network is really strange because it's public ip or reserved i don'"t remeber. but in both case this is strange.
    – Kiwy
    Commented Jan 24, 2014 at 9:15
  • The 128.0.0.0 part is coming from openvpn. it is explained here Commented Jan 24, 2014 at 9:19
  • You should turn your "UPDATE" into an answer as it is just this: an answer which helped me to understand the same exact problem I was having :)
    – WoJ
    Commented Feb 24, 2016 at 20:13
  • 1
    @slayedbylucifer the explanation for 128.0.0.0 appears to be down and there's no archive of it available. Do you happen to have a online link about this?
    – SaAtomic
    Commented Mar 30, 2017 at 8:44

1 Answer 1

4

Do I have 2 default gateways if we consider point 6 and 8? (there can be only 1 Default Gateway though, so I know I am wrong but can't justify) (probably answered, see below)

The 6st line is defining range 0.0.0.0 - 127.255.255.255 and 7th line is defining range 128.0.0.0 - 255.255.255.255.

Do I have 2 default gateways if we consider point 6 and 8?

NO, there is only one default gateway and that is :

0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0

Considering point 1 and 2, anything going for 10.8.0.1 is not really using any gateway via tun0. Is this correct?

No not correct, packets destined for 10.8.0.1 would be routed to 10.8.0.5(which is accessible by tun0 lan as set by first line).
you were right if the netmask was not 255.255.255.255

Considering point 3 and 4, anything going for 54.202.18.143 is not really using any gateway via eth0. Is this correct?

No not correct, packets destined for 54.202.18.143 would be routed to 10.0.2.2(which is another host on eth0 lan and is accessible by 4th line)

1
  • The first question is answered by yourself I just wanted the answer to be complete so I rementioned it.
    – Arash
    Commented Mar 25, 2016 at 19:57

You must log in to answer this question.

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