Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My /etc/network/interfaces looks like this:

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
      address 10.0.0.99
      netmask 255.255.255.0
      gateway 10.0.0.1

auto eth0
iface eth0 inet dhcp

After I reboot the machine, I get

vagrant@precise64:~$ ip route
default via 10.0.2.2 dev eth0 
default via 10.0.0.1 dev eth1  metric 100 
10.0.0.0/24 dev eth1  proto kernel  scope link  src 10.0.0.99 
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15

How can I modify /etc/network/interfaces so that my traffic goes through 10.0.0.1 instead of 10.0.2.2 by default? I can do it manually as follows, but I don't want to do this on every reboot:

vagrant@precise64:~$ sudo ip route del default via 10.0.2.2 dev eth0
vagrant@precise64:~$ ip route
default via 10.0.0.1 dev eth1  metric 100 
10.0.0.0/24 dev eth1  proto kernel  scope link  src 10.0.0.99 
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15
share|improve this question

1 Answer 1

up vote 0 down vote accepted

It turns out the reason was unrelated to /etc/network/interfaces. This machine was a Vagrant VM, which by default has some extra stuff in /etc/rc.local:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Make sure eth0 is working. This works around Vagrant issue #391
dhclient eth0

exit 0

Commenting out the dhclient eth0 line and rebooting yields:

vagrant@precise64:~$ ip r
default via 10.0.0.1 dev eth1  metric 100 
10.0.0.0/24 dev eth1  proto kernel  scope link  src 10.0.0.99 
10.0.2.0/24 dev eth0  proto kernel  scope link  src 10.0.2.15 
share|improve this answer
    
If you answered you own question, please mark it as answered. –  Paul Sep 14 '13 at 2:58
1  
There's a waiting period before you can accept your own answer. –  Snowball Sep 15 '13 at 20:21

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.