4.设置静态IP

淺唱寂寞╮ 提交于 2019-11-29 04:42:58

由于Ubuntu重启之后,ip很容易改变,可以用以下方式固定ip地址

1.设置ip地址

vi /etc/network/interface

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.117.50
netmask 255.255.255.0
gateway 192.168.117.1

enp0s3
2.设置dns

vi /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8
nameserver 8.8.4.4

3.刷新配置文件

resolvconf -u

4.重启网络服务

/etc/init.d/networking restart

如果上述命令重启网卡失败,可以手动关闭网卡,再打开网卡,这是ip已经改过来了,变成你设置的固定的ip了

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!