24519bc1a26c4830424283d1ec152ffe0e83f517
[vpp.git] / docs / reference / cmdreference / interface / subinterface.rst
1 .. _subinterfacecommands:
2
3 .. toctree::
4
5 Create Sub-Interfaces
6 =====================
7 This command is used to add VLAN IDs to interfaces, also known as
8 subinterfaces. The primary input to this command is the '*interface*'
9 and '*subId*' (subinterface Id) parameters. If no additional VLAN ID is
10 provide, the VLAN ID is assumed to be the '*subId*'. The VLAN ID and
11 '*subId*' can be different, but this is not recommended.
12
13 This command has several variations:
14
15 -  **create sub-interfaces <interface> <subId>** - Create a subinterface
16    to process packets with a given 802.1q VLAN ID (same value as the
17    '*subId*').
18 -  **create sub-interfaces <interface> <subId> default** - Adding the
19    '*default*' parameter indicates that packets with VLAN IDs that do
20    not match any other subinterfaces should be sent to this
21    subinterface.
22 -  **create sub-interfaces <interface> <subId> untagged** - Adding the
23    '*untagged*' parameter indicates that packets no VLAN IDs should be
24    sent to this subinterface.
25 -  **create sub-interfaces <interface> <subId>-<subId>** - Create a
26    range of subinterfaces to handle a range of VLAN IDs.
27 -  **create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any
28    [exact-match]** - Use this command to specify the outer VLAN ID, to
29    either be explicited or to make the VLAN ID different from the
30    '*subId*'.
31 -  **create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any
32    inner-dot1q <vlanId>|any [exact-match]** - Use this command to
33    specify the outer VLAN ID and the innner VLAN ID.
34
35 When '*dot1q*' or '*dot1ad*' is explictly entered, subinterfaces can be
36 configured as either exact-match or non-exact match. Non-exact match is
37 the CLI default. If '*exact-match*' is specified, packets must have the
38 same number of VLAN tags as the configuration. For non-exact-match,
39 packets must at least that number of tags. L3 (routed) interfaces must
40 be configured as exact-match. L2 interfaces are typically configured as
41 non-exact-match. If '*dot1q*' or '*dot1ad*' is NOT entered, then the
42 default behavior is exact-match.
43
44 Use the '*show interface*' command to display all subinterfaces.
45
46 Summary/Usage
47 -------------
48
49 .. code-block:: shell
50
51     create sub-interfaces <interface> {<subId> [default|untagged]} | {<subId>-<subId>} | {<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}.
52
53 Examples
54 --------
55
56 Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
57
58 .. code-block:: console
59
60     vpp# create sub-interfaces GigabitEthernet2/0/0 11
61
62 The previous example is shorthand and is equivalent to:
63
64 .. code-block:: console
65
66     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match
67
68 Example of how to create a subinterface number that is different from the VLAN ID:
69
70 .. code-block:: console
71
72     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100
73
74 Examples of how to create q-in-q and q-in-any subinterfaces:
75
76 .. code-block:: console
77
78     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200
79     vpp# create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any
80
81 Examples of how to create dot1ad interfaces:
82
83 .. code-block:: console
84
85     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11
86     vpp# create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200
87
88 Examples of '*exact-match*' versus non-exact match. A packet with outer VLAN 100 and inner VLAN 200 would match this interface, because the default is non-exact match:
89
90 .. code-block:: console
91
92     vpp# create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100
93
94 However, the same packet would NOT match this interface because '*exact-match*' is specified and only one VLAN is configured, but packet contains two VLANs:
95
96 .. code-block:: console
97
98     vpp# create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match
99
100 Example of how to created a subinterface to process untagged packets:
101
102 .. code-block:: console
103
104    vpp# create sub-interfaces GigabitEthernet2/0/0 5 untagged
105
106 Example of how to created a subinterface to process any packet with a VLAN ID that does not match any other subinterface:
107
108 .. code-block:: console
109
110     vpp# create sub-interfaces GigabitEthernet2/0/0 7 default
111
112 When subinterfaces are created, they are in the down state. Example of how to enable a newly created subinterface:
113
114 .. code-block:: console
115
116     vpp# set interface GigabitEthernet2/0/0.7 up
117