ubuntu 18.04 修复自动连接有线网络设置

如果你像我一样,之前不小心卸载了不该卸载的软件。导致不能开机自动联网:

1,先尝试用 这个链接的方法先手动连上网络,以便安装软件

2,查看是否安装了netplan.io 包 (注意不是netplan)

$ dpkg -s netplan.io

结果有三种可能:

2.1,没有安装过

dpkg-query: package 'notexists' is not installed and no information is available
...

2.2,安装过,已经卸载,并还保留着配置文件 

...
Status: deinstall ok config-files
...

2.3,已经安装了 

...
Status: install ok installed
...

3,安装上述软件

sudo apt install netplan.io

4,配置有线网络

4.1 查看有线网卡名称:enp5s0。 lo使localhost,wlx开头的是无线网卡

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> ...
...
2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
...
3: wlx40xxx: <BROADCAST,MULTICAST> ...
...

4.2 修改配置文件: 

sudo gedit /etc/netplan/01-network-manager-all.yam

改成以下内容:自动获取ip。

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp5s0:
      dhcp4: yes

4.3,使配置生效

$ sudo netplan try # 没有出现报错则根据提示回车
$ sudo netplan apply # 最后应用
$ $ sudo systemctl restart network-manager # 重启网络服务

5,最后可以重启查看开机是否能自动连上有线网络

$ sudo shutdown -r now

感谢:https://vitux.com/how-to-configure-networking-with-netplan-on-ubuntu/

https://ubuntuforums.org/showthread.php?t=2400673

https://www.fernandoike.com/2014/09/12/purge-debian-packages-marked-with-rc-status/

https://www.jianshu.com/p/8bc5f1f660ee

https://blog.csdn.net/vebasan/article/details/5515235

发布了189 篇原创文章 · 获赞 72 · 访问量 27万+

猜你喜欢

转载自blog.csdn.net/qxqxqzzz/article/details/105169677