Linux之修改NIC名
一般创建虚拟机是,添加的网卡的名字都比较奇怪,而且特别长,有时候会希望将他们改成eth0,eth1的这种命名方式。
做这个还是需要特别注意的,最好修改前先做个snapshot,否则,哪个地方没改好。虚拟机就起不来了。
1.以root用户登录到虚拟机
2.修改网卡的名称
/etc/sysconfig/network-scripts/ifcfg-XXXX修改成ifcfg-eth0(例)
vi /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
UUID=01e2a4f1-0117-46cc-97d6-420fcde7072a
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.100.25
GATEWAY=192.168.100.254
3.修改grub.cfg文件
# cd /boot/grub2/
# cp -p grub.cfg grub.cfg.bak
# vi grub.cfg
# diff grub.cfg grub.cfg.bak
< linux16 /vmlinuz-3.10.0-514.16.1.el7.x86_64 root=/dev/mapper/vg00-root ro rd.lvm.lv=vg00/root rd.lvm.lv=vg00/swap rhgb quiet crashkernel=128M ipv6.disable=1 net.ifnames=0 biosdevname=0 LANG=ja_JP.UTF-8
---
> linux16 /vmlinuz-3.10.0-514.16.1.el7.x86_64 root=/dev/mapper/vg00-root ro rd.lvm.lv=vg00/root rd.lvm.lv=vg00/swap rhgb quiet crashkernel=128M ipv6.disable=1 net.ifnames=1 biosdevname=0 LANG=ja_JP.UTF-8
113c113
< linux16 /vmlinuz-0-rescue-3ee13ab662eb4e02aa165d688b29b61d root=/dev/mapper/vg00-root ro rd.lvm.lv=vg00/root rd.lvm.lv=vg00/swap rhgb quiet crashkernel=128M ipv6.disable=1 net.ifnames=0 biosdevname=0
---
> linux16 /vmlinuz-0-rescue-3ee13ab662eb4e02aa165d688b29b61d root=/dev/mapper/vg00-root ro rd.lvm.lv=vg00/root rd.lvm.lv=vg00/swap rhgb quiet crashkernel=128M ipv6.disable=1 net.ifnames=1 biosdevname=0
4.重启shutdown -r now
5.ifconfig确认是不是修改成功。
))