在我的接口配置文件中,我只为 192.168.2.0 添加了一条路由,但是当机器运行时,192.168.2.0 有一个 0.0.0.0 网关。
如何仅使用接口配置来解决这个问题?
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.164.0.1 0.0.0.0 UG 600 0 0 wlan0
10.164.0.0 0.0.0.0 255.255.0.0 U 600 0 0 wlan0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
192.168.2.0 192.168.2.101 255.255.255.0 UG 0 0 0 eth0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
202.161.42.25 10.164.0.1 255.255.255.255 UGH 600 0 0 wlan0
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.2.102
netmask 255.255.255.0
up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.101