定义固定以太网 IP 地址后无法访问互联网

定义固定以太网 IP 地址后无法访问互联网

我为某个项目为我的以太网连接分配了一个固定 IP 地址。从那时起,我的 Wifi 就变得非常慢,有时我甚至无法访问网页。由于我不是这方面的专家,所以我可能改错了什么,但我不知道是什么。我有以下设置ubuntu@master:~$ ifconfig::

wlp65s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.160  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2001:171b:2269:80:31b7:25ec:c36e:6823  prefixlen 128  scopeid 0x0<global>
        inet6 fdaa:bbcc:ddee:0:1da1:a7e1:5729:1050  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::d6c7:1b3d:1e0b:5c2e  prefixlen 64  scopeid 0x20<link>
        inet6 fdaa:bbcc:ddee:0:c847:d06f:b111:5c5  prefixlen 64  scopeid 0x0<global>
        inet6 2001:171b:2269:80:1da1:a7e1:5729:1050  prefixlen 64  scopeid 0x0<global>
        inet6 2001:171b:2269:80:7863:65c7:2f72:50e5  prefixlen 64  scopeid 0x0<global>
        ether 84:1b:77:a6:de:16  txqueuelen 1000  (Ethernet)
        RX packets 246113  bytes 216699304 (216.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 134602  bytes 32519445 (32.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp4s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.1.1  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::b62e:99ff:fe31:55a0  prefixlen 64  scopeid 0x20<link>
        ether b4:2e:99:31:55:a0  txqueuelen 1000  (Ethernet)
        RX packets 419407  bytes 369641096 (369.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1018506  bytes 1287911312 (1.2 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xd9500000-d951ffff 

wlp65s0我的 WLAN 互联网连接在哪里?在我进行一些更改之前,它工作正常。我的以太网连接在哪里enp4s0?我也有sudo nano /etc/network/interfaces

auto lo
iface lo inet loopback

#this has been added:
    allow-hotplug enp4s0
    iface enp4s0 inet static
    address 192.168.1.1
    netmask 255.255.255.0
    network 192.168.1.1
    broadcast 192.168.1.255

然后:sudo nano /etc/netplan/01-network-manager-all.yaml

network:
  version: 2
  renderer: networkd #before, this was NetworkManager
  ethernets:
    enp4s0:
      addresses: [192.168.1.1/24]
      gateway4: 192.168.1.1
      nameservers:
          search: [255.255.255.0]
          addresses: [1.1.1.1, 1.0.0.1, 192.168.1.1]

ls -al /etc/netplan

total 20
drwxr-xr-x   2 root root  4096 Apr 28 18:14 .
drwxr-xr-x 146 root root 12288 Apr 28 18:16 ..
-rw-r--r--   1 root root   506 Apr 28 17:53 01-network-manager-all.yaml

dkms 状态

nvidia, 460.73.01, 5.4.0-72-generic, x86_64: installed

您能否指出您发现的不一致之处?如果有任何遗漏或不清楚的地方,请告诉我。任何提示或帮助都将不胜感激。我有 Wifi 卡 Aorus GC-WBAX200,正在 Ubuntu 18.04 桌面上运行。提前非常感谢

答案1

对于 Ubuntu 桌面...

您的 /etc/network/interfaces 应该是:

auto lo
iface lo inet loopback

您的 /etc/netplan/01-cloud-init.yaml 应该是:

network:
  version: 2
  renderer: NetworkManager

sudo netplan generate

sudo netplan apply

reboot

然后使用 NetworkManager GUI 设置静态地址(如果需要):

注意:静态地址不能是您的路由器的地址(192.168.1.1)。

在此处输入图片描述

相关内容