![12.04 服务器多个 IP 地址和多个接口](https://linux22.com/image/851359/12.04%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%A4%9A%E4%B8%AA%20IP%20%E5%9C%B0%E5%9D%80%E5%92%8C%E5%A4%9A%E4%B8%AA%E6%8E%A5%E5%8F%A3.png)
我在 VirtualBox 上运行 Ubuntu 12.04 Server。我尝试设置两个具有静态 IP 地址的接口。如果我只连接一个网络接口,那么 eth0 可以正常工作,但是一旦我连接第二个接口,eth0 就无法工作,而 eth1 可以工作。我这样做是因为 eth0 是我的管理子网,而 eth1 是我的管理员/员工子网。下面是我配置 /etc/network/interfaces 文件的方式。任何帮助都将不胜感激。谢谢。
# This file describes the network interfaces available on your system
# and how to active them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 10.192.168.60
netmask 255.255.254.0
gateway 10.192.168.1
network 10.192.168.0
broadcast 10.192.169.255
dns-nameserver 192.168.1.21
# The secondary network interface
auto eth1
iface eth1 inet static
address 192.168.0.11
netmask 255.255.248.0
gateway 192.168.0.1
network 192.168.0.0
broadcast 192.168.7.255
dns-nameserver 192.168.1.21
答案1
可能是 udev 设置有问题?首先检查两个接口是否都显示出来,ifconfig -a
以及 udev 是否正确处理了它们:
cat /etc/udev/rules.d/70-persistent-net.rules
(检查 mac 地址 eth0 是否与 udev 规则 eth0 匹配,等等)
其次,由于您在两个 NIC 上使用相同的名称服务器,并且可从 eth1 访问,那么网关是否应该位于 eth1 上并启用 NIC 之间的转发?
echo 1 > /proc/sys/net/ipv4/ip_forward
第三,由于您的 eth0 具有标准网络掩码/广播,请尝试省略规则并让 ubuntu 仅通过提供必要的信息来确定路由:
auto eth0
iface eth0 inet static
address 10.192.168.60
netmask 255.255.254.0
dns-nameserver 192.168.1.21