ubuntu網路設定

2021-06-27 11:04:45 字數 1686 閱讀 9120

a, ubuntu系列網路配置資訊儲存在/etc/network/inte***ces中

b, dns資訊儲存在/ect/resolv.conf中.

note:

如果只是臨時性的改變ip位址,則不用修改inte***ces檔案,只用ifconfig即可,不過當系統重啟後,系統會恢復inte***ces中的配置.

ifconfig命令各linux系統通用,但是暫時性的.

(1) 配置eth0的ip位址, 同時啟用該裝置

sudoifconfigeth0 192.168.1.10 netmask 255.255.255.0 up

(2) 新增預設閘道器

sudo route add default gw 192.168.1.1

(3) 配置dns

#sudo vi /etc/resolv.conf

nameserver 202.96.134.133

nameserver 202.96.128.68

nameserver 202.96.128.166

或者:$echo nameserver 202.106.46.151 >/etc/resolv.conf

檢視dns

$ less /etc/resolv.conf

$nm-tool

(4)其它命令

啟用裝置

ifconfig eth0 up / sudo ifup eth0

禁用裝置

ifconfig eth0 down / sudo ifdown eth0

重啟網路裝置

/etc/init.d/networking restart

service network restart(redhat)

(5)ping閘道器及外網

靜態ip配置方法:

sudo gedit /etc/network/inte***ces

auto eth0

iface eth0 inet static

address 192.168.1.103

gateway 192.168.1.1

netmask 255.255.255.0

network 192.168.1.0

broad

cast 192.168.1.255

然後重啟網路裝置

sudo /etc/init.d/networking restart

設定dns:

ubuntu設定dns,只要將dns位址寫入/ect/resolv.conf檔案即可,但在12.04 desktop版中,重啟系統之後,靜態ip設定生效,但無法鏈結外網,/etc/resole.conf檔案的dns位址也覆蓋掉了。

解決辦法,在/etc/resolvconf/resolv.conf.d/目錄下建立

tail檔案,寫入

nameserver 202.96.134.133

nameserver 202.96.128.68

然後重啟,dns生效。

ubuntu網路設定

主要檔案 etc network inte ces,這裡是ip 閘道器 掩碼等的一些配置 etc resolv.conf這個檔案儲存dns的有關資訊 主要命令 sudo etc init.d networking restart重啟網路,使配置檔案的配置生效 通過配置檔案配置 1 配置ip閘道器 s...

ubuntu 設定網路

1.以dhcp方式配置網絡卡 編輯檔案 etc network inte ces sudo vi etc network inte ces 並用下面的行來替換有關eth0的行 the primary network inte ce use dhcp to find our address auto ...

ubuntu 網路設定

1,本地 無線 vmware選擇橋接模式,配置相關ip與dns,ip與本地ip在同一網段,root ubuntu cat etc network inte ces auto eth0 iface eth0 inet static address 192.168.0.199 gateway 192.1...