I’m doing some testing using some Ubuntu server and I wasn’t able to ping across from other server I’ve got. I checked the network and it was fine, so I can checked the server and saw that the routing on the server was acting unexpcted :/

Checked the network file /etc/network/interfaces and that was fine

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 192.31.3.2
netmask 255.255.255.0
gateway 192.31.3.1

However when I checked the routing table the default gateway was going via the management subnet

marquk01@km-vm3:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.1.0.1        0.0.0.0         UG    0      0        0 eth0
10.1.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.31.3.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1

marquk01@km-vm3:~$ ip route 
default via 10.1.0.1 dev eth0 
10.1.0.0/24 dev eth0  proto kernel  scope link  src 10.1.0.140 
192.31.3.0/24 dev eth1  proto kernel  scope link  src 192.31.3.2

Needed to change this, to have the default gateway as 192.31.3.1. Firstly, I had to remove the current default gateway: sudo route del default

Verified that the route was removed, using ip route

marquk01@km-vm3:~$ ip route
10.1.0.0/24 dev eth0  proto kernel  scope link  src 10.1.0.140 
192.31.3.0/24 via 192.31.3.1 dev eth1 
192.31.3.0/24 dev eth1  proto kernel  scope link  src 192.31.3.2

To add the new default route, I had to run the command route add default gw {IP address}

marquk01@km-vm3:~$ sudo route add default gw 192.31.3.1

Then verified with ip route again

marquk01@km-vm3:~$ ip route 
default via 192.31.3.1 dev eth1 
10.1.0.0/24 dev eth0  proto kernel  scope link  src 10.1.0.140 
192.31.3.0/24 via 192.31.3.1 dev eth1 
192.31.3.0/24 dev eth1  proto kernel  scope link  src 192.31.3.2

Now when I did a mtr to my other test server, routing is working as expected :)

                            My traceroute  \[v0.85\]
km-vm3 (0.0.0.0)                                       Mon Aug  3 10:37:15 2015
Resolver: Received error response 2. (server failure)er of fields   quit
                                       Packets               Pings
 Host                                Loss%   Snt   Last   Avg  Best  Wrst StDev
 1. 192.31.3.1                        0.0%     9    1.0   0.9   0.8   1.0   0.0
 2. 172.31.1.2                        0.0%     9    0.9   1.0   0.9   1.1   0.0
 3. 192.31.1.2                        0.0%     9    0.7   0.5   0.4   0.7   0.0

Throughout the troubleshooting (as I’m not a server man!) I did also figure out how to make add a static route as well! This is done by use the command: route add -net [subnet/mask] gw [IP address] dev [interface]

marquk01@km-vm3:~$ sudo route add -net 192.31.3.0/24 gw 192.31.3.1 dev eth1

As you see the static route was added.

marquk01@km-vm3:~$ ip route
default via 10.1.0.1 dev eth0 
10.1.0.0/24 dev eth0  proto kernel  scope link  src 10.1.0.140 
192.31.3.0/24 via 192.31.3.1 dev eth1 
192.31.3.0/24 dev eth1  proto kernel  scope link  src 192.31.3.2

Although this didn’t fix my issue, it was a useful thing to come across as it could be helpful in the future!!

Share on LinkedIn
Share on Reddit