ubuntu12.04下 配置静态IP
2012-11-29 09:45
204 查看
世界变化太快。
1、配置静态IP地址:
# vim /etc/network/interfaces
原内容有如下4行:
auto eth0
iface eth0 inet dhcp
以上表示默认使用DHCP分配IP,修改为如下:
# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.105
netmask 255.255.255.0
gateway 192.168.1.2
保存退出。
注意:只需要设置address(IP地址)、netmask(子网掩码)、gateway(网关)这三项就OK,network和broadcast这两项参数是可以不写的。
2、手动设置DNS服务器:
# vim /etc/resolv.conf
添加如下内容(这点所有Linux发行版都通用):
nameserver 192.168.80.2
nameserver 8.8.8.8
保存退出。
注意:重启Ubuntu后发现又不能上网了,问题出在/etc/resolv.conf。重启后,此文件配置的dns又被自动修改为默认值。所以需要永久性修改DNS。方法如下:
# vim /etc/resolvconf/resolv.conf.d/base
nameserver 192.168.80.2
nameserver 8.8.8.8
3、使其生效:
# /etc/init.d/networking restart
如果这步不起作用的话,那么 reboot 系统吧;
#reboot
启动后,你会发现/etc/resolv.conf文件里自动追加了/etc/resolvconf/resolv.conf.d/base文件的内容
1、配置静态IP地址:
# vim /etc/network/interfaces
原内容有如下4行:
auto lo iface lo inet loopback
auto eth0
iface eth0 inet dhcp
以上表示默认使用DHCP分配IP,修改为如下:
auto lo iface lo inet loopback
# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.105
netmask 255.255.255.0
gateway 192.168.1.2
保存退出。
注意:只需要设置address(IP地址)、netmask(子网掩码)、gateway(网关)这三项就OK,network和broadcast这两项参数是可以不写的。
2、手动设置DNS服务器:
# vim /etc/resolv.conf
添加如下内容(这点所有Linux发行版都通用):
nameserver 192.168.80.2
nameserver 8.8.8.8
保存退出。
注意:重启Ubuntu后发现又不能上网了,问题出在/etc/resolv.conf。重启后,此文件配置的dns又被自动修改为默认值。所以需要永久性修改DNS。方法如下:
# vim /etc/resolvconf/resolv.conf.d/base
nameserver 192.168.80.2
nameserver 8.8.8.8
3、使其生效:
# /etc/init.d/networking restart
如果这步不起作用的话,那么 reboot 系统吧;
#reboot
启动后,你会发现/etc/resolv.conf文件里自动追加了/etc/resolvconf/resolv.conf.d/base文件的内容
相关文章推荐
- ubuntu12.04配置静态IP及设置DNS的方法
- ubuntu12.04配置静态IP及设置DNS
- ubuntu12.04配置静态IP及设置DNS
- ubuntu12.04配置静态IP及设置DNS
- ubuntu12.04配置静态ip
- ubuntu12.04配置静态IP及设置DNS
- 详解centos7 下双网卡如何配置静态IP
- Ubuntu配置静态IP
- Linux配置JDK的问题,Centos7设置静态IP后ping不通的问题
- Hadoop学习笔记_linux网络配置及静态ip设置
- 虚拟机ubuntu 14 配置静态ip及配置后无法链接外网问题
- 【转】Ubuntu Server 12.04 静态IP简洁配置
- Centos7.2配置静态IP
- solaris 10静态IP、静态路由和DNS解析配置
- centos 配置 静态IP方法
- 虚拟机CentOS 7通过桥接配置静态ip
- linux(centos 7版) 配置静态ip
- Ubuntu Server 12.04(14.04)配置静态IP的方法
- 虚拟机 静态ip 上网配置
- Ubuntu Server 12.04 静态IP简洁配置