Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

close
keyboard_arrow_left
Ethernet Switching User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
keyboard_arrow_right

MAC Accounting

date_range 20-Dec-24

Enabling MAC Accounting on a Device

By default, MAC accounting is disabled on the device. You can enable packet accounting either for a device as a whole or for a specific VLAN. After you enable packet accounting, the Junos OS maintains packet counters for each MAC address learned.

To enable MAC accounting, include the global-mac-statistics statement at the [edit protocols l2-learning] hierarchy level:

content_copy zoom_out_map
[edit protocols l2-learning]
global-mac-statistics;

Enabling MAC Accounting for a VLAN

By default, MAC accounting is disabled. You can enable packet counting for a VLAN. When you enable packet accounting, the Junos OS maintains packet counters for each MAC address learned on the interfaces in the VLAN.

To enable MAC accounting for a VLAN, include the mac-statistics statement at the [edit vlans vlan-name switch-options] hierarchy level:

content_copy zoom_out_map
[edit vlans vlan-name switch-options]
mac-statistics;

Enabling MAC Accounting for a Set of VLANs

By default, MAC accounting is disabled. You can enable packet counting for a set of VLANs. After you enable packet accounting, the Junos OS maintains packet counters for each MAC address learned on the trunk port associated with the set of VLANs.

To enable MAC accounting for a set of VLANs, include the mac-statistics statement at the [edit switch-options] hierarchy level:

content_copy zoom_out_map
[edit switch-options]
mac-statistics;

Verifying That MAC Accounting Is Working

Purpose

Verify that MAC accounting is enabled and the system is counting packets and collecting statistics.

Action

  1. Verify that MAC accounting is enabled.

    content_copy zoom_out_map
    user@switch> show ethernet-switching table
    MAC flags (S - static MAC, D - dynamic MAC, L - locally learned
            SE - statistics enabled, NM - non configured MAC, R - remote PE MAC)
    
    Routing instance : default-switch
        Vlan                MAC                 MAC         Age    Logical
        name                address             flags              interface
        VLAN101             88:e0:f3:bb:07:f0   D,SE           -   ae20.0
    
    
    MAC flags (S - static MAC, D - dynamic MAC, L - locally learned
           SE - statistics enabled, NM - non configured MAC, R - remote PE MAC)
    
    Routing instance : default-switch
        Vlan                MAC                 MAC         Age    Logical
        name                address             flags              interface
        VLAN102             88:e0:f3:bb:07:f0   D,SE           -   ae20.0
    
    
    MAC flags (S - static MAC, D - dynamic MAC, L - locally learned
           SE - statistics enabled, NM - non configured MAC, R - remote PE MAC)
    
    Routing instance : default-switch
        Vlan                MAC                 MAC         Age    Logical
        name                address             flags              interface
        VLAN103             88:e0:f3:bb:07:f0   D,SE           -   ae20.0
    [...output truncated...]
  2. Display MAC accounting statistics for all VLANs associated with an interface.

    content_copy zoom_out_map
    user@switch> show ethernet-switching statistics
    
     Local interface: ae20.0, Index: 1039
       Broadcast packets:                   115
       Broadcast bytes  :                  6900
       Multicast packets:                395113
       Multicast bytes  :              61622869
       Flooded packets  :                     0
       Flooded bytes    :                     0
       Unicast packets  :                  1419
       Unicast bytes    :                117924
       Current MAC count:                     4 (Limit 8192)
    [...output truncated...]
  3. Display MAC accounting statistics for each address in the MAC address table.

    content_copy zoom_out_map
    user@switch> show ethernet-switching table extensive
    MAC address: 88:e0:f3:bb:07:f0
      Routing instance: default-switch
    VLAN ID: 101
       Learning interface: ae20.0
       Layer 2 flags: in_hash,in_ifd,in_ifl,in_vlan,in_rtt,acct,kernel,in_ifbd
       Epoch: 6                            Sequence number: 13
       Learning mask: 0x00000020
    MAC address used as destination:
    Packet count:                     0  Byte count:                     0
    MAC address used as source:
    Packet count:                     9  Byte count:                  1116
    
    MAC address: 88:e0:f3:bb:07:f0
      Routing instance: default-switch
    VLAN ID: 102
       Learning interface: ae20.0
       Layer 2 flags: in_hash,in_ifd,in_ifl,in_vlan,in_rtt,acct,kernel,in_ifbd
       Epoch: 6                            Sequence number: 13
       Learning mask: 0x00000020
    MAC address used as destination:
    Packet count:                     0  Byte count:                     0
    MAC address used as source:
    Packet count:                     9  Byte count:                  1116
    
    MAC address: 88:e0:f3:bb:07:f0
      Routing instance: default-switch
    VLAN ID: 103
       Learning interface: ae20/0
       Layer 2 flags: in_hash,in_ifd,in_ifl,in_vlan,in_rtt,acct,kernel,in_ifbd
       Epoch: 6                            Sequence number: 13
       Learning mask: 0x00000020
    MAC address used as destination:
    Packet count:                     0  Byte count:                     0
    MAC address used as source:
    Packet count:                     9  Byte count:                  1116
    [...output truncated...]

Meaning

In the output for show ethernet-switching table, the MAC flag SE indicates that MAC accounting is enabled for VLANs 101, 102, and 103, which are all associated with the default-switch routing instance.

The output for show ethernet-switching statistics displays packet statistics and the current number of MAC addresses learned by the VLANs associated with aggregated Ethernet interface ae20.0.

The output for show ethernet-switching table extensive shows information for each address in the MAC address table. In particular, it displays the number of packets sent to and received by an interface, which is identified by a MAC address.

The output from the three commands demonstrates that MAC accounting is working properly. That is, MAC accounting is enabled on VLANs 101, 102, and 103, and as a result, you can view statistics for each of these VLANs, aggregated Ethernet interface ae20.0, and each MAC address.

external-footer-nav