手动临时设置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 *.*.*.*(合适的ip地址)
netmask 255.255.255.0
gateway *.*.*.*(合适的网关)
auto lo
iface lo inet loopback
ii)编辑 /etc/resolv.conf,设置dns
nameserver *.*.*.*(合适的dns)
iii)关闭后重启,使新设置生效
$sudo ifconfig eth0 down
$sudo ifconfig eth0 up
另外,重启网络的命令是 sudo /etc/init.d/networking restart (对ubuntu而言)
另外,重启网络的命令是 sudo /etc/init.d/networking restart (对ubuntu而言)
以上方法都是属于命令行的方式,当然还有更简单的方法,就是直接在界面设置(和windows一样简单),前提能够找到设置的地方,具体方法找google或者baidu。