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
- Any packet destined for
10.8.0.5
has no gateway and will usetun0
- any packet destined for
10.8.0.1
will use10.8.0.5
as gateway viatun0
- any packet destined for
54.202.18.143
will use10.0.2.2
as gateway viaeth0
- any packet destined for
10.0.2.0/24
has no gateway and will useeth0
- Lets ignore the 169.254.0.0 part
- All other packets (destined for
0.0.0.0
) will us10.8.0.5
as default gateway viatun0
. So this is default gateway, isn't it? - Any packet destined for
128.0.0.0/7
will use10.8.0.5
as default gateway viatun0
- All other packets (
0.0.0.0
) will use10.0.2.2
as default gateway viaeth0
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 viaeth0
. 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
0.0.0.0
route has Genmask128.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 :/