前言:Centos 7服務器出現網絡異常的問題
排查步驟:
1.確認是否有IP地址
2.重啓網卡是否成功
3.是否有衝突的網絡管理工具(network&NetworkManger)
4.檢查網卡的配置文件是否正常
Warning:主要看日誌,默認Log存放位置(/var/log/messages)
(1)檢測是否有IP地址
(這裏就不上圖了,能夠看到網卡信息,可是沒有IP地址)
咱們看一下日誌服務器
Apr 8 10:35:20 localhost network: Bringing up interface eth0: ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device has different MAC address than expected, ignoring. Apr 8 10:35:20 localhost /etc/sysconfig/network-scripts/ifup-eth: Device has different MAC address than expected, ignoring. Apr 8 10:35:20 localhost network: [FAILED] Apr 8 10:35:20 localhost systemd: network.service: control process exited, code=exited status=1 Apr 8 10:35:20 localhost systemd: Failed to start LSB: Bring up/down networking. Apr 8 10:35:20 localhost systemd: Unit network.service entered failed state. Apr 8 10:35:20 localhost systemd: network.service failed.
這裏明顯說明MAC地址問題咱們就看一下MAC地址是否正確網絡
[root@localhost ~]# grep HAW /etc/sysconfig/network-scripts/ifcfg-eth0 HAWDDR="打碼不給你看"
而後確認一下eth0網卡的MAC地址是否正確ide
[root@localhost ~]# cat /sys/class/net/eth0/address 打碼打碼
如今確認MAC地址不一致,咱們修改網卡配置文件工具
[root@localhost ~]sed -i 's'/原配置文件的MAC/如今配置文件的MAC/g' /etc/sysconfig/network-scripts/ifcfg-eth0
再次重啓網卡rest
[root@localhost ~]# systemctl restart network
不出意外又報錯了,咱們再看一下日誌信息日誌
Apr 8 10:43:47 localhost /etc/sysconfig/network-scripts/ifup-eth: Device does not seem to be present, delaying initialization. Apr 8 10:43:47 localhost network: [FAILED] Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists Apr 8 10:43:47 localhost network: RTNETLINK answers: File exists
此次的報錯不同了,告訴咱們找不到文件(這種類型的報錯範圍廣,不容易排查,咱們從一下幾點排查)
1.首先排查配置文件是否指定網卡名稱
對象:文件名
網卡配置:NAME、DEVICE
2.檢查70-persistent-net.rules自定義網卡信息配置文件
3.網卡信息是否刷新
(1)檢查配置文件名稱code
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 # Generated by dracut initrd NAME="eth0" HWADDR="打碼" ONBOOT=yes NETBOOT=yes UUID="打碼" IPV6INIT=yes BOOTPROTO=dhcp TYPE=Ethernet
這裏缺乏DEVICE名稱咱們加上對象
[root@localhost ~]# sed -i '3a/DEVICE=eth0' /etc/sysconfig/network-scripts/ifcfg-eth0
重啓服務嘗試dns
[root@localhost ~]# systemctl restart network
服務正常了
(2)檢查70-persistent-net.rules自定義網卡信息配置文件ip
[root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules
若是沒有這個文件這一步能夠跳過,有的話比對信息
(3)刷新網卡
[root@localhost ~]# ip addr flush dev eth0
通常這些作完就能夠排除網卡配置問題若是還有問題請檢查route、dns、到DHCP服務器是否正常、若是是虛擬機的話查看虛擬機網卡配置是否正常等