Ubuntu16.04设置静态IP或动态ip(DHCP)

Ubuntu16.04设置静态IP或动态ip(DHCP)

设置静态IP

1,vim编辑/etc/network/interfaces 网络配置文件

sudo vim /etc/network/interfaces

2,码添加以下代码

auto ens33
iface ens33 inet static
address 192.168.1.244 #ip地址
netmask 255.255.255.0 #子网掩码
gateway 192.168.1.1 #网关
dns-nameserver 114.114.114.114 #dns服务器

:wq保存退出

3,重启网络:sudo /etc/init.d/networking restart,然后重启系统:reboot

DHCP动态获取IP

1,vim编辑/etc/network/interfaces 网络配置文件

sudo vim /etc/network/interfaces

原文地址:https://www.cnblogs.com/111testing/p/13137624.html