01-ubuntu14.04静态ip配置
2016-11-10 17:21
323 查看
1. 找到文件并作如下修改:
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 #广播保留,不知道
2. 修改dns解析
因为以前是dhcp解析,所以会自动分配dns服务器地址
而一旦设置为静态ip后就没有自动获取到的dns服务器了
要自己设置一个
sudo vim /etc/resolv.conf
写上一个公网的DNS
nameserver 202.96.128.86
(注意:8.8.8.8是谷歌的DNS服务器,但是解析速度慢,还是找到一个国内的dns来用,
上面这个是广东电信的dns服务器。)
问题来了:
仔细看下,这个文档里面的说明。大概意思是:机器重启时,这个文件的东西会被清空。所以不能在这里修改dns的值(要改也是可以的,另行查找)
vim /etc/resolvconf/resolv.conf.d/base
修改好保存,然后执行
resolvconf -u
sudo /etc/init.d/resolvconf restart
再去看看/etc/resolv.conf文件,可以看到自己添加的dns服务器已经加到该文件中。
到这里,dns的配置完成了。
3. 重启网卡:
sudo /etc/init.d/network restart
注意:
这条命令不管用了,使用 sudo service networking restart
stop: Job failed while stopping
start: Job is already running: networking
发现:这条命令也不管用了。
惨了,这时候只能看日志文件,看看错误:
tail -f /var/log/upstart/networking.log //查看错误日志
Stopping or restarting the networking job is not supported.
Use ifdown & ifup to reconfigure desired interface.
从以上日志内容可以看出,传统的service重启和停止网络已经不再支持了,需要通过使用ifdown & ifup来实现相应的操作。
重启指定网卡:
ifdown eth0 && ifup eth0
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 #广播保留,不知道
2. 修改dns解析
因为以前是dhcp解析,所以会自动分配dns服务器地址
而一旦设置为静态ip后就没有自动获取到的dns服务器了
要自己设置一个
sudo vim /etc/resolv.conf
写上一个公网的DNS
nameserver 202.96.128.86
(注意:8.8.8.8是谷歌的DNS服务器,但是解析速度慢,还是找到一个国内的dns来用,
上面这个是广东电信的dns服务器。)
问题来了:
仔细看下,这个文档里面的说明。大概意思是:机器重启时,这个文件的东西会被清空。所以不能在这里修改dns的值(要改也是可以的,另行查找)
vim /etc/resolvconf/resolv.conf.d/base
修改好保存,然后执行
resolvconf -u
sudo /etc/init.d/resolvconf restart
再去看看/etc/resolv.conf文件,可以看到自己添加的dns服务器已经加到该文件中。
到这里,dns的配置完成了。
3. 重启网卡:
sudo /etc/init.d/network restart
注意:
这条命令不管用了,使用 sudo service networking restart
stop: Job failed while stopping
start: Job is already running: networking
发现:这条命令也不管用了。
惨了,这时候只能看日志文件,看看错误:
tail -f /var/log/upstart/networking.log //查看错误日志
Stopping or restarting the networking job is not supported.
Use ifdown & ifup to reconfigure desired interface.
从以上日志内容可以看出,传统的service重启和停止网络已经不再支持了,需要通过使用ifdown & ifup来实现相应的操作。
重启指定网卡:
ifdown eth0 && ifup eth0
相关文章推荐
- [置顶] ubuntu14.04 图形化配置 静态IP
- Ubuntu Server 12.04(14.04) 静态IP简洁配置
- VMware下Ubuntu 14.04静态ip配置
- Ubuntu 14.04 server配置使用无线连接静态设置IP
- ubuntu14.04配置静态ip
- Ubuntu Server 12.04(14.04)配置静态IP的方法
- Ubuntu 14.04 配置静态IP
- Ubuntu Server启动eth0,并配置静态IP
- ubuntu下配置静态IP上网
- Ubuntu 上配置静态的ip
- Ubuntu Server 12.04 静态IP简洁配置
- Ubuntu命令行修改网络配置,静态ip,hostname ,解决hostname ping不通的办法
- VM8下ubuntu10.04下修改mac地址和配置静态ip
- ubuntu 静态IP的配置
- Ubuntu Server 12.04 静态IP简洁配置
- VMware Ubuntu14.10 配置静态IP
- (总结)Ubuntu Server 12.04 静态IP简洁配置
- Ubuntu下的静态IP和动态IP配置
- Ubuntu Server 12.04 静态IP简洁配置
- ubuntu 12.04配置静态ip