天天看點

Centos7修改預設網卡名(改為eth0)以及網卡啟動報錯RTNETLINK answers: File exists處理

安裝好centos7版本的系統後,發現預設的網卡名字有點怪,為了便于管理,可以手動修改。下面對centos7版本下網卡重命名操作做一記錄:

1)編輯網卡資訊

[root@linux-node2~]# cd /etc/sysconfig/network-scripts/                             #進入網卡目錄

[root@linux-node2network-scripts]# mv ifcfg-eno16777728 ifcfg-eth0          #将預設的網卡名eno16777728改為eth0

[root@linux-node2network-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.56.12

NETMASK=255.255.255.0

GATEWAY=192.168.56.2

DNS1=192.168.56.2

2)修改grub

[root@linux-node2~]# 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@linux-node2~]# 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)驗證是否修改成功

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<code>[root@linux-node2~]</code><code># reboot                           #必須重新開機系統生效</code>

<code>[root@linux-node2~]</code><code># yum install net-tools                   #預設centos7不支援ifconfig 需要看裝net-tools包</code>

<code>[root@linux-node2~]</code><code># ifconfig eth0                 #在次檢視網卡資訊</code>

<code>eth0:flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt; mtu 1500</code>

<code>inet 192.168.56.12 netmask 255.255.255.0 broadcast 192.168.56.255</code>

<code>inet6 fe80::20c:29ff:fe5c:7bb1 prefixlen 64 scopeid 0x20&lt;link&gt;</code>

<code>ether 00:0c:29:5c:7b:b1 txqueuelen 1000 (Ethernet)</code>

<code>RX packets 152 bytes 14503 (14.1 KiB)</code>

<code>RX errors 0 dropped 0 overruns 0 frame 0</code>

<code>TX packets 98 bytes 14402 (14.0 KiB)</code>

<code>TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 </code>

centos7啟動網卡服務報錯“RTNETLINK answers: File exists”的解決方法

19

20

21

22

23

24

25

26

27

28

<code>[root@localhost network-scripts]</code><code># service NetworkManager stop</code>

<code>Starting network (via systemctl):  Job </code><code>for</code> <code>network.service failed because the control process exited with error code. See </code><code>"systemctl status network.service"</code> <code>and </code><code>"journalctl -xe"</code> <code>for</code> <code>details.</code>

<code>[root@localhost network-scripts]</code><code># systemctl status network.service</code>

<code>?.network.service - LSB: Bring up</code><code>/down</code> <code>networking</code>

<code>   </code><code>Loaded: loaded (</code><code>/etc/rc</code><code>.d</code><code>/init</code><code>.d</code><code>/network</code><code>)</code>

<code>   </code><code>Active: failed (Result: </code><code>exit</code><code>-code) since Mon 2017-03-20 18:41:03 CST; 3min 49s ago</code>

<code>     </code><code>Docs: </code><code>man</code><code>:systemd-sysv-generator(8)</code>

<code>  </code><code>Process: 18880 ExecStart=</code><code>/etc/rc</code><code>.d</code><code>/init</code><code>.d</code><code>/network</code> <code>start (code=exited, status=1</code><code>/FAILURE</code><code>)</code>

<code>Mar 20 18:41:03 localhost.localdomain network[18880]: RTNETLINK answers: File exists</code>

<code>Mar 20 18:41:03 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1</code>

<code>Mar 20 18:41:03 localhost.localdomain systemd[1]: Failed to start LSB: Bring up</code><code>/down</code> <code>networking.</code>

<code>Mar 20 18:41:03 localhost.localdomain systemd[1]: Unit network.service entered failed state.</code>

<code>Mar 20 18:41:03 localhost.localdomain systemd[1]: network.service failed.</code>

<code>原因分析和解決:</code>

<code>在centos下出現該故障的原因是啟動網絡的兩個服務</code><code>/etc/init</code><code>.d</code><code>/network</code> <code>和 </code><code>/etc/init</code><code>.d</code><code>/NetworkManager</code><code>有沖突。</code>

<code>從根本上說是NetworkMaganager(NM)的帶來的沖突,停用NetworkManager即可解決。重新開機即可。</code>

<code>Redirecting to </code><code>/bin/systemctl</code> <code>stop  NetworkManager.service</code>

<code>[root@localhost network-scripts]</code><code># systemctl start network.service</code>

<code>[root@localhost network-scripts]</code><code>#</code>

***************當你發現自己的才華撐不起野心時,就請安靜下來學習吧***************

本文轉自散盡浮華部落格園部落格,原文連結:http://www.cnblogs.com/kevingrace/p/5570274.html,如需轉載請自行聯系原作者

繼續閱讀