您的位置:首页 > 其它

ubuntu14.04设置静态ip

2015-09-17 16:52 337 查看
原文地址:http://www.cnblogs.com/vincedotnet/p/4013099.html

. 找到文件并作如下修改:

sudo vim /etc/network/interfaces

修改如下部分:

auto eth0
iface eth0 inet static
address 192.168.0.117
gateway 192.168.0.1 #这个地址你要确认下 网关是不是这个地址
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255

表示自己这样设置下就可以了

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.22
netmask 255.255.255.0
gateway 192.168.3.255


2. 修改dns解析

因为以前是dhcp解析,所以会自动分配dns服务器地址

而一旦设置为静态ip后就没有自动获取到的dns服务器了

要自己设置一个

sudo vim /etc/resolv.conf

写上一个公网的DNS

nameserver 202.96.128.86

(注意:8.8.8.8是谷歌的DNS服务器,但是解析速度慢,还是找到一个国内的dns来用)

3. 重启网卡:

sudo /etc/init.d/networking restart

默认配置如下

/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

/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 127.0.1.1
search localdomain
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: