我们刚刚在用于工作测试的旧电脑(ubuntu 18.04 - 无 GUI)上更换了外壳,导致无法访问网络 - ping 8.8.8.8,返回:
"connect: Network is unreachable"
我们为解决此问题所采取的措施:1. 修复日期时间 -> 重新启动 2. 将 dhcp4 更改为“True”(然后更改为“Yes”)3. sudo netplan --debug generate 4. sudo netplan --debug apply
后者返回:
"NetworkManager: definition enp0s7 is not for us (backend 1)".
ifconfig-a:
docker0: flags=[...]
enp0s7: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
[...]
lo: flags=73 [...]
lspci 结果:
00:07.0 Bridge: NVIDIA Corporation MCP61 Ethernet (rev a2)
Kernel driver in user: forcedeth
Kernel modules: forcedeth
提前感谢您提供的任何帮助/见解/来源以弄清楚发生了什么!
编辑
@heynnema 非常感谢您及时提供帮助!结果如下:
01-network-card.yaml(最新尝试让DHCP开放并获取动态IP):
network:
version: 2
renderer: networkd
ethernets:
enp0s7:
dhcp4: yes
01-网卡.yaml.保存
network:
version: 2
renderer: networkd
ethernets:
enp0s7:
dhcp4: no
addresses: [192.168.1.97/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.4.4,8.8.8.8]
sudo lshw -C 网络
*-network
description: Ethernet interface
physical id: 1
logical name: docker0
serial: 02:42:72:32:11:63
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.17.0.1 link=no multicast=yes
cat /etc/network/interfaces (似乎它甚至没有安装,因为netplan
)
# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
# sudo apt install ifupdown
答案1
检查您的以太网电缆。您应该使用 cat 5e 或 cat 6 电缆。
假设sudo lshw -class bridge
显示 enp0s7 是您的以太网卡...
.yaml 文件
Netplan 对 .yaml 格式非常挑剔。您的格式/etc/netplan/01-network-card.yaml
应如下所示(保留间距,无制表符):
network:
version: 2
renderer: networkd
ethernets:
enp0s7:
dhcp4: true
sudo netplan --debug generate
sudo netplan apply
reboot
Nvidia 驱动程序
这张NVIDIA Corporation MCP61 Ethernet
卡看上去很难工作。
从这错误报告,我们得到这个代码片段来修改 forcedeth 驱动程序...
在终端中输入这两个命令:
echo "options forcedeth msi=0 msix=0" | sudo tee /etc/modprobe.d/forcedeth_options.conf
sudo update-initramfs -u
然后重新启动你的机器