nix*_*win 10 networking routing debian
这是我的接口文件:
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
Run Code Online (Sandbox Code Playgroud)
如果我重新启动网络守护进程,我会收到此错误: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
Run Code Online (Sandbox Code Playgroud)
我通过使用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
Run Code Online (Sandbox Code Playgroud)
Eli*_*uft 10
这个 /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
Run Code Online (Sandbox Code Playgroud)
我得到两个默认路由:
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
Run Code Online (Sandbox Code Playgroud)
注意指标。我明白你的问题了吗?
归档时间: |
|
查看次数: |
83978 次 |
最近记录: |