In a previous post I talked about some trouble with internet connectivity I’d had on an Ubuntu installation where I’d configured my /etc/network/interfaces file for multiple networks. Even though two of the four networks the computer was connected to had internet connections, the computer was using one of the static networks to try to connect to the web.
In short, I’d specified too many default gateways in my interfaces file, and had to comment out the ones referring to the static networks.
My interfaces file looked like this:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp # OpenStack - Management Network auto eth1 iface eth1 inet static address 192.168.100.2 netmask 255.255.252.0 gateway 192.168.100.1 # OpenStack - API/Public Network auto eth2 iface eth2 inet static address 192.168.200.2 netmask 255.255.252.0 gateway 192.168.200.1 # OpenStack - Data Network auto eth3 iface eth3 inet static address 192.168.220.2 netmask 255.255.252.0 gateway 192.168.220.1
My supervisor’s first throught was to check the routing with the command route -n, which produced:
CENSORED@openstack-controller:~$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.100.1 0.0.0.0 UG 100 0 0 eth1 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.100.0 0.0.0.0 255.255.252.0 U 0 0 0 eth1 192.168.200.0 0.0.0.0 255.255.252.0 U 0 0 0 eth2 192.168.220.0 0.0.0.0 255.255.252.0 U 0 0 0 eth3
This showed that the default gateway, highlighted on line 4, is the gateway for one of my static networks. We tried adding the proper gateway with route add default gw 192.168.200.1, which caused route -n to display:
CENSORED@openstack-controller:~$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.100.1 0.0.0.0 UG 0 0 0 eth1 0.0.0.0 192.168.200.1 0.0.0.0 UG 100 0 0 eth2 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.100.0 0.0.0.0 255.255.252.0 U 0 0 0 eth1 192.168.200.0 0.0.0.0 255.255.252.0 U 0 0 0 eth2 192.168.220.0 0.0.0.0 255.255.252.0 U 0 0 0 eth3
So now we had two default gateways, and still no connection.
We deleted the gateway for the static network (route del default gw 192.168.100.1) and the internet worked perfectly.
In the end we solved the problem by commenting out the “gateway” setting for each static network in the /etc/network/interfaces file (highlighted lines):
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet dhcp # OpenStack - Management Network auto eth1 iface eth1 inet static address 192.168.100.2 netmask 255.255.252.0 # gateway 192.168.100.1 # OpenStack - API/Public Network auto eth2 iface eth2 inet static address 192.168.200.2 netmask 255.255.252.0 gateway 192.168.200.1 # OpenStack - Data Network auto eth3 iface eth3 inet static address 192.168.220.2 netmask 255.255.252.0 # gateway 192.168.220.1
After rebooting the only default gateway displayed by the route -n command was the one we wanted:
CENSORED@openstack-controller:/home/senecacd# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.200.1 0.0.0.0 UG 100 0 0 eth2 10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.100.0 0.0.0.0 255.255.252.0 U 0 0 0 eth1 192.168.200.0 0.0.0.0 255.255.252.0 U 0 0 0 eth2 192.168.220.0 0.0.0.0 255.255.252.0 U 0 0 0 eth3
Our ping test confirmed the internet was back, and there was much merriment and rejoicing!