ubuntu server 设置静态ip

来源:岁月联盟 编辑:exp 时间:2011-11-17

修改这个网络配置文件,默认一般是自动获得ip的。

 

sudo vi /etc/network/interfaces

 

文件内容:

 

view plain

auto lo 

iface lo inet loopback 

 

mapping hotplug 

script grep 

map eth0 

 

auto eth0 

iface eth0 inet static 

address 192.168.1.101 

netmask 255.255.255.0 

network 192.168.1.0 

broadcast 192.168.1.255 

gateway 192.168.1.1 

 

如果还要上网的话,要修改dns文件:

 

sudo vi /etc/resolv.conf

文件内容:

 

view plain

nameserver 192.168.1.1              <-------------这行是新增的 

nameserver xxx.xx.xx.xxx                <-------------这行是原来的dns服务器 

 

 

重启网络模块:

 

sudo /etc/init.d/networking restart

 

 

ok,现在应该可以正常使用设定的ip地址了。

 

作者 小糊涂神