[root@elk opt]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
编辑信息如下:
DEVICE=eth0s3HWADDR=08:00:27:c6:1a:92TYPE=Ethernet#UUID=ba2acafb-7530-4ca7-9425-52fa227b172dONBOOT=yesNM_CONTROLLED=yesBOOTPROTO=staticIPADDR=192.168.56.105GATEWAY=192.168.1.1NETMASK=255.255.255.0DNS1=192.168.1.1IPV6INIT=noUSERCTL=no
其中HWADDR 地址通过 ip addr 查看:
编辑resolv.conf
增加 nameserver 192.168.1.1
重启网卡:
systemctl stop NetworkManagersystemctl disable NetworkManagersystemctl restart network
如果重启网卡报了:Failed to start LSB: Bring up/down networking
参考资料:http://blog.51cto.com/11863547/1905929
修改/etc/sysconfig/grub,添加net.ifnames=0 biosdevname=0
[root@centos7 ~]# cat /etc/sysconfig/grub GRUB_TIMEOUT=5GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="crashkernel=128M rd.lvm.lv=centos/root rhgb quiet net.ifnames=0 biosdevname=0"GRUB_DISABLE_RECOVERY="true"[root@centos7 ~]#
然后生产菜单:
[root@centos7 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ...Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-8058723e5e754d3aabc51842d9108e3bFound initrd image: /boot/initramfs-0-rescue-8058723e5e754d3aabc51842d9108e3b.imgdone[root@centos7 ~]#
重启虚机,可以了