我有一台运行Ubuntu Server 12.04的VMware虚拟机。 我为虚拟机configuration了两个networking适配器,而我的/ etc / network / interfacesconfiguration如下所示:
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 10.226.83.2 netmask 255.255.255.248 gateway 10.226.83.1 # Management Interface auto eth1 iface eth1 inet static address 10.20.9.200 netmask 255.255.240.0 up ip route add 10.20.0.0/20 via 10.20.0.1 dev eth1 || true up ip route add 10.21.120.0/22 via 10.20.0.1 dev eth1 || true up ip route add 10.13.122.0/22 via 10.20.0.1 dev eth1 || true
我的问题是,在这个特定的configuration,我无法看到路由到10.13.122.0/22时调用路由:
$ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 10.226.83.1 0.0.0.0 UG 100 0 0 eth0 10.20.0.0 * 255.255.240.0 U 0 0 0 eth1 10.21.120.0 10.20.0.1 255.255.252.0 UG 0 0 0 eth1 10.118.233.0 10.118.233.2 255.255.255.0 UG 0 0 0 tun10000 10.118.233.2 * 255.255.255.255 UH 0 0 0 tun10000 10.226.83.0 * 255.255.255.248 U 0 0 0 eth0
我试图完成的是来自networking10.20.0.0,20,10.21.120.0/22和10.13.122.0/22的stream量将穿过eth1到10.20.0.1,否则stream量将通过eth0并通过10.226.83.1。 tun10000是由我们的OpenVPNconfiguration生成的一个适配器,在这种情况下可以忽略。
目前除10.13.122.0/22以外的所有内容都正常工作,这反映在路由表中; 我在表中看不到10.13.122.0/22,即使使用与其他两个networking相同的语法添加它的路由。
另外,当我做sudo /etc/init.d/networking重新启动,我得到以下内容:
$ sudo /etc/init.d/networking restart * Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces * Reconfiguring network interfaces... ssh stop/waiting ssh start/running, process 21240 RTNETLINK answers: File exists RTNETLINK answers: Invalid argument ssh stop/waiting ssh start/running, process 21306
即使有两个RTNETLINK答案,我也得到了一个function接口,除了到10.13.122.0/22的路由。 我怎样才能得到这条路线工作,有没有办法摆脱“文件存在”和“无效参数”的消息?
10.21.120.0/22是10.21.120.0-10.21.123.255,因此等同于10.13.122.0/22 。 因此,为10.13.122.0/22设置一个路由会给出错误“文件存在”(或者更准确地说“条目已经存在”)。
你需要弄清楚你的networking拓扑结构。
我在configuration中有错误的掩码; 交换10.13.122.0/22到10.13.122.0/23得到的东西工作。