이것은 내 인터페이스 파일입니다.
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
auto eth1
iface eth1 inet static
address 192.168.2.10
netmask 255.255.255.0
gateway 192.168.2.1
네트워킹 데몬을 다시 시작하면이 오류가 발생 eth1 is not up
합니다. 나는 두 개의 기본 게이트웨이 가 여기에 대한 질문에 대한 대답에서 언급 된 것을 달성하기를 원합니다 . 이것이 나의 라우팅 테이블이되는 방법입니다 :
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
default 192.168.2.1 0.0.0.0 UG 0 0 0 eth1
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.2.0 * 255.255.255.0 U 0 0 0 eth1
ifconfig
및 route add default gw
명령 을 사용하여 위의 테이블을 얻었습니다 . 하지만 /etc/network/interfaces
파일로 하고 싶습니다 . 어떻게하니?
업데이트 1 :
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
up ip route del 192.168.1.0/24
post-up ip route add 192.168.1.0/24 dev eth0 metric 1
up route add default gw 192.168.1.1 metric 1
답변
이 / etc / network / interfaces는 2.6.32-40 Ubuntu 10.04 LTS에서 작동합니다.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.254
post-up route add default gw 192.168.1.1 metric 1
pre-down route del default gw 192.168.1.1
auto eth1
iface eth1 inet static
address 192.168.2.10
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.254
post-up route add default gw 192.168.2.1 metric 2
pre-down route del default gw 192.168.2.1
두 가지 기본 경로가 있습니다.
root@gamla:/etc/network# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 192.168.1.1 0.0.0.0 UG 1 0 0 eth0
0.0.0.0 192.168.2.1 0.0.0.0 UG 2 0 0 eth1
메트릭을 참고하십시오. 당신의 질문을 이해 했습니까?