centos7版本的系统,发现默认的网卡名字有点怪,为了便于管理,修改一下。
1)编辑网卡信息
[root@rstx-214 ~]# cd /etc/sysconfig/network-scripts/ #进入网卡目录
[root@rstx-214 network-scripts]# mv ifcfg-eno16777728 ifcfg-eth0 #将默认的网卡名eno16777728改为eth0
[root@rstx-214 network-scripts]# cat ifcfg-eth0 #编辑网卡信息
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
NAME=eth0 #name修改为eth0
ONBOOT=yes
IPADDR=192.168.1.214
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=223.5.5.5
2)修改grub
[root@rstx-214 ~]# cat /etc/sysconfig/grub #编辑内核信息,添加红色字段的
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=autorhgb net.ifnames=0 biosdevname=0 quiet"
GRUB_DISABLE_RECOVERY="true"
生成启动菜单
[root@rstx-214 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generatinggrub configuration file ...
Foundlinux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Foundinitrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Foundlinux image: /boot/vmlinuz-0-rescue-1100f7e6c97d4afaad2e396403ba7f61
Foundinitrd image: /boot/initramfs-0-rescue-1100f7e6c97d4afaad2e396403ba7f61.img
Done
也可以在开机启动加载安装系统界面设置。
3)验证是否修改成功
[root@rstx-214 ~]# reboot #必须重启系统生效
[root@rstx-214 ~]# yum install net-tools #默认centos7不支持ifconfig 需要看装net-tools包
[root@rstx-214 ~]# ifconfig eth0 #在次查看网卡信息
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.214 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fdc3:8811:1412:0:2e0:4cff:fe25:e423 prefixlen 64 scopeid 0x0<global>
inet6 fe80::2e0:4cff:fe25:e423 prefixlen 64 scopeid 0x20<link>
ether 00:e0:4c:25:e4:23 txqueuelen 1000 (Ethernet)
RX packets 13487 bytes 1093943 (1.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3256 bytes 306491 (299.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
centos7启动网卡服务报错“RTNETLINK answers: File exists”的解决方法
[root@localhost network-scripts]# service NetworkManager stop
Starting network (via systemctl): Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
[root@localhost network-scripts]# systemctl status network.service
?.network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network)
Active: failed (Result: exit-code) since Mon 2017-03-20 18:41:03 CST; 3min 49s ago
Docs: man:systemd-sysv-generator(8)
Process: 18880 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
Mar 20 18:41:03 localhost.localdomain network[18880]: RTNETLINK answers: File exists
Mar 20 18:41:03 localhost.localdomain network[18880]: RTNETLINK answers: File exists
Mar 20 18:41:03 localhost.localdomain network[18880]: RTNETLINK answers: File exists
Mar 20 18:41:03 localhost.localdomain network[18880]: RTNETLINK answers: File exists
Mar 20 18:41:03 localhost.localdomain network[18880]: RTNETLINK answers: File exists
Mar 20 18:41:03 localhost.localdomain network[18880]: RTNETLINK answers: File exists
Mar 20 18:41:03 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1
Mar 20 18:41:03 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
Mar 20 18:41:03 localhost.localdomain systemd[1]: Unit network.service entered failed state.
Mar 20 18:41:03 localhost.localdomain systemd[1]: network.service failed.
原因分析和解决:
在centos下出现该故障的原因是启动网络的两个服务/etc/init.d/network 和 /etc/init.d/NetworkManager有冲突。
从根本上说是NetworkMaganager(NM)的带来的冲突,停用NetworkManager即可解决。重启即可。
[root@localhost network-scripts]# service NetworkManager stop
Redirecting to /bin/systemctl stop NetworkManager.service
[root@localhost network-scripts]# systemctl start network.service