Ubuntu 1404设置静态IP

来源:互联网 发布:linux jdk 降级 编辑:程序博客网 时间:2024/06/15 18:26

编辑修改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 interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0#——————shielding DHCP#iface eth0 inet dhcp#——————add your setting hereiface eth0 inet staticaddress 192.168.1.214gateway 192.168.1.1netmask 255.255.255.0network 192.168.1.0broadcast 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 OVERWRITTENnameserver 49.223.187.120nameserver 175.190.255.50search DHCP HOST

重启网卡

一般使用

sudo service networking restart

或者

sudo /etc/init.d/networking restart

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

ifconfig eth0 downifconfig eth0 up
原创粉丝点击