ubuntu 20.04无法连接网络,网线灯不亮,network-manager也启动不了

背景

系统编程只读的了,进入到initramfs模式,执行了下边语句,发现不小心把windows也给执行了,报错很多乱码,强制退出

执行

复制代码
fsck -y /dev/sdb4
fsck -t ext4 /dev/sdb5  -y ## windows

时强制退出了导致很多文件损坏,虽然能正常开机了

但是terminal打不开,NetworkManager启动不了,网卡也掉了,折腾了好久才解决重新连上网

解决办法

看系统日志报错,网线灯也不亮

复制代码
bus-manager: fatal failure to acquire D-Bus service "org.freedesktop.NetworkManager: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Connection ":1.293" is not allowed to own the service "org.freedesktop.NetworkManager" due to security policies in the configuration fil
挂载网卡
  1. 找个可以打开的控制台工具打开,我用vscode打开控制台
    执行语句挂在网卡,网卡灯就亮了,我的网卡名字叫eno1,有些网卡叫eth0什么的多试试就行

    ifconfig eno1 up

启动network-manager
  1. 启动网卡还是失败,报上边的错误

    sudo service network-manager start

创建一个文件叫org.freedesktop.NetworkManager.conf,拷贝到

复制代码
sudo cp org.freedesktop.NetworkManager.conf /etc/dbus-1/system.d/

内容如下:

复制代码
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <!-- Only root can own the service -->
  <policy user="root">
    <allow own="org.freedesktop.NetworkManager"/>
  </policy>

  <policy context="default">
    <allow send_destination="org.freedesktop.NetworkManager"/>
    <allow send_destination="org.freedesktop.NetworkManager"
           send_interface="org.freedesktop.DBus.Properties"/>
    <allow send_destination="org.freedesktop.NetworkManager"
           send_interface="org.freedesktop.DBus.Introspectable"/>
    <allow send_destination="org.freedesktop.NetworkManager.User"
           send_interface="org.freedesktop.DBus.Properties"/>
    <allow send_destination="org.freedesktop.NetworkManager.User"
           send_interface="org.freedesktop.DBus.Introspectable"/>
  </policy>

</busconfig>

再次启动network-manager,启动成功

复制代码
sudo service network-manager start

查看窗台

复制代码
sudo service network-manager status
获取ipv4地址
  1. 启动成功但是还是无法获取ipv4地址

需要创建一个/etc/network/interfaces文件,内容如下: 网卡改成你自己的

复制代码
 auto lo
 iface lo inet loopback
 auto eno1
 iface eno1 inet dhcp
 auto eno1
 iface eno1 inet dhcp

执行

复制代码
sudo dhclient

就有ipv4地址了,可以正常连接

相关推荐
orion571 天前
Missing Semester Class1:course overview and introduction of shell
linux
用户120487221612 天前
Linux驱动编译与加载
linux·嵌入式
用户805533698032 天前
Input 子系统架构:Core、Handler、Driver 三层是怎么协作的
linux·嵌入式
用户805533698032 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
七歌杜金房2 天前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia3 天前
linux curl命令详解_curl详解
linux
扛枪的书生4 天前
Linux 网络管理器用法速查
linux
顺风尿一寸4 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode4 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫4 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux