Ifconfig

ifconfig 是否顯示了 ether 後面的網路介面的 MAC 地址?

  • March 24, 2019

是否ifconfig顯示以下網路介面的 MAC 地址ether

ether是指乙太網嗎?Mac地址是什麼意思?

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
       inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
       ether 52:54:00:b1:aa:1f  txqueuelen 1000  (Ethernet)
       RX packets 451  bytes 43572 (43.5 KB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 108  bytes 28182 (28.1 KB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlx8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
       inet 192.168.1.97  netmask 255.255.255.0  broadcast 192.168.1.255
       inet6 xx:xx:xx  prefixlen 64  scopeid 0x20<link>
       ether 80:1f:02:b5:c3:89  txqueuelen 1000  (Ethernet)
       RX packets 697657  bytes 564556036 (564.5 MB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 374913  bytes 60332457 (60.3 MB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

如手冊中所述ifconfig,在設置選項部分中

如果設備驅動支持該操作,則設置該介面的硬體地址。關鍵字後面必須跟硬體類的名稱和硬體地址的可列印 ASCII 等價物。目前支持的硬體類包括ether(Ethernet)、ax25(AMPR AX.25)ARCnetnetrom(AMPR NET/ROM)。

這也解釋了輸出, ifconfig顯示介面的目前硬體地址及其硬體類。對於乙太網介面,類是ether,硬體地址是 MAC 地址。

注意ifconfig報告數據的不同實現方式不同。

對於 Linux 上常見的 net-tools 版本,這個詞ether硬體類,後面的值是硬體地址。可以使用以下ifconfig hw命令更改這兩者:

  hw class address
         Set the hardware address of this interface, if the device driver
         supports  this  operation.   The keyword must be followed by the
         name of the hardware class and the printable ASCII equivalent of
         the  hardware  address.   Hardware  classes  currently supported
         include ether (Ethernet), ax25 (AMPR AX.25), ARCnet  and  netrom
         (AMPR NET/ROM).

對於“乙太網”硬體類,地址是卡的 MAC 地址。

引用自:https://unix.stackexchange.com/questions/508384