Выбрать язык


Выбрать язык | Show only


Русский | English


суббота, 2 апреля 2016 г.

Linux "show mac-address-table" analogue

Few days ago I could see a user question about Linux analogue for Cisco "show mac-address-table" command. He wo'nt use the "arp"or "arp -a" command for some hidden reasons. And I think it may be interesting for other users.



The "arp" or "arp -a" command shows you mac-address table (MAC-interface maping) and ARP table (MAC-IP mapping) all-in-one. Cisco IOS devices, as networking equipment, show some more information and it contains VLAN id and entry type (static or dynamic).

Cisco output are below:


#sh mac address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
 All    0100.0ccc.cccc    STATIC      CPU
 All    0100.0ccc.cccd    STATIC      CPU
<skipped>

 All    ffff.ffff.ffff    STATIC      CPU
 10    0000.0c07.abcd    DYNAMIC     Gi0/1
 20    000b.be68.bcde    DYNAMIC     Gi0/2
 30    0013.6016.cdef    DYNAMIC     Gi0/3
<skipped>

Total Mac Addresses for this criterion: 67

#sh ip arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  10.100.10.11            0   3c4a.92b2.abcd  ARPA   Vlan10 

Internet  10.100.20.28          162   b4b5.2fab.bcde  ARPA   Vlan20
 

But Linux "arp" and "arp -a" commands show us some another information:

# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.10.1             ether   00:50:56:c0:00:08   C                     eth0
192.168.10.2             ether   00:50:56:f2:83:0a   C                     eth0
 

# arp -a
? (192.168.10.1) at 00:50:56:c0:00:08 [ether] on eth0
? (192.168.10.2) at 00:50:56:f2:83:0a [ether] on eth0

 

So you can see both ARP and MAC-address table in one output. It is not so rich as Cisco output but it is good enough.

But if you think that the "arp" output contains a lot of extra information you may parse it with "awk" command:

# arp | grep -v Address | awk ' { print $3,$5 } '
00:50:56:c0:00:08 eth0
00:50:56:f2:83:0a eth0


If you hate the "arp" or "awk" command you must 

  • install bridge-utils, 
  • set the bridge, 
  • add interfaces to the bridge
  • use "brctl showmacs" command


# brctl addbr 1
# brctl addif 1 eth0
# brctl showmacs 1

 port no mac addr is local? ageing timer
1 00:0c:29:1f:cf:5a yes 0.00
1 00:50:56:c0:00:08 no 0.00


So I hope this information may be interesting and useful.

Комментариев нет:

Отправить комментарий