学习和工作中,总是遇到奇奇怪怪的一些问题,处理之后记录在这里。
一、由于网卡名改变导致的网络服务启动失败
1.现象:服务器重启之后发现网络不通,然后ifconfig 发现网卡eth0不见了,只有本地lo
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:12536 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:594 (594.0 B) TX bytes:594 (594.0 B)
然后尝试了ifup eth0,返回结果说没有这个设备
然后重启网络服务/etc/init.d/networking restart也是失败的
Restarting networking (via systemctl): networking.serviceJob for networking.service failed because the control process exited with error code. See "systemctl status networking.service" and "journalctl -xe" for details.
failed!
查状态/etc/init.d/networking status出现错误:Failed to start Raise network interf….
2.检查网卡名dmesg |grep eth
[ 0.000000] psci: probing for conduit method from ACPI.
[ xx.2xxx25] netif_napi_add() called with weight 256 on device eth%d
[ xx.1xxx76] r8169 xxx:03 enp2s3: renamed from eth3
[ xx.2xxx12] r8169 xxx:01 enp2s1: renamed from eth1
[ xx.2xxx71] r8169 xxx:02 enp2s2: renamed from eth2
[ xx.3xxx96] r8169 xxx:00 enp2s0: renamed from eth0
发现网卡名发生变化
4.修改网络配置文件:
vim /etc/network/interfaces
将里面的eth0都替换成新网卡名:enp2s0
auto enp2s0
iface enp2s0 inet static
address 192.168.5.39
gateway 192.168.5.1
netmask 255.255.255.0