Linux下ifconfig命令的擴充實用

來源:互聯網
上載者:User

   Linux查看IP地址的命令--ifconfig

  ifconfig命令用於查看和更改網路介面的地址和參數

  代碼如下:

  $ifconfig -a

lo0: flags=849 mtu 8232

inet 127.0.0.1 netmask ff000000

hme0: flags=863 mtu 1500

inet 211.101.149.11 netmask ffffff00 broadcast 211.101.149.255

ether 8:0:20:a7:4d:21

  系統會顯示網路介面的名稱,介面的狀態(up or down),

  介面的IP地址和掩碼等資訊

  更改網路介面的IP地址:

  代碼如下:

  #ifconfig hme0 down

#ifconfig hme0 211.101.149.233 netmask 255.255.255.0 up

  首先,使用down命令參數把網路介面hme0的服務暫時停止,然後再用Linux查看ip的ifconfig命令給

  介面分配新的IP地址和掩碼,並啟動網路介面服務

  也可以通過改變檔案/etc/hosts中的IP地址的值並重新啟動系統來更改機器的IP地址。

  代碼如下:

  /etc/hosts/: 211.101.149.11 sampdt

  定義主機名稱在/etc/hostname.hme0及IP地址。

  更改了網卡/增加了網卡,系統不能自動啟動該介面服務,這時需要手動建立網口服務:

  代碼如下:

  #ifconfig hme0 plumb

  Linux查看ip即可以為介面le0建立網口服務

  相應地,用ifconfig帶unplumb參數可以停止服務並關閉網路.

  netconfig 用來設定IP地址

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.