ubuntu網路配置

2021-07-03 13:25:24 字數 878 閱讀 6672

配置ip位址,網管,子網掩碼等資訊

在 /etc/network/inte***ces檔案中配置,這樣配置出的ip就是靜態ip,每次開機不會發生變化

auto lo

iface lo inet loopback

#上面的是回環

#網絡卡eth0的配置

auto eth0

#staic 靜態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 

#後面兩條是網路號和廣播號,這個可以由其它資訊計算,因此無需設定

配置好了ip後需要配置dns才能解析網域名稱

在/etc/resolv.conf中配置,nameserver (dns伺服器ip)

但是這樣配置每次開機就會重置

要想每次開機都會有固定的dns伺服器則需要在/etc/resolvconf/resolv.conf.d/tail中配置,配置的內容和resolv.conf中相同即可

配置完成之後執行/etc/init.d/networking restart 或者重啟即可生效

如果要利用命令進行配置

配置ip和子網掩碼 

ifconfig eth0 192.168.153.129 netmask 255.255.255.0

配置閘道器

新增預設閘道器 route add default gateway 192.168.153.2

刪除預設閘道器route del default gateway 192.168.153.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...