当前位置:   article > 正文

笔记:ubuntu22.04重启后无法启动网络_ubuntu 2022 开机 net-manager失败

ubuntu 2022 开机 net-manager失败

安装ubuntu-22.04-live-server-amd64.iso后,这是一个默认没有界面的ubuntu系统,配置好静态IP后,安装了新内核。

附安装新内核过程中需要的一些库:

先apt-cache search 5.15.0-76 内核相关的包。

apt-get download libssl1.1

apt-get download crda

 apt-get download wireless-crda 

apt-get download iw

apt-get download linux-image-5.15.0-76-generic  linux-headers-5.15.0-76-generic  linux-modules-5.15.0-76-generic  linux-modules-extra-5.15.0-76-generic 

以上是从另一台ubuntu20上下载的,因为当前这个ubuntu server22.04的source源中搜索不到其他内核包。如果改变source,可能导致开发库所依赖的动态库版本不匹配。

需要ubuntu图形界面安装:apt install ubuntu-desktop

如果要开启root登录:

vim打开以下的/etc/pam.d/gdm-autologin及gdb-password中分别注释大约第3行,或者使用以下命令进行注释。

  1. sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-autologin
  2. sudo sed -i "s/.*root quiet_success$/#&/" /etc/pam.d/gdm-password

现在重点问题来了,在安装新内核重启后,没有网络,且重启过程中卡在“A start job is running for wait for network to be Configured”很久,登录界面后,右上角以及setting中的network设置中,都看不到网络设置,只有proxy等无关的东西。  ip a命令查询网卡存在,但是ifup ens33尝试启动不了,也没有报错。

解决方法:

   先查看系统上有哪些网络服务:

sudo systemctl status systemd-networkd
sudo systemctl status NetworkManager
sudo service networking status
sudo service network-manager status
 

我的节点内容如下所示:

  1. root@love:~# systemctl status systemd-networkd
  2. ● systemd-networkd.service - Network Configuration
  3. Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
  4. Active: active (running) since Mon 2024-01-08 11:51:18 UTC; 1h 20min ago
  5. TriggeredBy: ● systemd-networkd.socket
  6. Docs: man:systemd-networkd.service(8)
  7. Main PID: 6913 (systemd-network)
  8. Status: "Processing requests..."
  9. Tasks: 1 (limit: 4516)
  10. Memory: 1.5M
  11. CPU: 174ms
  12. CGroup: /system.slice/systemd-networkd.service
  13. └─6913 /lib/systemd/systemd-networkd
  14. Jan 08 11:51:18 love systemd[1]: Starting Network Configuration...
  15. Jan 08 11:51:18 love systemd-networkd[6913]: ens33: Link UP
  16. Jan 08 11:51:18 love systemd-networkd[6913]: ens33: Gained carrier
  17. Jan 08 11:51:18 love systemd-networkd[6913]: lo: Link UP
  18. Jan 08 11:51:18 love systemd-networkd[6913]: lo: Gained carrier
  19. Jan 08 11:51:18 love systemd-networkd[6913]: ens33: Gained IPv6LL
  20. Jan 08 11:51:18 love systemd-networkd[6913]: Enumeration completed
  21. Jan 08 11:51:18 love systemd[1]: Started Network Configuration.
  22. root@love:~# systemctl status NetworkManager
  23. ● NetworkManager.service - Network Manager
  24. Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
  25. Active: active (running) since Mon 2024-01-08 13:07:53 UTC; 4min 13s ago
  26. Docs: man:NetworkManager(8)
  27. Main PID: 59083 (NetworkManager)
  28. Tasks: 3 (limit: 4516)
  29. Memory: 2.8M
  30. CPU: 98ms
  31. CGroup: /system.slice/NetworkManager.service
  32. └─59083 /usr/sbin/NetworkManager --no-daemon
  33. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6713] ifupdown: interface-parser: sou>
  34. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6714] ifupdown: interfaces file /etc/networ>
  35. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6714] ifupdown: interface-parser: fin>
  36. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6737] dhcp-init: Using DHCP client 'interna>
  37. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6737] device (lo): carrier: link connected
  38. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6762] manager: (lo): new Generic device (/o>
  39. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6861] device (ens33): carrier: link connect>
  40. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6868] manager: (ens33): new Ethernet device>
  41. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6876] failed to open /run/network/ifstate
  42. Jan 08 13:07:53 love NetworkManager[59083]: <info> [1704719273.6940] manager: startup complete
  43. root@love:~# service networking status
  44. ○ networking.service
  45. Loaded: masked (Reason: Unit networking.service is masked.)
  46. Active: inactive (dead)
  47. Jan 08 12:32:41 love systemd[1]: /lib/systemd/system/networking.service:12: Unknown key name 'ExecRestart' >
  48. Jan 08 12:32:41 love systemd[1]: /lib/systemd/system/networking.service:12: Unknown key name 'ExecRestart' >
  49. root@love:~# service network-manager status
  50. Unit network-manager.service could not be found.

可以看到,systemd-networkd和NetworkManager同时存在,这时候禁用掉systemd-networkd服务即可。

sudo systemctl stop systemd-networkd
sudo systemctl disable systemd-networkd

  1. root@love:~# systemctl stop systemd-networkd
  2. Warning: Stopping systemd-networkd.service, but it can still be activated by:
  3. systemd-networkd.socket
  4. gpt解释:
  5. 这个警告提示 systemd-networkd 服务停止后,仍然可以通过 systemd-networkd.socket 激活。systemd-networkd.socket 是 systemd-networkd 服务的 socket 单元,负责根据需要启动 systemd-networkd 服务。

想着也用不到的,想尝试卸载上面的服务,先看看它属于哪个安装包:

  1. root@love:~# systemctl show -p FragmentPath systemd-networkd
  2. FragmentPath=/lib/systemd/system/systemd-networkd.service
  3. root@love:~# dpkg -S /lib/systemd/system/systemd-networkd.service
  4. systemd: /lib/systemd/system/systemd-networkd.service

可以看到这个服务属于systemd包里的,那就不敢卸载了,留着吧。

做完这些操作,systemctl restart NetworkManager应该可以启动网络,因为我是在重启之前就做了上面这些操作,所以如果不行你就再重启一次。

附命令行配置IP:

先查看接口名称,如我的机器网卡名称为ens38 :

  ip a

1. 配置网卡     (10.1.*.*为IP,16为掩码, 10.1.0.1为网关,10.1.0.6为DNS)


nmcli con mod ens38 ipv4.addresses 10.1.*.*/16 ipv4.gateway 10.1.0.1 ipv4.dns 10.1.0.6 ipv4.method manual


nmcli con up ens38

其他机器如suse15可以执行:

nmtui

会弹出仿真界面进行配置静态IP。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/75552
推荐阅读
相关标签
  

闽ICP备14008679号