以下过程适用于Ubuntu 18.04(Bionic Beaver)
I.重新安装ifupdown软件包:
# apt-get update
# apt-get install ifupdown
二。使用以下配置节来配置/ etc / network / interfaces文件:
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
allow-hotplug enp0s3
auto enp0s3
iface enp0s3 inet static
address 192.168.1.133
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
# Only relevant if you make use of RESOLVCONF(8)
# or similar...
dns-nameservers 1.1.1.1 1.0.0.1
三,使配置生效(无需重新启动):
# ifdown --force enp0s3 lo && ifup -a
# systemctl unmask networking
# systemctl enable networking
# systemctl restart networking
IV。禁用并删除不需要的服务:
# systemctl stop systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl disable systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl mask systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# apt-get --assume-yes purge nplan netplan.io
然后,您完成了。
注意:当然,您必须根据系统(网络,接口名称...)调整值。
五, DNS解析器
因为Ubuntu Bionic Beaver(18.04)使用了SYSTEMD-RESOLVED.SERVICE(8)提供的DNS存根解析器,所以您还应该将DNS添加到/etc/systemd/resolved.conf文件中。例如:
....
DNS=1.1.1.1 1.0.0.1
....
完成后,然后重新启动systemd解析的服务:
# systemctl restart systemd-resolved
如上所示,ifupdown INTERFACES(5)文件中的DNS条目仅在使用RESOLVCONF(8)或类似属性时才相关。