設定IP
$sudo gedit /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.111
netmask 255.255.255.0
gateway 192.168.0.1
保存,並關閉gedit。
這樣,IP並沒有立即生效。需要執行
$sudo /etc/init.d/networking restart
這時候就能ping到局域網中的電腦了。但是上不了Internet,是因爲沒有設置DNS的原因。DNS信息保存在/etc/resolv.conf中,一旦更改,立即生效。
$sudo gedit /etc/resolv.conf
nameserver 192.168.2.43
nameserver 192.168.2.6
保存並關閉,現在就可以上網了。
附網卡設置相關命令:
查看網卡信息: 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