在Ubuntu系統下工作,只掌握圖形化的配置工具還是不夠的,系統在出現故障的時候往往使用的是終端的操作模式,下面里仁3G培訓講師介紹在終端下如何配置網絡。
臨時改變網絡參數
l .Ifconfig:查看和配置IP地址。
$ifconfig eth0
$sudo ifconfig eth0 192.168.9.23 netmask 255.255.255.0
route:配置路由參數
$sudo route add default gw 192.168.9.1 eth0 #設置默認網關
使參數立即生效
$sudo/etc/init.d/networking restart
修改網絡配置文件
設置DNS服務器。
$sudo echo‘nameserver=219.150.32.132>/etc/resolv.conf’
編輯/etc/network/interfaces。
$sudo vim /etc/network/interfaces
Auto lo
Iface lo inet loopback
Iface eth0 inet static #設置eth0,靜態IP
Address 192.168.8.45
Netmask 255.255.255.0
Gateway 192.168.8.1
Iface eht1inet dhcp #設置eth1為dhcp模式
l 可以通過下面的命令設置路由。
Up route add default gw 192.168.8.1 eth1
Up route add –net 192.168.8.0/24 gw 192.168.8.1 eth0
Down route del –net 192.168.8.0/24 gw 192.168.8.1 eth0
其中,當網絡接口up時,執行它后面的命令;當網絡接口down時,執行它后面的命令。
使用參數立即生效。
$sudo /etc/init.d/networking restart 轉:www.lirenedu.org