And*_*ndy 6 networking linux redhat centos6
我正在尝试配置具有 3 个 NIC 的机器,前两个是内置 GbE 控制器,第三个是 10GbE 控制器。通过 NetworkManager,我将“第一个”GbE NIC(当时是 eth0)配置为使用静态 IP 地址。第二个 GbE NIC 将配置在单独的专用网络上,并且 10GbE NIC 现在未使用。
当我重新启动机器时,eth0、eth1、eth2 等的顺序似乎是随机的。有时 eth0 会获取静态 IP 地址,其他时候它会被识别为 eth1 并获取 DHCP 地址。在这种情况下,我需要在正确重新配置之前交换电缆。
如何控制排序,以便特定物理 NIC 始终显示为 eth0 或 eth1,而无需更改下次重新启动?
RHEL 6 中仍然支持的方法是通过 udev 设备规则。
应该有一个自动生成的 /etc/udev/rules.d/70-persistent-net.rules强制一致的命名:
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
# PCI device 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:1d:d1:30", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:90:1d:d1:31", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
Run Code Online (Sandbox Code Playgroud)
如果没有,您可以对自己的 MAC 地址使用类似的语法来强制持久设备命名。
小智 5
也许有人会发现这些信息很有用:首先,在 RHEL7 中,您不需要重新安装系统来更改界面命名约定。
注意:需要引导参数:
a) With no parameters or net.ifnames=1 used, the names will use systemd Predictable Network Interface Names
b) With biosdevname=1 used, the names will be managed by udev (technically systemd-udev) using Consistent Network Device Naming
c) With net.ifnames=0 and biosdevname=0 both specified, traditional ("kernel names") ethX names will be used; if udev rules are also added they can rename the interfaces to anything except eth
Run Code Online (Sandbox Code Playgroud)
例子:
Edit /etc/default/grub
append selected params eg.
biosdevname=0 net.ifnames=0
grub2-mkconfig -o /boot/grub2/grub.cfg
Run Code Online (Sandbox Code Playgroud)
在主题的情况下:当您需要调整所有接口的顺序时,程序很容易:
mv /etc/udev/rules.d/70-persistent-net.rules /root/
(New udev rules will be generated at next boot)
Adjust configuration files in
/etc/sysconfig/network-scripts/ifcfg-eth*
[Edit device name, connection name, HWADDR etc.]
Reboot and then udev will generate rules basing on configuration files - if you did it properely.
Run Code Online (Sandbox Code Playgroud)