Ubuntu 18.04 IP 设置

配置文件

vi /etc/network/interfaces

自动IP

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ens33
iface ens33 inet dhcp

静态IP

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto ens33
iface ens33 inet static
address 192.168.1.66
netmask 255.255.255.0
gateway 192.168.1.1

注意:静态IP需要设置DNS否则不能联网。

填写配置文件/etc/systemd/resolved.conf中的DNS值。

# See resolved.conf(5) for details

[Resolve]
#DNS=
DNS=8.8.8.8 223.5.5.5
#FallbackDNS=
#Domains=

重启网络

/etc/init.d/networking restart ifconfig
原文地址:https://www.cnblogs.com/llil/p/14541022.html