新安装的 Ubuntu 无法通过以太网访问互联网

新安装的 Ubuntu 无法通过以太网访问互联网

我刚刚安装了 ubuntu 18.04,但无法通过以太网线访问互联网

以下是我尝试过的命令,用于了解问题。enp0s25 是以太网连接的名称吗?

~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.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: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 18:a9:05:f0:05:13 brd ff:ff:ff:ff:ff:ff

~$ ping -c3 www.google.com
ping: www.google.com: Temporary failure in name resolution

~$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad

我正在尝试通过查看页面来解决问题手动设置网络设置。在那里,我被要求输入:

  • IP地址
  • 网关
  • 网络掩码

输出中是否提供了这 3 条信息?如果是,它们具体是什么?我的 IP 地址是 127.0.0.1 吗?我的网关和网络掩码是什么?

编辑1

以下是以下命令的输出

~$ sudo ethtool eth0
sudo: ethtool: command not found
~$ sudo lshw -class network
  *-network                 
       description: Ethernet interface
       product: 82567LM-3 Gigabit Network Connection
       vendor: Intel Corporation
       physical id: 19
       bus info: pci@0000:00:19.0
       logical name: enp0s25
       version: 02
       serial: 18:a9:05:f0:05:13
       size: 1Gbit/s
       capacity: 1Gbit/s
       width: 32 bits
       clock: 33MHz
       capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k duplex=full firmware=0.4-3 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
       resources: irq:31 memory:f0000000-f001ffff memory:f0025000-f0025fff ioport:2100(size=32)

编辑2


$ cat /etc/netplan/00-installer-config.yaml
cat: /etc/netplan/00-installer-config.yaml: No such file or directory
$ ls /etc/netplan/
01-network-manager-all.yaml
$ cat /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

答案1

看起来您有一个链接(enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP>),因此假设您的网络上配置了 dhcp 服务器,您可以尝试手动请求一个 ip 地址:

sudo dhclient enp0s25

你现在有取得IP吗?

ip a

如果这没有帮助,则可能是您的链接速度和双工协商出了问题。输出是什么:

sudo ethtool eth0

你是什​​么型号的网卡?

sudo lshw -class network

答案2

您可以尝试以下步骤:

首先创建原始配置文件的备份。

sudo cp /etc/netplan/01-network-manager-all.yaml{,.bak}

然后修改文件。如果有 DHCP 服务器自动为连接到网络的设备分配 IP 地址和其他通信参数(大多数情况下,家用路由器默认这样做),请将配置更改为:

network:
  ethernets:
    enp0s25:
      dhcp4: true
  version: 2
  renderer: networkd

注意 Netplain 支持 Netplan 同时支持 networkd 和 NetworkManager 作为后端。在这种情况下,我们选择networkd。如果没有可用的 DHCP 服务器,或者您想分配静态 IP 地址,请将配置更改为:

network:
  ethernets:
    enp0s25:
      addresses: [192.168.1.101/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1, 8.8.8.8, 8.8.4.4]
  version: 2
  renderer: networkd

在哪里:

  • 192.168.1.101将是设备的 IP 地址,它取决于您的 LAN 配置。
  • 192.168.1.1是您的路由器的 IP 地址,它也取决于您的 LAN 配置。
  • 8.8.8.88.8.4.4是 Google 的名称服务器,这里我们使用它们作为备份。

最后重启networkd.service生效:

sudo systemctl restart systemd-networkd.service

然后检查它的状态:

sudo systemctl status systemd-networkd.service

参考:

相关内容