您的位置:首页 > 其它

Ubuntu 1404设置静态IP

2017-08-16 21:34 615 查看

编辑修改interfaces文件

sudo vim /etc/network/interfaces

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

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0

#——————shielding DHCP
#iface eth0 inet dhcp
#——————add your setting here
iface eth0 inet static
address 192.168.1.214
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255


修改DNS

resolv.conf 这个文件DHCP获取后自动改写,这里我没有修改,原来已经通过DHCP获取了一个,贸然填上8.8.8.8谷歌的,可能还会缓慢

sudo vim /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 49.223.187.120
nameserver 175.190.255.50
search DHCP HOST


重启网卡

一般使用

sudo service networking restart

或者

sudo /etc/init.d/networking restart

这两个命令都可以重启网卡,重新载入配置,但是在这个Ubuntu 1404 server版本中,没有任何反应,还是原来DHCP获取的IP,通过关闭和开启网卡可以,没有搞清楚原因

ifconfig eth0 down
ifconfig eth0 up
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ubuntu