今天早上,我的 Ubuntu 18.04 服务器版机器上的网络不再工作了:
marco@pc01:$ sudo lshw -class network
*-network DISABLED
description: Ethernet interface
product: RTL8111/8168/8411 PCI Express
Gigabit Ethernet Controller
*-network DISABLED
description: Wireles interface
product: AR9227 Wireless Network Adapter
*-network:0
description: Ethernet interface
physical id: 2
logical name : docker0
*-network:1
description: Ethernet interface
physical id: 3
sudo nano /etc/nework/interfaces
:
iface eth0 inet static
address 192.168.1.7
netmask 255.255.255.0
network 192.168.1.1
broadcast 192.168.0.255
post-up iptables-restore <
/etc/iptables.up.rules
gateway 192.168.1.1
dns-nameservers 192.168.0.5 8.8.8.8
marco@pc01:$ sudo service network-manager restart
Failed to restart network-manager.service: Unit network-manager.service
not found
即使sudo /etc/init.d/networking restart
:
marco@pc01:$ sudo /etc/init.d/networking restart
[ok] Restarting networking (via systemctl):
networking.service
marco@pc01:$ ping 192.168.1.4
connect: Network is unreachable
marco@pc01:$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKOWN group
default qlen 1000
inet 27.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group
default qlen 1000
link/ether 78:24:af:43:ef:5c brd ff:ff:ff:ff:ff:ff
3: wlp5s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group
default qlen 1000
link/ether c0:4a:00:09:0e:80 brd ff:ff:ff:ff:ff:ff
4: b3-4f9fe03b1a66: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc
noqueue state DOWN group default
link/ether 02:42:64:29:65:73 brd ff:ff:ff:ff:ff:ff
inet 172.22.0.1/16 brd 172.22.255.255 scope global br-4f9fe03b1a66
valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue
state DOWN group default
link/Ether 02:42:01:ea:90:66 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scoper global docker0
valid_lft forever preferred_lft forever
marco@pc01:$ ifconfig eth0 up eth0: ERROR while getting interface flags:
eth0: ERROR while getting interface flgs: No such device
eth0: Host name lookup failure
marco@pc01:$ ifconfig
br-4f9feo3b1a66: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.22.0.1 netmask 255.255.0.0 broadcast 172.22.255.255
ether 02:42:4d:c4:bd:62 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0B)
RX errors 0 dropped 0 overruns 0 frame 0
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4099<,UP,BROADCAST,MULTICAST> mtue 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:24:b9:3b:59 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
l0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefoxlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 258 bytes 32343 (32.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 258 bytes 32343 (32.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
/etc/network/interfaces :
auto lo
iface lo inet loopback
4°更新:
marco@pc01:$ uname -r
4.15.0-55-generic
marco@pc01:$ ls -al /etc/netplan
total 20
drwxr-xr-x 2 root root 4096 Jul 25 18:37
drwxr-xr-x 128 root root 12288 Jul 25 12:51
-rw-r--r-- 1 root root 616 Jul 25 18:37 30-cloun-init.yaml
etc/netplan/50-cloud-init.yaml :
network:
renderer: NetworkManager/ networkd
ethernets:
enp3s0:
addresses: [192.168.1.7/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8,8.8.4.4]
dhcp4: no
version: 2
marco@pc01:$ sudo netplan apply
sudo: netplan: command not found
对于sudo llshw -c network
:请参见上文
我该怎么做才能让网络再次可用?期待您的帮助 Marco
答案1
上面显示“eth0:获取接口标志时出错:没有这样的设备”。可能是驱动程序问题或硬件已停用/不可用。检查系统日志,尤其是内核。其他错误可能是次要的,或者在某些情况下,您可能输入了错误的命令(我不熟悉 Ubuntu)。
(Linux 已经变得非常复杂,还有网络......)