禁用一致的接口设备命名

要重新获得ethX,请编辑grub文件。

vi /etc/default/grub

寻找 GRUB_CMDLINE_LINUX 并添加或更改为以下内容 net.ifnames=0. FROM:

GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"

至:

GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet"
[[电子邮件 protected] ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 02:00:17:00:b1:dc brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.2/24 brd 10.0.0.255 scope global dynamic ens3
       valid_lft 86202sec preferred_lft 86202sec
    inet6 fe80::17ff:fe00:b1dc/64 scope link
       valid_lft forever preferred_lft forever
[[电子邮件 protected] ~]# vi /etc/default/grub
[[电子邮件 protected] ~]#  grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1062.12.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.12.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-229.1.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.1.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-64cb9cb13e6a425f9bca6c461e593eb3
Found initrd image: /boot/initramfs-0-rescue-64cb9cb13e6a425f9bca6c461e593eb3.img
Found linux image: /boot/vmlinuz-0-rescue-5eef1a77fa764e12a0a38a6c52d9818b
Found initrd image: /boot/initramfs-0-rescue-5eef1a77fa764e12a0a38a6c52d9818b.img
done

[[电子邮件 protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens3
# Generated by dracut initrd
NAME="ens3"
DEVICE="ens3"
ONBOOT=yes
NETBOOT=yes
UUID="673dfd0f-eece-41f6-b538-6233106248df"
IPV6INIT=yes
BOOTPROTO=dhcp
TYPE=Ethernet
NM_CONTROLLED=no
[[电子邮件 protected] ~]# mv /etc/sysconfig/network-scripts/ifcfg-ens3 /etc/sysconfig/network-scripts/ifcfg-eth0
[[电子邮件 protected] ~]# systemctl disable 网络Manager
[[电子邮件 protected] ~]#
[[电子邮件 protected] ~]# 





重启之前:

[[电子邮件 protected] 〜]#vi / etc / sysconfig / network-scripts / ifcfg-eth0

......
NAME=eth0
DEVICE=eth0
......



将以太网名称从ens3更改为eth0。

rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service'





但是仍然在下次重新启动时,它可能会更改为较早的一次,为此,我们必须通过编辑名为以下文件的系统文件来使其持久化 /usr/lib/udev/rules.d/60-net.rules

[[电子邮件 protected] ~]# cat /usr/lib/udev/rules.d/60-net.rules
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="52:54:00:5f:d0:28", NAME="eth0"

现在,我们将网络以太网卡的名称永久重命名为所需的名称。

[[电子邮件 protected] rules.d]# pwd

/etc/udev/rules.d

[[电子邮件 protected] rules.d]# cat 70-persistent-net.rules |grep -v \#

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:4e:40:9a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

[[电子邮件 protected] rules.d]#
[[电子邮件 protected] ~]#reboot

取消屏蔽NetworkManager服务

nmuti是启动NetworkManager的命令。在上一节中,我们已禁用并屏蔽了此服务。这是取消屏蔽并启用它的步骤。

[[电子邮件 protected] ~]# systemctl list-unit-files | grep 网络
NetworkManager-dispatcher.service             disabled
NetworkManager-wait-online.service            masked
NetworkManager.service                        masked
[[电子邮件 protected] ~]# systemctl unmask 网络Manager
Removed symlink /etc/systemd/system/NetworkManager.service.
[[电子邮件 protected] ~]#  systemctl start 网络Manager
[[电子邮件 protected] ~]# nmuti

[[电子邮件 protected] ~]# systemctl status 网络Manager
[[电子邮件 protected] ~]# systemctl unmask 网络Manager.service
Removed symlink /etc/systemd/system/NetworkManager.service.
[[电子邮件 protected] ~]# systemctl unmask 网络Manager-wait-online.service
Removed symlink /etc/systemd/system/NetworkManager-wait-online.service.

通过 网络安全

发表评论