
Meu /etc/network/interfaces
fica assim:
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
Depois de reiniciar a máquina, recebo
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
Como posso modificar /etc/network/interfaces
para que meu tráfego passe por 10.0.0.1 em vez de 10.0.2.2 por padrão? Posso fazer isso manualmente da seguinte maneira, mas não quero fazer isso a cada reinicialização:
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
Responder1
Acontece que o motivo não estava relacionado com /etc/network/interfaces
. Esta máquina era umaVagabundoVM, que por padrão possui algumas coisas extras em /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
Comentando a dhclient eth0
linha e reiniciando os rendimentos:
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