Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

FreeBSD 查看 IP 位址與網路介面資訊指令 (ifconfig -a)

編輯:關於伺服器

FreeBSD 系統下查看 IP 位址、MAC 位址、MTU、IPv6 等網路介面完整資訊的標準指令與輸出解讀。

操作步驟

  1. SSH 或本地終端機以 root/一般用戶登入 FreeBSD。
  2. 執行:ifconfig -a
  3. 解讀輸出關鍵欄位。

指令與範例輸出

$ ifconfig -a
em0: flags=8843 metric 0 mtu 1500
        options=9b
        ether 00:0c:29:e2:ce:a2
        inet 192.168.1.195 netmask 0xffffff00 broadcast 192.168.1.255
        inet6 fe80::20c:29ff:fee2:cea2%em0 prefixlen 64 scopeid 0x2
        nd6 options=29
        media: Ethernet autoselect (1000baseT )
        status: active

plip0: flags=8810 metric 0 mtu 1500
        nd6 options=29

lo0: flags=8049 metric 0 mtu 16384
        options=600003
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=21

關鍵欄位速查

欄位說明範例值
em0實體網卡介面名稱 (Intel PRO/1000)em0, igb0, re0, vtnet0
flags介面狀態旗標UP=啟用, RUNNING=連線中, BROADCAST=支援廣播
mtu最大傳輸單元1500 (乙太網標準)
etherMAC 位址 (硬體位址)00:0c:29:e2:ce:a2
inetIPv4 位址192.168.1.195
netmask子網掩碼 (十六進位)0xffffff00 = 255.255.255.0
broadcast廣播位址192.168.1.255
inet6IPv6 位址 (Link-local / Global)fe80::20c:29ff:fee2:cea2%em0
media實體介質狀態1000baseT full-duplex
status介面連線狀態active / no carrier
lo0回環介面127.0.0.1 / ::1

常用變體指令

  • ifconfig em0:僅顯示指定介面。
  • ifconfig -l:列出所有介面名稱 (一行)。
  • ifconfig em0 inet:僅顯示 IPv4 相關資訊。
  • ifconfig em0 inet6:僅顯示 IPv6 相關資訊。

永久配置 IP (rc.conf)

# /etc/rc.conf
ifconfig_em0="inet 192.168.1.195 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
# IPv6
ifconfig_em0_ipv6="inet6 2001:db8::1 prefixlen 64"
ipv6_defaultrouter="2001:db8::fffe"

修改後 service netif restart && service routing restart 生效。

掌握 ifconfig -a 輸出解讀,可快速完成 FreeBSD 網路故障排查、IP 規劃與防火牆規則編寫。

Copyright © Windows教程網 All Rights Reserved