读书人

(转)Ubuntu设立静态IP的方法

发布时间: 2012-06-26 10:04:13 作者: rapoo

(转)Ubuntu设置静态IP的方法

http://www.cnblogs.com/shengshuai/archive/2009/02/27/1399905.html

?

1。设定IP
sudo gedit? /etc/network/interfaces

auto lo
iface lo inet loopback??????????? #lo 是本地回环地址:127.1

auto eth0?
iface eth0 inet static?
address 192.168.1.152?
gateway 192.168.1.1?
netmask 255.255.255.0?
network 192.168.1.0?
broadcast 192.168.1.255????? #设定eth0的IP

这样,IP并没有立即生效。
sudo /etc/init.d/networking restart

2。这时候就能ping到局域网中的电脑了。但是上不了Internet,是因为没有设置DNS的原因。DNS信息保存在/etc/resolv.conf中,一旦更改,立即生效。

sudo gedit /etc/resolv.conf

nameserver 208.67.222.222?
nameserver 208.67.220.220

现在可以上网了。

附网卡设置相关命令:

查看网卡信息: ifconfig

设定一个网卡IP:ifconfig eth1 192.168.1.10 netmask 255.255.255.0??

重启网卡使设定生效:sudo /etc/init.d/networking restart

更改MAC地址:ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

查看路由相关信息:route -n

读书人网 >操作系统

热点推荐