共計 1536 個字符,預(yù)計需要花費(fèi) 4 分鐘才能閱讀完成。
這篇文章主要介紹了 Ubuntu 網(wǎng)絡(luò)怎么配置的相關(guān)知識,內(nèi)容詳細(xì)易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇 Ubuntu 網(wǎng)絡(luò)怎么配置文章都會有所收獲,下面我們一起來看看吧。
一、配置大概分三類:通過配置文件配置、通過命令配置、通過圖形化的網(wǎng)絡(luò)連接菜單配置。
主要文件:/etc/network/interfaces,這里是 ip、網(wǎng)關(guān)、掩碼等的一些配置;/etc/resolv.conf 這個文件保存 dns 的有關(guān)信息
主要命令:sudo /etc/init.d/networking restart 重啟網(wǎng)絡(luò),使配置文件的配置失效;sudo route add default gw ip 地址 , 設(shè)置網(wǎng)關(guān)。
二、配置方法
1、通過命令配置
如果你只是想暫時性的修改 ip 地址,可以選擇這種方法。重啟網(wǎng)絡(luò)后會丟失。
1)sudo ifconfig eth0 ip 地址 netmask 子網(wǎng)掩碼 up
eth0 是網(wǎng)卡。最后的 up 表示開啟網(wǎng)卡,可以不加。
2)sudo route add default gw 網(wǎng)關(guān) ip
設(shè)置網(wǎng)關(guān)
3)設(shè)置 dns,這個必須去配置文件修改,同第二種
4)配置主機(jī)名稱
命令:sudo /bin/hostname 主機(jī)名
但是系統(tǒng)啟動時, 會從 /etc/hostname 來讀取主機(jī)的名稱。
2、通過配置文件配置
1)配置 ip 網(wǎng)關(guān):sudo gedit /etc/network/interfaces 里面添加
dhcp 的:
復(fù)制代碼 代碼如下:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
靜態(tài) ip 的:
復(fù)制代碼 代碼如下:
auto lo
iface lo inet loopback
# 上面的是回環(huán)
# 網(wǎng)卡 eth0 的配置
auto eth0
#staic 靜態(tài) ip
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.1
#network 192.168.3.0
#broadcast 192.168.3.255
# 后面兩條是網(wǎng)絡(luò)號和廣播號,這個可以由其它信息計算,因此無需設(shè)置
這里還可以配置第二 ip(虛擬 ip)
復(fù)制代碼 代碼如下:
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
#network x.x.x.x
#broadcast x.x.x.x
gateway x.x.x.x
2)配置 dns:sudo gedit /etc/resolv.conf
復(fù)制代碼 代碼如下:
nameserver 202.107.117.11
3)主機(jī)名:sudo gedit /etc/hostname 里面輸入主機(jī)名。默認(rèn)有個主機(jī)名,因此這個不是必須的。
4)重啟網(wǎng)絡(luò):sudo /etc/init.d/networking restart
也可以重啟網(wǎng)卡:
sudo ifconfig eth0 down
sudo ifconfig eth0 up
重啟網(wǎng)卡對別的網(wǎng)卡無影響,更推薦一些。
3、通過圖形化的網(wǎng)絡(luò)連接菜單配置
這個在系統(tǒng) - 首選項里,也叫做 network manager,通過右上角面板里的網(wǎng)絡(luò)管理小程序可以啟用它的配置。
這個有點(diǎn)問題:它和第二種方法共用配置文件,所以會導(dǎo)致種種沖突,使用時要注意。
不如,這兩種方法都做了配置,sudo /etc/init.d/networking restart 啟用的是第二種方法的配置,而點(diǎn)擊桌面面板上的網(wǎng)絡(luò)管理小程序中的 auto eth0 啟用的是第三種的配置。
關(guān)于“Ubuntu 網(wǎng)絡(luò)怎么配置”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“Ubuntu 網(wǎng)絡(luò)怎么配置”知識都有一定的了解,大家如果還想學(xué)習(xí)更多知識,歡迎關(guān)注丸趣 TV 行業(yè)資訊頻道。