기본 네트워크 인터페이스 설정

기본 네트워크 인터페이스 설정

/etc/network/interfaces모습은 다음과 같습니다.

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

컴퓨터를 재부팅한 후에는 다음과 같은 메시지가 표시됩니다.

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

/etc/network/interfaces내 트래픽이 기본적으로 10.0.2.2 대신 10.0.0.1을 통과하도록 수정하려면 어떻게 해야 합니까 ? 다음과 같이 수동으로 수행할 수 있지만 재부팅할 때마다 이 작업을 수행하고 싶지는 않습니다.

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

답변1

그 이유는 과 관련이 없는 것으로 밝혀졌습니다 /etc/network/interfaces. 이 기계는방랑자VM에는 기본적으로 다음과 같은 추가 기능이 있습니다 /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

해당 줄을 주석 처리 dhclient eth0하고 재부팅하면 다음과 같은 결과가 나옵니다.

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 

관련 정보