ifconfig 是一個用于配置和顯示 Linux 內核中網絡接口的命令行實用程序。要使用 ifconfig 查看網絡連接,請按照以下步驟操作:
打開終端(Terminal)。
輸入 ifconfig 命令,然后按 Enter 鍵。這將顯示系統中所有活動網絡接口的詳細信息。輸出示例:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.2 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 1031456 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 64 bytes 5760 (5.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 64 bytes 5760 (5.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
在這個示例中,eth0 是一個活動的網絡接口,其 IP 地址為 192.168.1.2,子網掩碼為 255.255.255.0,廣播地址為 192.168.1.255。lo 是一個本地回環接口,用于測試網絡連接。
要查看特定網絡接口的信息,可以在 ifconfig 命令后添加接口名稱,例如:
ifconfig eth0
這將僅顯示 eth0 接口的詳細信息。
請注意,ifconfig 在某些 Linux 發行版中可能已被棄用,建議使用 ip 命令替代。要使用 ip 命令查看網絡連接,請輸入 ip addr 或 ip a。