Ubuntu Server下的網路設定

來源:互聯網
上載者:User


Ubuntu Server下的網路設定 檢查網路設定  www.2cto.com  $ ifconfig配置DHCP用戶端$ sudo vi /etc/network/interfaces加入 iface eth0 inet dhcp配置靜態IP地址$ sudo vi /etc/network/interfaceseth0配置如下:  www.2cto.com  auto eth0address 192.168.0.88netmask 255.255.255.0gateway 192.168.0.1讓新配置生效儲存退出後,使用重啟networking命令讓新配置生效:$ sudo /etc/init.d/networking restart也可以重啟網卡讓新配置生效,優點是不影響其他網路介面:$ sudo ifdown eth0$ sudo ifup eth0 臨時改變IP地址$ sudo ifconfig eth0 192.168.1.111 netmask 255.255.255.0當系統重啟動後,後會恢複interfaces中的配置。設定預設閘道的方法也有兩種:1. 在interfaces檔案中設定。$ sudo vi /etc/network/interfaces在eth0的相關配置下加入gateway,如:auto eth0iface eth0 inet staticaddress 192.168.1.123netmask 255.255.255.0gateway 192.168.1.12. 直接用命令設定:刪除當前預設網關$ sudo route del default gw手工配置預設網關$ sudo route add default gw 192.168.1.1查看路由資訊$ route使用本方法,修改當即生效,重新啟動後,則interfaces檔案中的設定有效。查看主機名稱$ hosts臨時修改主機名稱$ sudo hostname testserver執行完命令後,即時生效。永久修改主機名稱$ sudo vi /etc/hostname把新的主機名稱寫入即可。當系統重啟後,會讀出此檔案中主機名稱。配置DNS伺服器的地址,最多可以使用3個DNS伺服器$ sudo vi /etc/resolv.confnameserver 202.xx.xx.xxnameserver 192.168.1.1對”resolv.conf”的修改是即時生效的。可以使用nslookup命令進行DNS伺服器查詢,以驗證”resolv.conf”設定檔。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.