我有一个网卡的Debian拉伸服务器。 我希望它连接到我的(正常configuration的标准DHCP)路由器。
所以正常情况下我会说iface eth0 inet dhcp 。 但是我有一个网卡安装了两个额外的以太网端口。
根据网卡的PCI插槽,端口名称不同:
enp5s0 enp8s0第一个插卡插槽称为enp3s0第二个插卡enp4s0称为enp4s0 enp9s0第一个插卡sockets称为enp6s0第二个插卡sockets称为enp7s0 我希望我的服务器通过enp5s0 , enp8s0或enp9s0连接到路由器,无论是否有普通的dhcp客户端。
我不想使用其他连接,因为我稍后要分配特殊的虚拟化configuration:)
任何人都可以推荐我一个/ etc / network / interfacesconfiguration可以实现这个吗?
三年前,我在Ubuntu 12.04下遇到了一个问题,那就是硬件在两台相同的服务器上没有被一致地命名。 修复很简单,我想你可以在Debian下做同样的事情。
我的解决scheme是使用udev根据它的mac地址重命名设备。 这样,无论您插入哪个插槽,该设备将始终命名相同。
这应该在Debian下工作。
例如用ifconfig获取卡的MAC地址
enp0s25 Link encap:Ethernet HWaddr 20:cf:30:2f:40:79 inet addr:192.168.0.114 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::ecb9:ee41:b487:b54a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:338426 errors:0 dropped:0 overruns:0 frame:0 TX packets:168905 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:385564822 (385.5 MB) TX bytes:32387645 (32.3 MB) Interrupt:20 Memory:f9de0000-f9e00000
然后编辑或创build文件/etc/udev/rules.d/010_netinterfaces.rules(在Ubuntu 12.04下它被称为/etc/udev/rules.d/70-persistent-net.rules)
为每张卡添加一行:
KERNEL=="eth*", SYSFS{address}=="20:cf:30:2f:40:79", NAME="eth0"
然后用新名称更新你的/etc/network/interfaces 。
# The primary network interface auto eth0 iface eth0 inet dhcp
现在,您可以将卡插入任何插槽,并且设备名称始终为eth0 。