Ubuntu16.04下设置静态IP

vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens160    #设置自动启动ens160接口
#iface ens160 inet dhcp  

iface ens160 inet static   #配置静态IP
address 10.1.18.200  #IP地址
netmask 255.255.255.0  #子网掩码
gateway 10.1.18.254    #默认网关
dns-nameserver 210.32.32.10

dns-nameserver 210.32.32.10 这句一定需要有,
因为以前是DHCP解析,所以会自动分配DNS 服务器地址。
而一旦设置为静态IP后就没有自动获取到DNS服务器了

设置完重启电脑

/etc/resolv.conf 文件中会自动添加

nameserver 210.32.32.10

(或者nameserver 8.8.8.8)可以根据访问速度,选择合适的公共DNS

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容