尝试设置静态 IP 地址后,我的计算机无法识别网卡

尝试设置静态 IP 地址后,我的计算机无法识别网卡

安装 Ubuntu Server 20.xx 后,我更改了/etc/netplan/00-installer-config.yaml获取静态IP地址的内容:

network:
  ethernets:
    enp0s3:
      addresses: [192.168.1.17/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1]
  version: 2

但是当我执行:sudo netplan 申请好像我的网卡断开了,我无法检测到 IP 地址,当我卷曲-Ihttp://google.com我没有得到任何回应,并且以太网灯也没有闪烁。

更新:

mostafa@dell-xps:~$ Is -al /etc/netplan
total 12 
drwxr-xr-x 2 root root 4096 Apr 8 19:05 . 
drwxr-xr-x 102 root root 4096 Apr 8 18:11 .. 
-rw-r--r-- 1 root root 117 Apr 8 19:05 00-installer-config.yaml 
mostafa@dell-xps:~$ cat /etc/netplan/*.yaml 
# This is the network config written by 'subiquity' 
network: ethernets:
  enp0s3:
    dhcp4: true 
  version: 2 
 
mostafaedell-xps:~$ sudo lshw -C network 
 *-network DISABLED 
     description: Ethernet interface 
     product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller 
     vendor: Realtek Semiconductor Co., Ltd. 
     physical id: 0 
     bus info: pc i®0000:03:00.0 
     logical name: enp3s0 
     version: 06 
     serial: c8:0:66:06:94:al 
     width: 64 bits 
     clock: 33MHz 
     capabilities: pm msi pciexpress msix vpd bus_master cap_list ethernet physical 
     configuration: broadcast=yes driver=r8169 latency=0 link=no multicast=yes 
     resources: irq:16 ioport:d000(size=256) memory:f0004000-f0004fff memory:f0000000-f0003fff mostafa@dell-xps:3 

我重新启动了电脑,但什么也没有改变!

有什么建议吗?

答案1

您的 .yaml 文件中的设备名称不正确。

将其用于静态地址:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      addresses: [192.168.1.17/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1]
      optional: true

或者动态地址如下:

network:
  version: 2 
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: true 
      optional: true

sudo netplan generate

sudo netplan apply

reboot

相关内容