更换主板后无法联网

更换主板后无法联网

我有一块安装了 Ubuntu Server 20.04 内核 5.4.0-77 的 SSD。我搬家了,SSD 也搬了,但服务器本身却没有。我暂时把 SSD 扔到了另一台机器上,但我无论如何都无法联网。新机器上的网络适配器是“Realtek RTL8111/8168/8411”。起初,我尝试从这里pci-aspm.h,但它无法构建(我认为这与在某个时候被合并有关pci.h?)无论如何,在那之后,我清除了文件,并从中获取了驱动程序这里(GBE)并用 构建它autorun.sh。它似乎安装得很好,但我找不到任何证据表明它正在工作。我将放出几个命令的输出,因为我认为这些命令比我试图解释的更能说明问题:

$ lsmod | grep r8168
r8168      540672  0

$ lspci -v
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
        Subsystem: Dell RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
        Flags: bus master, fast devsel, latency 0, IRQ 40
        I/O ports at d000 [size=256]
        Memory at f2104000 (64-bit, prefetchable) [size=4K]
        Memory at f2100000 (64-bit, prefetchable) [size=16K]
        Capabilities: <access denied>
        Kernel Driver in use: r8168
        Kernel Modules: r8168

$ ifconfig -a
br-0e94947f61e9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.20.0.1  netmask 255.255.0.0  broadcast 172.20.255.255
        ether 02:42:c3:55:aa:70  txqueuelen 0  (Ethernet)
        RX packets 43  bytes 1204 (1.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 780  bytes 80552 (80.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ae:d4:6d:fc  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

enp5so: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 78:45:c4:fe:20:14  txqueuelen 1000  (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
        device interrupt 40  base 0x9000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop txqueuelen 1000  (Local Loopback)
        RX packets 7437  bytes 847680 (847.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7437  bytes 847680 (847.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ cat /etc/netplan/*.yaml 
# This is the network config written by ‘subiquity’
network:
  ethernets:
    eno1:
      dhcp4: true
  version: 2

如果还有其他需要我提供的,我非常乐意。我整天都在忙于此事,所以可能忘记了一些显而易见的事情。无论如何,请帮我弄清楚如何启动和运行我的网络接口,谢谢。

答案1

Ubuntu Server 20.04 及更高版本中的网络由 netplan 处理。您的 netplan 文件引用以太网接口 eno1。由于您将 SSD 移到了不同​​的主板,因此接口实际上现在是 enp5s0。我们只需更改 netplan 文件以匹配即可。

首先,我们需要知道文件的确切名称。从终端:

cd /etc/netplan && ls

这将显示文件的确切名称。现在让我们编辑它以进行更改:

sudo nano fileyoufound.yaml

更改此文件:

# This is the network config written by ‘subiquity’
network:
  ethernets:
    eno1:
      dhcp4: true
  version: 2

对此:

# This is the network config written by ‘subiquity’
network:
  ethernets:
    enp5s0:
      dhcp4: true
  version: 2

Netplan 对缩进、间距等非常具体,因此请仔细校对两遍。保存(Ctrl+o 后按 Enter)并关闭(Ctrl+x 后按 Enter)文本编辑器 nano。

接下来是:

sudo netplan generate
sudo netplan apply

你連線了嗎?

ping -c3 www.ubuntu.com

相关内容