Ubuntu 18.04 IP 设置

时间:2021-03-17 14:16:49   收藏:0   阅读:0

配置文件

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
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!