本文共 2495 字,大约阅读时间需要 8 分钟。
[root@ansheng ~]# cd /etc/sysconfig/network-scripts/
[root@ansheng network-scripts]# vi ifcfg-eno16777728 TYPE=EthernetBOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=noNAME=eth0 UUID=8a3eade8-005c-46df-81f2-6e2598457bac #DEVICE=eno16777728DEVICE=eth0ONBOOT=yesHWADDR=00:0c:29:94:b0:0cIPADDR=192.168.8.81(注意,这里要和网关的子网相对应) NETMASK=255.255.255.0 GATEWAY=192.168.8.1 DNS1=8.8.8.8 DNS2=114.114.114.114 (如果不知道硬件地址是什么,用 ip addr命令查看)[root@ansheng network-scripts]# mv ifcfg-eno16777728 ifcfg-eth0
[root@ansheng network-scripts]# vi /etc/default/grub
GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0" GRUB_DISABLE_RECOVERY="true"[root@ansheng network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-4dd6b54f74c94bff9e92c61d669fc195 Found initrd image: /boot/initramfs-0-rescue-4dd6b54f74c94bff9e92c61d669fc195.img done[root@ansheng network-scripts]# reboot
[root@ansheng ~]# ip addr
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.56.130 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::20c:29ff:fe6d:d894 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6d:d8:94 txqueuelen 1000 (Ethernet) RX packets 27413 bytes 38532163 (36.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 7727 bytes 702194 (685.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0本文转自 Lee_吉 博客,原文链接: http://blog.51cto.com/12173069/2051476 如需转载请自行联系原作者