Ubuntu设置IP
-------------伊人诚类
手动临时设置IP
sudo ifconfig eth0 up 192.168.1.10
手动设置IP一般在系统重启后就失效
静态设置IP
Ubuntu网络配置信息保存在 /etc/network/interfaces 文件中,默认内容如下:
auto eth0
iface eth0 inet dhcp
auto lo
iface lo inet loopback
设置静态ip的方法如下:
使用root用户编辑 /etc/network/interfaces
i)注释掉第二行,设置静态ip有关参数
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
auto lo
iface lo inet loopback
ii)编辑 /etc/resolv.conf,设置dns
nameserver 202.96.134.86
nameserver 202.106.0.166
iii)关闭后重启,使新设置生效
$sudo ifconfig eth0 down
$sudo ifconfig eth0 up
iiii)关闭后重启,使新设置生效的另一种方法
可以用/etc/init.d/networking restart
要是上面行不通的话,就用
#ifdown eth0
#ifup eth0
这样应该没问题了。
评论