溫馨提示×

如何通過ifconfig查看網絡接口

小樊
45
2025-10-04 08:35:13
欄目: 編程語言

ifconfig 是一個用于配置和顯示 Linux 內核中網絡接口的命令行實用程序。通過 ifconfig,你可以查看網絡接口的狀態、IP 地址、子網掩碼等信息。以下是如何使用 ifconfig 查看網絡接口的步驟:

  1. 打開終端(Terminal)。

  2. 輸入以下命令并按 Enter 鍵:

    ifconfig
    
  3. 你將看到系統中所有活動的網絡接口及其相關信息。輸出結果類似于以下內容:

    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
            inet6 fe80::a00:27ff:fe4e:66a1  prefixlen 64  scopeid 0x20<link>
            ether 08:00:27:4e:66:a1  txqueuelen 1000  (Ethernet)
            RX packets 1003456  bytes 123456789 (117.7 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 987654  bytes 987654321 (941.5 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 12345  bytes 123456 (120.4 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 12345  bytes 123456 (120.4 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    

    在這個例子中,有兩個網絡接口:eth0lo。eth0 是一個以太網接口,lo 是一個本地回環接口。

  4. 你可以查看特定網絡接口的信息,例如 eth0,只需在 ifconfig 命令后添加接口名稱:

    ifconfig eth0
    

請注意,在某些 Linux 發行版中(如 Ubuntu 18.04 及更高版本),ifconfig 可能已被棄用,建議使用 ip 命令替代。要使用 ip 命令查看網絡接口,請輸入以下命令:

ip addr show

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女