.. _clicmd_src_vnet_l2:

===============================================================
Layer 2 CLI
===============================================================

bvi create
-------------------------------------------------------------------------

.. code-block:: console

    bvi create [mac <mac-addr>] [instance <instance>]



Create a BVI interface. Optionally, a MAC Address can be
provided. If not provided, 0b:0b::00:00:00:<instance> will be used.

The following two command syntaxes are equivalent:


.. code-block:: console

    bvi create [mac <mac-addr>] [instance <instance>]


Example of how to create a bvi interface:


.. code-block:: console

    bvi create



Declaration: ``l2_bvi_create_command`` `src/vnet/l2/l2_bvi.c line 274 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bvi.c#L274>`_

Implementation: ``l2_bvi_create_cli``


bvi delete
-------------------------------------------------------------------------

.. code-block:: console

    bvi delete <interface>



Delete a BVI interface.

The following two command syntaxes are equivalent:


.. code-block:: console

    bvi delete <interface>


Example of how to create a bvi interface:


.. code-block:: console

    bvi delete bvi0



Declaration: ``l2_bvi_delete_command`` `src/vnet/l2/l2_bvi.c line 323 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bvi.c#L323>`_

Implementation: ``l2_bvi_delete_cli``


clear l2fib
-------------------------------------------------------------------------

.. code-block:: console

    clear l2fib



This command clears all the MAC Address entries from the L2 FIB table.

Example of how to clear the L2 FIB Table:


.. code-block:: console

    clear l2fib


Example to show the L2 FIB Table has been cleared:


.. code-block:: console

    show l2fib verbose
    
    no l2fib entries
    



Declaration: ``clear_l2fib_cli`` `src/vnet/l2/l2_fib.c line 416 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L416>`_

Implementation: ``clear_l2fib``


create bridge-domain
-------------------------------------------------------------------------

.. code-block:: console

    create bridge-domain <bridge-domain-id> [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] [arp-term <0|1>] [arp-ufwd <0|1>] [mac-age <nn>] [bd-tag <tag>] [del]



Create/Delete bridge-domain instance

Example of creating bridge-domain 1:


.. code-block:: console

    create bridge-domain 1
    
    bridge-domain 1
    



Example of creating bridge-domain 2 with enabling arp-term, mac-age 60:


.. code-block:: console

    create bridge-domain 2 arp-term 1 mac-age 60
    
    bridge-domain 2
    
    vpp# show bridge-domain
      ID   Index   BSN  Age(min)  Learning  U-Forwrd  UU-Flood  Flooding  ARP-Term  BVI-Intf
      0      0      0     off       off       off       off       off       off      local0
      1      1      0     off        on        on       off        on       off       N/A
      2      2      0      60        on        on       off        on        on       N/A
    
    



Example of delete bridge-domain 1:


.. code-block:: console

    create bridge-domain 1 del
    
    




Declaration: ``bd_create_cli`` `src/vnet/l2/l2_bd.c line 1575 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L1575>`_

Implementation: ``bd_add_del_command_fn``


l2 rewrite entry
-------------------------------------------------------------------------

.. code-block:: console

    l2 rewrite entry [index <index>] [mask <hex-mask>] [value <hex-value>] [skip <n_bytes>] [del]



Layer 2-Rewrite node uses classify tables to match packets. Then, using
the provisioned mask and value, modifies the packet header.

Example of how to add an l2 rewrite entry to change the destination mac of
the packet to 00:8a:00:0d:0e:02 (where parameter mask is Ethernet header's
mask,
parameter value is Ethernet header's value):


.. code-block:: console

    l2 rewrite entry mask ffffffffffff00000000000000000000 value 008a000d0e0200000000000000000000



Declaration: ``l2_rw_entry_cli`` `src/vnet/l2/l2_rw.c line 410 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_rw.c#L410>`_

Implementation: ``l2_rw_entry_cli_fn``


l2fib add
-------------------------------------------------------------------------

.. code-block:: console

    l2fib add <mac> <bridge-domain-id> filter | <intf> [static | bvi]



This command adds a MAC Address entry to the L2 FIB table
of an existing bridge-domain. The MAC Address can be static
or dynamic. This command also allows a filter to be added,
such that packets with given MAC Addresses (source mac or
destination mac match) are dropped.

Example of how to add a dynamic MAC Address entry to the L2 FIB table
of a bridge-domain (where 200 is the bridge-domain-id):


.. code-block:: console

    l2fib add 52:54:00:53:18:33 200 GigabitEthernet0/8/0.200


Example of how to add a static MAC Address entry to the L2 FIB table
of a bridge-domain (where 200 is the bridge-domain-id):


.. code-block:: console

    l2fib add 52:54:00:53:18:55 200 GigabitEthernet0/8/0.200 static


Example of how to add a filter such that a packet with the given MAC
Address will be dropped in a given bridge-domain (where 200 is the
bridge-domain-id):


.. code-block:: console

    l2fib add 52:54:00:53:18:77 200 filter


Example of show command of the provisioned MAC Addresses and filters:


.. code-block:: console

    show l2fib verbose
    
        Mac Address     BD Idx           Interface           Index  static  filter  bvi  refresh  timestamp
     52:54:00:53:18:33    1      GigabitEthernet0/8/0.200      3       0       0     0      0         0
     52:54:00:53:18:55    1      GigabitEthernet0/8/0.200      3       1       0     0      0         0
     52:54:00:53:18:77    1                 N/A                -1      1       1     0      0         0
    3 l2fib entries
    



Declaration: ``l2fib_add_cli`` `src/vnet/l2/l2_fib.c line 591 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L591>`_

Implementation: ``l2fib_add``


l2fib del
-------------------------------------------------------------------------

.. code-block:: console

    l2fib del <mac> <bridge-domain-id> []



This command deletes an existing MAC Address entry from the L2 FIB
table of an existing bridge-domain.

Example of how to delete a MAC Address entry from the L2 FIB table of a bridge-domain (where 200 is the bridge-domain-id):


.. code-block:: console

    l2fib del 52:54:00:53:18:33 200



Declaration: ``l2fib_del_cli`` `src/vnet/l2/l2_fib.c line 827 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L827>`_

Implementation: ``l2fib_del``


l2fib flush-mac all
-------------------------------------------------------------------------

.. code-block:: console

    l2fib flush-mac all



This command kick off ager to delete all existing MAC Address entries,
except static ones, associated with an interface from the L2 FIB table.

Example of how to flush MAC Address entries learned on an interface from the L2 FIB table:


.. code-block:: console

    l2fib flush-mac interface GigabitEthernet2/1/0



Declaration: ``l2fib_flush_mac_all_cli`` `src/vnet/l2/l2_fib.c line 969 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L969>`_

Implementation: ``l2fib_flush_mac_all``


l2fib flush-mac bridge-domain
-------------------------------------------------------------------------

.. code-block:: console

    l2fib flush-mac bridge-domain <bd-id>



This command kick off ager to delete all existing MAC Address entries,
except static ones, in a bridge domain from the L2 FIB table.

Example of how to flush MAC Address entries learned in a bridge domain from the L2 FIB table:


.. code-block:: console

    l2fib flush-mac bridge-domain 1000



Declaration: ``l2fib_flush_mac_bd_cli`` `src/vnet/l2/l2_fib.c line 1030 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L1030>`_

Implementation: ``l2fib_flush_mac_bd``


l2fib flush-mac interface
-------------------------------------------------------------------------

.. code-block:: console

    l2fib flush-mac interface <if-name>



This command kick off ager to delete all existing MAC Address entries,
except static ones, associated with an interface from the L2 FIB table.

Example of how to flush MAC Address entries learned on an interface from the L2 FIB table:


.. code-block:: console

    l2fib flush-mac interface GigabitEthernet2/1/0



Declaration: ``l2fib_flush_mac_int_cli`` `src/vnet/l2/l2_fib.c line 983 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L983>`_

Implementation: ``l2fib_flush_mac_int``


set bridge-domain arp entry
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain arp entry <bridge-domain-id> [<ip-addr> <mac-addr> [del] | del-all]



Add an ARP entry to an existing bridge-domain.

Example of how to add an ARP entry (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain arp entry 200 192.168.72.45 52:54:00:3b:83:1a


Example of how to delete an ARP entry (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain arp entry 200 192.168.72.45 52:54:00:3b:83:1a del



Declaration: ``bd_arp_entry_cli`` `src/vnet/l2/l2_bd.c line 1106 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L1106>`_

Implementation: ``bd_arp_entry``


set bridge-domain arp term
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain arp term <bridge-domain-id> [disable]



Modify whether or not an existing bridge-domain should terminate and respond
to ARP Requests. ARP Termination is disabled by default.

Example of how to enable ARP termination (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain arp term 200


Example of how to disable ARP termination (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain arp term 200 disable



Declaration: ``bd_arp_term_cli`` `src/vnet/l2/l2_bd.c line 910 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L910>`_

Implementation: ``bd_arp_term``


set bridge-domain arp-ufwd
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain arp-ufwd <bridge-domain-id> [disable]



Layer 2 arp-unicast forwarding can be enabled and disabled on each
bridge-domain. It is disabled by default.

Example of how to enable arp-unicast forwarding (where 200 is the
bridge-domain-id):


.. code-block:: console

    set bridge-domain arp-ufwd 200


Example of how to disable arp-unicast forwarding (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain arp-ufwd 200 disable



Declaration: ``bd_arp_ufwd_cli`` `src/vnet/l2/l2_bd.c line 735 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L735>`_

Implementation: ``bd_arp_ufwd``


set bridge-domain default-learn-limit
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain default-learn-limit <maxentries>


Declaration: ``bd_default_learn_limit_cli`` `src/vnet/l2/l2_bd.c line 483 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L483>`_

Implementation: ``bd_default_learn_limit``


set bridge-domain flood
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain flood <bridge-domain-id> [disable]



Layer 2 flooding can be enabled and disabled on each
interface and on each bridge-domain. Use this command to
manage bridge-domains. It is enabled by default.

Example of how to enable flooding (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain flood 200


Example of how to disable flooding (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain flood 200 disable



Declaration: ``bd_flood_cli`` `src/vnet/l2/l2_bd.c line 609 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L609>`_

Implementation: ``bd_flood``


set bridge-domain forward
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain forward <bridge-domain-id> [disable]



Layer 2 unicast forwarding can be enabled and disabled on each
interface and on each bridge-domain. Use this command to
manage bridge-domains. It is enabled by default.

Example of how to enable forwarding (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain forward 200


Example of how to disable forwarding (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain forward 200 disable



Declaration: ``bd_fwd_cli`` `src/vnet/l2/l2_bd.c line 546 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L546>`_

Implementation: ``bd_fwd``


set bridge-domain learn
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain learn <bridge-domain-id> [disable]



Layer 2 learning can be enabled and disabled on each
interface and on each bridge-domain. Use this command to
manage bridge-domains. It is enabled by default.

Example of how to enable learning (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain learn 200


Example of how to disable learning (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain learn 200 disable



Declaration: ``bd_learn_cli`` `src/vnet/l2/l2_bd.c line 455 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L455>`_

Implementation: ``bd_learn``


set bridge-domain learn-limit
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain learn-limit <bridge-domain-id> <learn-limit>


Declaration: ``bd_learn_limit_cli`` `src/vnet/l2/l2_bd.c line 893 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L893>`_

Implementation: ``bd_learn_limit``


set bridge-domain mac-age
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain mac-age <bridge-domain-id> <mins>



Layer 2 mac aging can be enabled and disabled on each
bridge-domain. Use this command to set or disable mac aging
on specific bridge-domains. It is disabled by default.

Example of how to set mac aging (where 200 is the bridge-domain-id and
5 is aging time in minutes):


.. code-block:: console

    set bridge-domain mac-age 200 5


Example of how to disable mac aging (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain flood 200 0



Declaration: ``bd_mac_age_cli`` `src/vnet/l2/l2_bd.c line 845 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L845>`_

Implementation: ``bd_mac_age``


set bridge-domain rewrite
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain rewrite <bridge-domain> [disable]



Layer 2 rewrite can be enabled and disabled on each interface and on each
bridge-domain.
Use this command to manage l2 rewrite on bridge-domain.

Example of how to enable rewrite (where 100 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain rewrite 100


Example of how to disable rewrite (where 100 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain rewrite 100 disable



Declaration: ``l2_rw_set_cli`` `src/vnet/l2/l2_rw.c line 615 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_rw.c#L615>`_

Implementation: ``l2_rw_set_cli_fn``


set bridge-domain uu-flood
-------------------------------------------------------------------------

.. code-block:: console

    set bridge-domain uu-flood <bridge-domain-id> [disable]



Layer 2 unknown-unicast flooding can be enabled and disabled on each
bridge-domain. It is enabled by default.

Example of how to enable unknown-unicast flooding (where 200 is the
bridge-domain-id):


.. code-block:: console

    set bridge-domain uu-flood 200


Example of how to disable unknown-unicast flooding (where 200 is the bridge-domain-id):


.. code-block:: console

    set bridge-domain uu-flood 200 disable



Declaration: ``bd_uu_flood_cli`` `src/vnet/l2/l2_bd.c line 672 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L672>`_

Implementation: ``bd_uu_flood``


set interface l2 bridge
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 bridge <interface> <bridge-domain-id> [bvi|uu-fwd] [shg]



Use this command put an interface into Layer 2 bridge domain. If a
bridge-domain with the provided bridge-domain-id does not exist, it
will be created. Interfaces in a bridge-domain forward packets to
other interfaces in the same bridge-domain based on destination mac
address. To remove an interface from a the Layer 2 bridge domain,
put the interface in a different mode, for example Layer 3 mode.

Optionally, an interface can be added to a Layer 2 bridge-domain as
a Bridged Virtual Interface (bvi). Only one interface in a Layer 2
bridge-domain can be a bvi.

Optionally, a split-horizon group can also be specified. This defaults
to 0 if not specified.

Example of how to configure a Layer 2 bridge-domain with three
interfaces (where 200 is the bridge-domain-id):


.. code-block:: console

    set interface l2 bridge GigabitEthernet0/8/0.200 200


This interface is added a BVI interface:


.. code-block:: console

    set interface l2 bridge GigabitEthernet0/9/0.200 200 bvi


This interface also has a split-horizon group of 1 specified:


.. code-block:: console

    set interface l2 bridge GigabitEthernet0/a/0.200 200 1


Example of how to remove an interface from a Layer2 bridge-domain:


.. code-block:: console

    set interface l3 GigabitEthernet0/a/0.200



Declaration: ``int_l2_bridge_cli`` `src/vnet/l2/l2_input.c line 649 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_input.c#L649>`_

Implementation: ``int_l2_bridge``


set interface l2 efp-filter
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 efp-filter <interface> [disable]



EFP filtering is a basic switch feature which prevents an interface from
transmitting a packet that doesn't match the interface's ingress match
criteria. The check has two parts, one performed before egress vlan tag
rewrite and one after. This command enables or disables the EFP filtering
for a given sub-interface.

Example of how to enable a Layer 2 efp-filter on a sub-interface:


.. code-block:: console

    set interface l2 efp-filter GigabitEthernet0/8/0.200


Example of how to disable a Layer 2 efp-filter on a sub-interface:


.. code-block:: console

    set interface l2 efp-filter GigabitEthernet0/8/0.200 disable



Declaration: ``int_l2_efp_filter_cli`` `src/vnet/l2/l2_efp_filter.c line 560 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_efp_filter.c#L560>`_

Implementation: ``int_l2_efp_filter``


set interface l2 flood
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 flood <interface> [disable]



Layer 2 flooding can be enabled and disabled on each
interface and on each bridge-domain. Use this command to
manage interfaces. It is enabled by default.

Example of how to enable flooding:


.. code-block:: console

    set interface l2 flood GigabitEthernet0/8/0


Example of how to disable flooding:


.. code-block:: console

    set interface l2 flood GigabitEthernet0/8/0 disable



Declaration: ``int_flood_cli`` `src/vnet/l2/l2_flood.c line 469 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_flood.c#L469>`_

Implementation: ``int_flood``


set interface l2 forward
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 forward <interface> [disable]



Layer 2 unicast forwarding can be enabled and disabled on each
interface and on each bridge-domain. Use this command to
manage interfaces. It is enabled by default.

Example of how to enable forwarding:


.. code-block:: console

    set interface l2 forward GigabitEthernet0/8/0


Example of how to disable forwarding:


.. code-block:: console

    set interface l2 forward GigabitEthernet0/8/0 disable



Declaration: ``int_fwd_cli`` `src/vnet/l2/l2_fwd.c line 526 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fwd.c#L526>`_

Implementation: ``int_fwd``


set interface l2 input classify
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 input classify intfc <interface-name> [ip4-table <n>]
      [ip6-table <n>] [other-table <n>]



Configure l2 input classification.



.. code-block:: console

    set interface l2 input classify intfc <interface-name> [ip4-table <index>] [ip6-table <index>] [other-table <index>]
    
    



practical example.

Declaration: ``int_l2_input_classify_cli`` `src/vnet/l2/l2_input_classify.c line 642 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_input_classify.c#L642>`_

Implementation: ``int_l2_input_classify_command_fn``


set interface l2 learn
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 learn <interface> [disable]



Layer 2 learning can be enabled and disabled on each
interface and on each bridge-domain. Use this command to
manage interfaces. It is enabled by default.

Example of how to enable learning:


.. code-block:: console

    set interface l2 learn GigabitEthernet0/8/0


Example of how to disable learning:


.. code-block:: console

    set interface l2 learn GigabitEthernet0/8/0 disable



Declaration: ``int_learn_cli`` `src/vnet/l2/l2_learn.c line 541 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_learn.c#L541>`_

Implementation: ``int_learn``


set interface l2 output classify
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 output classify intfc <<interface-name>> [ip4-table <n>]
      [ip6-table <n>] [other-table <n>]



Configure Layer 2 output classification.



.. code-block:: console

    set interface l2 output classify intfc <interface-name> [ip4-table <index>] [ip6-table <index>] [other-table <index>]
    
    



practical example.

Declaration: ``int_l2_output_classify_cli`` `src/vnet/l2/l2_output_classify.c line 635 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_output_classify.c#L635>`_

Implementation: ``int_l2_output_classify_command_fn``


set interface l2 pbb-tag-rewrite
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 pbb-tag-rewrite <interface> [disable | pop | push | translate_pbb_stag <outer_tag> dmac <address> smac <address> s_id <nn> [b_vlanid <nn>]]


Declaration: ``int_l2_pbb_vtr_cli`` `src/vnet/l2/l2_vtr.c line 817 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_vtr.c#L817>`_

Implementation: ``int_l2_pbb_vtr``


set interface l2 rewrite
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 rewrite <interface> [table <table index>] [miss-index <entry-index>]



Apply the rule to the interface. The following example shows how to use
classify
entry and Layer 2-Rewrite entry to modify the packet ethernet header on the
interface.

Example use the classify to filter packets that do not need to be modified
(where
192.168.68.34 is the destination ip of the data packet, 8080 is the
destination port
of the packet):


.. code-block:: console

    classify table mask l3 ip4 dst l4 dst_port




.. code-block:: console

    classify session acl-hit-next permit table-index 0 match l3 ip4 dst 192.168.68.34 l4 dst_port 8080



Example apply classify and l2 rewrite rules to the interface (where
YusurK2Eth6/0/1/3
is interface, \"table 0\" means Table Id is 0, \"miss 0\" means the packet
that matches
the classify. miss will be modified according to the l2 rewrite entry with
index 0):


.. code-block:: console

    set interface l2 rewrite YusurK2Eth6/0/1/3 table 0 miss-index 0



Declaration: ``l2_rw_interface_cli`` `src/vnet/l2/l2_rw.c line 499 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_rw.c#L499>`_

Implementation: ``l2_rw_interface_cli_fn``


set interface l2 tag-rewrite
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 tag-rewrite <interface> [disable | pop {1|2} | push {dot1q|dot1ad} <tag> <tag>]



VLAN tag rewrite provides the ability to change the VLAN tags on a packet.
Existing tags can be popped, new tags can be pushed, and existing tags can
be swapped with new tags. The rewrite feature is attached to a subinterface
as input and output operations. The input operation is explicitly configured.
The output operation is the symmetric opposite and is automatically derived
from the input operation.

**POP:** For pop operations, the subinterface encapsulation (the vlan
tags specified when it was created) must have at least the number of popped
tags. e.g. the \"pop 2\" operation would be rejected on a single-vlan interface.
The output tag-rewrite operation for pops is to push the specified number of
vlan tags onto the packet. The pushed tag values are the ones in the
subinterface encapsulation.

**PUSH:** For push operations, the ethertype is also specified. The
output tag-rewrite operation for pushes is to pop the same number of tags
off the packet. If the packet doesn't have enough tags it is dropped.


By default a subinterface has no tag-rewrite. To return a subinterface to
this state use:


.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 disable



To pop vlan tags off packets received from a subinterface, use:


.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 pop 1




.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 pop 2



To push one or two vlan tags onto packets received from an interface, use:


.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 push dot1q 100




.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 push dot1ad 100 150



Tags can also be translated, which is basically a combination of a pop and push.


.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 translate 1-1 dot1ad 100




.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 translate 2-2 dot1ad 100 150




.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 translate 1-2 dot1q 100




.. code-block:: console

    set interface l2 tag-rewrite GigabitEthernet0/8/0.200 translate 2-1 dot1q 100 150



To display the VLAN Tag settings, show the associate bridge-domain:


.. code-block:: console

    show bridge-domain 200 detail
    
     ID   Index   Learning   U-Forwrd   UU-Flood   Flooding   ARP-Term     BVI-Intf
    200     1        on         on         on         on         off          N/A
    
             Interface           Index  SHG  BVI        VLAN-Tag-Rewrite
     GigabitEthernet0/8/0.200      5     0    -       trans-1-1 dot1ad 100
     GigabitEthernet0/9/0.200      4     0    -               none
     GigabitEthernet0/a/0.200      6     0    -               none
    




Declaration: ``int_l2_vtr_cli`` `src/vnet/l2/l2_vtr.c line 673 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_vtr.c#L673>`_

Implementation: ``int_l2_vtr``


set interface l2 xconnect
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 xconnect <interface> <peer interface>



Use this command put an interface into Layer 2 cross-connect mode.
Both interfaces must be in this mode for bi-directional traffic. All
packets received on one interface will be transmitted to the other.
To remove the Layer 2 cross-connect, put the interface in a different
mode, for example Layer 3 mode.

Example of how to configure a Layer2 cross-connect between two interfaces:


.. code-block:: console

    set interface l2 xconnect GigabitEthernet0/8/0.300 GigabitEthernet0/9/0.300




.. code-block:: console

    set interface l2 xconnect GigabitEthernet0/9/0.300 GigabitEthernet0/8/0.300


Example of how to remove a Layer2 cross-connect:


.. code-block:: console

    set interface l3 GigabitEthernet0/8/0.300




.. code-block:: console

    set interface l3 GigabitEthernet0/9/0.300



Declaration: ``int_l2_xc_cli`` `src/vnet/l2/l2_input.c line 713 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_input.c#L713>`_

Implementation: ``int_l2_xc``


set interface l2 xcrw
-------------------------------------------------------------------------

.. code-block:: console

    set interface l2 xcrw <interface> next <node-name>
        [del] [tx-fib-id <id>] [ipv6] rw <hex-bytes>



Add or delete a Layer 2 to Layer 3 rewrite cross-connect. This is
used to hook Layer 2 interface(s) up to the Layer 3 stack in
arbitrary ways. For example, cross-connect an L2 interface or
(future) bridge to an mpls-o-gre tunnel. Set up the L2 rewrite
string as shown in mpls_gre_rewrite, and use \"mpls-post-rewrite\"
to fix the GRE IP header checksum and length fields.


practical example.

Declaration: ``set_l2_xcrw_command`` `src/vnet/l2/l2_xcrw.c line 495 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_xcrw.c#L495>`_

Implementation: ``set_l2_xcrw_command_fn``


set l2fib scan-delay
-------------------------------------------------------------------------

.. code-block:: console

    set l2fib scan-delay <delay>



This command set scan delay (in 1/10s unit)

Declaration: ``l2fib_set_scan_delay_cli`` `src/vnet/l2/l2_fib.c line 857 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L857>`_

Implementation: ``l2fib_set_scan_delay``


show bridge-domain
-------------------------------------------------------------------------

.. code-block:: console

    show bridge-domain [bridge-domain-id [detail|int|arp|bd-tag]]



Show a summary of all the bridge-domain instances or detailed view of a
single bridge-domain. Bridge-domains are created by adding an interface
to a bridge using the ``set interface l2 bridge`` command.

Example of displaying all bridge-domains:


.. code-block:: console

    show bridge-domain
    
     ID   Index   Learning   U-Forwrd   UU-Flood   Flooding   ARP-Term     BVI-Intf
     0      0        off        off        off        off        off        local0
    200     1        on         on         on         on         off          N/A
    



Example of displaying details of a single bridge-domains:


.. code-block:: console

    show bridge-domain 200 detail
    
     ID   Index   Learning   U-Forwrd   UU-Flood   Flooding   ARP-Term     BVI-Intf
    200     1        on         on         on         on         off          N/A
    
             Interface           Index  SHG  BVI        VLAN-Tag-Rewrite
     GigabitEthernet0/8/0.200      3     0    -               none
     GigabitEthernet0/9/0.200      4     0    -               none
    




Declaration: ``bd_show_cli`` `src/vnet/l2/l2_bd.c line 1332 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_bd.c#L1332>`_

Implementation: ``bd_show``


show l2 rewrite entries
-------------------------------------------------------------------------

.. code-block:: console

    show l2 rewrite entries



This command displays all l2 rewrite entries.

Example of how to display all l2 rewrite entries:


.. code-block:: console

    show l2 rewrite entries
    
    0 -  mask:ffffffffffff00000000000000000000
    value:aabbccddeeff00000000000000000000
       hits:0 skip_bytes:0
    



Declaration: ``l2_rw_show_entries_cli`` `src/vnet/l2/l2_rw.c line 564 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_rw.c#L564>`_

Implementation: ``l2_rw_show_entries_cli_fn``


show l2 rewrite interfaces
-------------------------------------------------------------------------

.. code-block:: console

    show l2 rewrite interfaces



This command displays the l2 rewrite entries of the interfaces.

Example of how to display the l2 rewrite rules on the interface:


.. code-block:: console

    show l2 rewrite interfaces
    
    sw_if_index:4 table-index:0 miss-index:0
    



Declaration: ``l2_rw_show_interfaces_cli`` `src/vnet/l2/l2_rw.c line 531 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_rw.c#L531>`_

Implementation: ``l2_rw_show_interfaces_cli_fn``


show l2fib
-------------------------------------------------------------------------

.. code-block:: console

    show l2fib [all] | [bd_id <nn> | bd_index <nn>] [learn | add] | [raw]



This command displays the MAC Address entries of the L2 FIB table.
Output can be filtered to just get the number of MAC Addresses or display
each MAC Address for all bridge domains or just a single bridge domain.

Example of how to display the number of MAC Address entries in the L2
FIB table:


.. code-block:: console

    show l2fib
    
    3 l2fib entries
    


Example of how to display all the MAC Address entries in the L2
FIB table:


.. code-block:: console

    show l2fib all
    
        Mac Address     BD Idx           Interface           Index  static  filter  bvi  refresh  timestamp
     52:54:00:53:18:33    1      GigabitEthernet0/8/0.200      3       0       0     0      0         0
     52:54:00:53:18:55    1      GigabitEthernet0/8/0.200      3       1       0     0      0         0
     52:54:00:53:18:77    1                 N/A                -1      1       1     0      0         0
    3 l2fib entries
    



Declaration: ``show_l2fib_cli`` `src/vnet/l2/l2_fib.c line 355 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L355>`_

Implementation: ``show_l2fib``


show l2patch
-------------------------------------------------------------------------

.. code-block:: console

    Show l2 interface cross-connect entries



Show Layer 2 patch entries.



.. code-block:: console

    show l2patch
    
    



practical example.

Declaration: ``show_l2patch_cli`` `src/vnet/l2/l2_patch.c line 424 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_patch.c#L424>`_

Implementation: ``show_l2patch``


show l2xcrw
-------------------------------------------------------------------------

.. code-block:: console

    show l2xcrw



Display a Layer 2 to Layer 3 rewrite cross-connect. This is used to
hook Layer 2 interface(s) up to the Layer 3 stack in arbitrary ways.


practical example.

Declaration: ``show_l2xcrw_command`` `src/vnet/l2/l2_xcrw.c line 580 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_xcrw.c#L580>`_

Implementation: ``show_l2xcrw_command_fn``


show mode
-------------------------------------------------------------------------

.. code-block:: console

    show mode [<if-name1> <if-name2> ...]



Modify the packet processing mode of the interface to Layer 3, which
implies packets will be routed. This is the default mode of an interface.
Use this command to remove an interface from a Layer 2 cross-connect or a
Layer 2 bridge.

Example of how to set the mode of an interface to Layer 3:


.. code-block:: console

    set interface l3 GigabitEthernet0/8/0.200



Show the packet processing mode (Layer2 cross-connect, Layer 2 bridge,
Layer 3 routed) of all interfaces and sub-interfaces, or limit the
output to just the provided list of interfaces and sub-interfaces.
The output shows the mode, the interface, and if the interface is
a member of a bridge, the bridge-domain-id and the split horizon group (shg).

Example of displaying the mode of all interfaces:


.. code-block:: console

    show mode
    
    l3 local0
    l3 GigabitEthernet0/8/0
    l3 GigabitEthernet0/9/0
    l3 GigabitEthernet0/a/0
    l2 bridge GigabitEthernet0/8/0.200 bd_id 200 shg 0
    l2 bridge GigabitEthernet0/9/0.200 bd_id 200 shg 0
    l2 bridge GigabitEthernet0/a/0.200 bd_id 200 shg 0
    l2 xconnect GigabitEthernet0/8/0.300 GigabitEthernet0/9/0.300
    l2 xconnect GigabitEthernet0/9/0.300 GigabitEthernet0/8/0.300
    


Example of displaying the mode of a selected list of interfaces:


.. code-block:: console

    show mode GigabitEthernet0/8/0 GigabitEthernet0/8/0.200
    
    l3 GigabitEthernet0/8/0
    l2 bridge GigabitEthernet0/8/0.200 bd_id 200 shg 0
    



Declaration: ``show_l2_mode`` `src/vnet/l2/l2_input.c line 873 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_input.c#L873>`_

Implementation: ``show_int_mode``


test l2fib
-------------------------------------------------------------------------

.. code-block:: console

    test l2fib [add|del|check] mac <base-addr> count <nn>



The set of ``test l2fib`` commands allow the L2 FIB table of the default
bridge domain (bridge-domain-id of 0) to be modified.

Example of how to add a set of 4 sequential MAC Address entries to L2
FIB table of the default bridge-domain:


.. code-block:: console

    test l2fib add mac 52:54:00:53:00:00 count 4



Show the set of 4 sequential MAC Address entries that were added:


.. code-block:: console

    show l2fib verbose
    
        Mac Address     BD Idx           Interface           Index  static  filter  bvi  refresh  timestamp
    52:54:00:53:00:00    0       GigabitEthernet0/8/0.300     8       0       0     0      0         0
    52:54:00:53:00:01    0       GigabitEthernet0/8/0.300     8       0       0     0      0         0
    52:54:00:53:00:03    0       GigabitEthernet0/8/0.300     8       0       0     0      0         0
    52:54:00:53:00:02    0       GigabitEthernet0/8/0.300     8       0       0     0      0         0
    4 l2fib entries
    



Example of how to check that the set of 4 sequential MAC Address
entries were added to L2 FIB table of the default
bridge-domain. Used a count of 5 to produce an error:



.. code-block:: console

    test l2fib check mac 52:54:00:53:00:00 count 5


The output of the check command is in the log files. Log file
location may vary based on your OS and Version:

``# tail -f /var/log/messages | grep l2fib_test_command_fn``

Sep  7 17:15:24 localhost vnet[4952]: l2fib_test_command_fn:446: key 52:54:00:53:00:04 AWOL

Example of how to delete a set of 4 sequential MAC Address entries
from L2 FIB table of the default bridge-domain:


.. code-block:: console

    test l2fib del mac 52:54:00:53:00:00 count 4




Declaration: ``l2fib_test_command`` `src/vnet/l2/l2_fib.c line 720 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_fib.c#L720>`_

Implementation: ``l2fib_test_command_fn``


test l2patch
-------------------------------------------------------------------------

.. code-block:: console

    test l2patch rx <intfc> tx <intfc> [del]



Create or delete a Layer 2 patch.



.. code-block:: console

    test l2patch rx <intfc> tx <intfc> [del]
    
    



practical example.

Declaration: ``test_patch_command`` `src/vnet/l2/l2_patch.c line 374 <https://github.com/FDio/vpp/blob/master//src/vnet/l2/l2_patch.c#L374>`_

Implementation: ``test_patch_command_fn``