Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using 3 ethernet interfaces on Ubuntu but when I restart, the default gateway is changing to a different interface. Each time I boot I have to change default gateway back to the eth1 by deleting the default gateway and adding it back with eth1. How can I fix this problem?

share|improve this question
    
Have you configured it manually using the /etc/network/interfaces file, or a with software like Network Manager or wicd? –  Lekensteyn Mar 23 '11 at 12:56
    
"Gateway" is not equal to "route". A gateway is specific to an interface where an route says which interface should be used. –  Lekensteyn Jun 2 '11 at 19:24
    
The gateway is usually an interface on a remote device which the local node is relying on for routing decisions. A route statement itself can refer to a local interface or not, but the routing destination has to be discoverable from a recursive lookup, connected interface, or default route. A default route or default gateway is the 'gateway of last resort' -- which will be used in the absence of a more specific route being available. –  belacq Oct 29 '11 at 22:14
    
Can you provide your routing table and list of interface, and other any relevant network configuration you've done? –  belacq Oct 29 '11 at 22:17

2 Answers 2

up vote 3 down vote accepted

Open /etc/network/interfaces file

find desired interface and add following:

gateway 192.x.x.x

Restart network:

sudo /etc/init.d/networking restart
share|improve this answer
3  
What if the desired interface is configured via DHCP and I don't know the gateway address it will assign? –  devmiles.com Aug 31 '12 at 10:40

To temporarily change the default route you can use an ip command like this:

$ sudo ip route change default via 192.168.1.1 dev eth0

If you have a static ip configuration in /etc/network/interfaces you can add a gateway statement to make this permanent.

iface eth0 inet static
    gateway 192.168.1.1
    […]

Using DHCP to configure networking you have to adjust another file instead. Add the supersede statement in /etc/dhcp/dhclient.conf.

supersede routers 192.168.1.1;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.