1. 程式人生 > >Linux下ifconfig不顯示ip地址

Linux下ifconfig不顯示ip地址

本文轉載自:http://blog.csdn.net/cmh477660693/article/details/52760236

ubuntu終端下命令ifconfig的問題解決

問題一. ifconfig之後只顯示lo,沒有看到eth0

問題二. ifconfig之後顯示eth0,但是沒有顯示靜態IP地址,即無inet、地址、廣播、掩碼。

問題三. ping命令不能使用,因為dns還沒設定,編輯/etc/resolv.conf,加上dns伺服器地址。

問題一:ifconfig之後只顯示lo,沒有看到eth0 ?

  1. eth0設定不正確,導致無法正常啟動,修改eth0配置檔案就好 
    ubuntu 12.04的網路設定檔案是/etc/network/interfaces,開啟檔案,會看到 
    auto lo 
    iface lo inet loopback 
    這邊的設定是本地迴路。在後面加上 
    auto eth0 
    iface eth0 inet static 
    address 192.168.1.230 //(ip地址) 
    netmask 255.255.255.0 //(子網掩碼) 
    gateway 192.168.1.1 //(閘道器) 
    其中eth0就是電腦的網絡卡,如果電腦有多塊網絡卡,比如還會有eth1,都可以在這裡進行設定。iface eth0 inet 設定為dhcp是動態獲取IP,設定為static則用自定義的IP。這邊要自定義IP地址,所以選擇static選項。
  2. eth0被關了

    輸入命令列:ifconfig eth0 up    #開啟eth0
    

問題二:ifconfig之後顯示eth0,但是沒有顯示“inet/地址/廣播/掩碼/ ”?

  1. 先用sudo dhclient eth0更新IP地址

  2. 然後執行sudo ifconfig eth0

    3.reboot

問題三:重啟後,ping命令不能使用,因為dns還沒設定,編輯/etc/resolv.conf,加上dns伺服器地址。

設定好後,如果直接ping www.baidu.com會發現ping不通,因為dns還沒設定,編輯/etc/resolv.conf,加上dns伺服器地址。 
nameserver 8.8.8.8 
nameserver 8.8.4.4 
這兩個是Google提供的免費DNS伺服器的IP地址