Questions? Feedback? powered by Olark live chat software
Author Avatar

Second Gateway on Ubuntu

Written by: on 02 March 2017 02:36 PM 02 March 2017 02:36 PM

If you have a DHCP based second NIC on Ubuntu, it will have two gateways. You may find when you reboot the server sometimes it takes the incorrect gateway and makes it default meaning that your system has no internet access.

You can find out what the default route is by typing:

ip r s

To make your system delete any incorrect route and add a specific default route you need to edit your interfaces file at


Add the following to the bottom of the file

post-up ip route del default

post-up ip route add default via 203.143.X.1 dev eth0

Of course you need to specify the correct gateway for your IP address (which is also listed earlier in the file) and ensure you specify the correct NIC (e.g. eth0).

To test you will need to reboot the server as restarting networking may not work properly.

(0 vote(s))
Not helpful