使用网线连接路由器无法上网
背景
在Ubuntu20.04版本中,没有/etc/network/interfaces文件,而是使用/etc/netplan/01-network-manager-all.yaml文件配置网络
Ubuntu20.04版本 /etc/network/ 内容:
Ubuntu20.04版本 /etc/netplan 内容:
Ubuntu20.04的配置网络不是修改interfaces文件,而是需要修改01-network-manager-all.yaml
解决步骤
1. 查看网络信息
查看IP端口名称,当前IP地址,掩码,广播地址
root@a512-3090:/etc/netplan# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.12.44.43 netmask 255.255.255.0 broadcast 10.12.44.255
inet6 2001:db0:1:0:3b66:f68:4f11:61ae prefixlen 64 scopeid 0x0<global>
inet6 2001:db0:1:0:467e:8a9a:8902:d616 prefixlen 64 scopeid 0x0<global>
inet6 fe80::3be6:4b7c:90d:d941 prefixlen 64 scopeid 0x20<link>
ether b0:7b:25:23:6d:c7 txqueuelen 1000 (以太网)
RX packets 181409378 bytes 171321373017 (171.3 GB)
RX errors 0 dropped 1267806 overruns 0 frame 0
TX packets 67493620 bytes 12569160408 (12.5 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0x92f00000-92f20000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (本地环回)
RX packets 1385115 bytes 1910726160 (1.9 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1385115 bytes 1910726160 (1.9 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2. 编写文件
sudo gedit 01-network-manager-all.yaml
- 打开网卡DHCP
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
eno1:
dhcp4:yes
保存并退出
3. 使用netplan使配置生效
sudo netplan apply
备注:
有图形界面可以操作的,可以通过类似windows的网络配置 去修改 也可以。