Ubuntu18.04 使用ifupdown配置网络
https://www.wabks.com/post/615.html
1,安装ifupdown、resolvconf 软件包 apt install ifupdown resolvconf 2, 修改/etc/network/interfaces文件配置网络连接 root@bks:~# cat /etc/network/interfaces # ifupdown has been replaced by netplan(5) on this system. See # /etc/netplan for current configuration. # To re-enable ifupdown on this system, you can run: # sudo apt install ifupdown auto lo iface lo inet loopback auto ens33 iface ens33 inet static address 192.168.218.89 netmask 255.255.255.0 gateway 192.168.218.2 dns-nameservers 1.1.1.1 114.114.114.114 3,重启网络接口 ifdown --force ens33 lo && ifup -a systemctl enable networking systemctl restart networking 4,停止、取消和禁止 Netplan 相关服务运行,并移除 Netplan 软件包及其配置文件 1,systemd-networkd是 Netplan 后端服务(桌面版则是NetworkManager); 2,networkd-dispatcher是 Netplan 守护服务,可通过监听连接状态以执行特定事件操作; 3,systemd-networkd-wait-online用于检测systemd-networkd所管理网络接口的连接状态; 4,systemd-resolved新的 DNS 管理服务,其配置文件里有的参数依赖 Netplan 后端服务工作; systemctl stop systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved systemctl disable systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved systemctl mask systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved apt purge nplan netplan.io 若切换回 Netplan: 将带有 mask 的命令换成 unmask 运行一次,不然即使 start disable 了也没法使用服务。 apt install nplan netplan.io systemctl unmask systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved systemctl enable systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved systemctl start systemd-networkd networkd-dispatcher systemd-networkd-wait-online systemd-resolved 拓展命令: systemctl list-dependencies systemd-networkd --reverse查询指定服务所关联的依赖项; systemctl list-unit-files --type=masked --all列出/lib/systemd/system下被禁止的服务; 5,若出现dns解析不了 如果 DNS 解析不了,请检查/etc/resolv.conf所链接的文件是否是/run/resolvconf/resolv.conf。如果不是,运行下面命令设置。 ln -sf /run/resolvconf/resolv.conf /etc/resolv.conf
posted on 2022-04-15 23:01 zhangmingda 阅读(1316) 评论(0) 编辑 收藏 举报