在Ubuntu系統(tǒng)下工作,只掌握圖形化的配置工具還是不夠的,系統(tǒng)在出現(xiàn)故障的時候往往使用的是終端的操作模式,下面里仁3G培訓(xùn)講師介紹在終端下如何配置網(wǎng)絡(luò)。
臨時改變網(wǎng)絡(luò)參數(shù)
l .Ifconfig:查看和配置IP地址。
$ifconfig eth0
$sudo ifconfig eth0 192.168.9.23 netmask 255.255.255.0
route:配置路由參數(shù)
$sudo route add default gw 192.168.9.1 eth0 #設(shè)置默認(rèn)網(wǎng)關(guān)
使參數(shù)立即生效
$sudo/etc/init.d/networking restart
修改網(wǎng)絡(luò)配置文件
設(shè)置DNS服務(wù)器。
$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 #設(shè)置eth0,靜態(tài)IP
Address 192.168.8.45
Netmask 255.255.255.0
Gateway 192.168.8.1
Iface eht1inet dhcp #設(shè)置eth1為dhcp模式
l 可以通過下面的命令設(shè)置路由。
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
其中,當(dāng)網(wǎng)絡(luò)接口up時,執(zhí)行它后面的命令;當(dāng)網(wǎng)絡(luò)接口down時,執(zhí)行它后面的命令。
使用參數(shù)立即生效。
$sudo /etc/init.d/networking restart 轉(zhuǎn):www.lirenedu.org