ubuntu 網路配置

2021-08-26 03:57:35 字數 1590 閱讀 8275

檢查網路配置命令:ifconfig -a

1、通過配置檔案配置

環境:vpc2007sp1 、ubuntu9.04

ubuntu上連了兩塊網絡卡,eth0為外網的eth1為內網的

eth0上ip為自動獲取

eth1上為手工設定

配置過程:

1、開啟ubuntu的/etc/network/inte***ces檔案 。預設內容如下:

auto lo

iface lo inet loopback

2、eth0為自動獲取ip,所以不需要配置了。插入要手工設定ip的eth1的ip資訊,編輯後內容如下,前面auto eth1,讓網絡卡開機自動掛載.:

auto lo

iface lo inet loopback

auto eth1

iface eth1 inet static

address 192.168.0.101

netmask 255.255.255.0

network 192.168.0.0

broadcask 192.168.0.255

gateway 192.168.0.2

3、編寫完畢儲存,然後開啟終端執行如下命令,重新啟動網絡卡即可:

$/etc/init.d/networking restart

也可以重啟網絡卡讓新配置生效,優點是不影響其他網路介面:

$ sudo ifdown eth0

$ sudo ifup eth0

4、如果以dhcp方式配置網絡卡,則改為:

auto eth0

iface eth0 inet dhcp

也可以在命令列下直接輸入下面的命令來獲取位址

sudo dhclient eth0

5、配置dns伺服器的位址,最多可以使用3個dns伺服器

$ sudo vi /etc/resolv.conf

nameserver 202.96.134.133

nameserver 202.96.128.68

nameserver 202.96.128.166

對"resolv.conf"的修改是即時生效的。可以使用nslookup命令進行dns伺服器查詢,以驗證"resolv.conf"配置檔案。

二、使用命令設定ubuntu的ip位址

1. 檢驗是否可以連通,就使用ping命令ping 閘道器

開始的時候總是現實unreachable

2. 設定ip

sudo ifconfig eth0 192.168.0.190 netmask 255.255.255.0

這樣就算設定好了網絡卡eth0的ip位址和子網掩碼

3. 設定閘道器 sudo route add default gw 192.168.0.1

4. ping 閘道器就可以ping通了

5. 設定dns 修改/etc/resolv.conf,在其中加入

nameserver dns的位址1

nameserver dns的位址2

完成。

這樣設定之後,下次開機時配置會丟失。

ubuntu 網路配置

進入網路配置檔案 sudo vi etc network inte ces 在這裡你應該會看到如下內容 auth lo iface lo inet loopback 這個正是 lo回環,我需要讓這台執行 ubuntu server 的機子通過 dhcp 獲得ip 來加入網路,那麼我只需要在上面的 l...

Ubuntu 網路配置

1 sudo vi etc network inte ces 更改配置為 autoeth0 ifaceeth0 inet static address 192.168.3.90 gateway 192.168.3.1 netmask 255.255.255.0 sudo etc init.d net...

ubuntu 網路配置

檢查網路配置命令 ifconfig 4 如果以dhcp方式配置網絡卡,則改為 auto eth0 iface eth0 inet dhcp 也可以在命令列下直接輸入下面的命令來獲取位址 sudo dhclient eth0 5 配置dns伺服器的位址,最多可以使用3個dns伺服器 sudo vi e...