docs: add useful debug CLI
[vpp.git] / docs / reference / cmdreference / interface / create_interface.rst
1 .. _interface:
2
3 .. toctree::
4
5 Create Interfaces Commands
6 ===========================
7 This section contains those interface commands that are associated to creating an interface:
8
9 * `Create Host-Interface`_
10 * `Create Interface Memif`_
11 * `Create Loopback Interface`_
12 * `Create Sub-Interfaces`_
13
14 .. note:: For a complete list of CLI Debug commands refer to the Debug CLI section of the `Source Code Documents <https://docs.fd.io/vpp/18.07/clicmd.html>`_ .
15
16 Create Host-Interface
17 ++++++++++++++++++++++
18 Summary/Usage
19 -------------
20
21 create host-interface name <*ifname*> [*hw-addr <*mac-addr*>]
22
23 Description
24 ------------
25
26 Create a host interface that will attach to a linux AF_PACKET interface, one side of a veth pair. The veth pair must already exist. Once created, a new host interface will exist in VPP with the name 'host-<*ifname*>', where '<*ifname*>' is the name of the specified veth pair. Use the `show interface` command to display host interface details.
27
28 This command has the following optional parameters:
29
30     hw-addr <*mac-addr*> - Optional ethernet address, can be in either X:X:X:X:X:X unix or X.X.X cisco format
31
32 Example Usage
33 -------------
34
35     Example of how to create a host interface tied to one side of an existing linux veth pair named vpp1:
36
37         .. code-block:: console
38
39                 vpp# create host-interface name vpp1
40
41                 host-vpp1
42
43     Once the host interface is created, enable the interface using:
44
45         .. code-block:: console
46
47                 vpp# set interface state host-vpp1 up
48
49 Declaration and Implementation
50 -------------------------------
51
52 **Declaration:** af_packet_create_command (src/vnet/devices/af_packet/cli.c line 133)
53
54 **Implementation:** af_packet_create_command_fn
55
56 Create Interface Memif
57 +++++++++++++++++++++++
58
59 Summary/Usage
60 -------------
61
62 create interface memif [id <*id*>] [socket-id <*socket-id*>] [ring-size <*size*>] [buffer-size <*size*>] [hw-addr <*mac-address*>] <master|slave> [rx-queues <*number*>] [tx-queues <*number*>] [mode ip] [secret <*string*>]
63
64 Declaration and Implementation
65 -------------------------------
66
67 **Declaration:** memif_create_command (src/plugins/memif/cli.c line 258)
68
69 **Implementation:** memif_create_command_fn
70
71
72 Create Loopback Interface
73 ++++++++++++++++++++++++++
74
75 Summary/Usage
76 --------------
77
78 create loopback interface [mac <*mac-addr*>] [instance <*instance*>]
79
80 Description
81 ------------
82
83 Create a loopback interface. Optionally, a MAC Address can be provided. If not provided, de:ad:00:00:00:<*loopId*> will be used.
84
85 Example Usage
86 --------------
87     The following two command syntaxes are equivalent:
88
89         .. code-block:: console
90
91                 vpp# loopback create-interface [mac <*mac-addr*>] [instance <*instance*>]
92
93                 vpp# create loopback interface [mac <*mac-addr*>] [instance <*instance*>]
94
95     Example of how to create a loopback interface:
96
97         .. code-block:: console
98
99                 vpp# create loopback interface
100
101 Declaration and Implementation
102 -------------------------------
103
104 **Declaration:** create_loopback_interface_command (src/vnet/ethernet/interface.c line 879)
105
106 **Implementation:** create_simulated_ethernet_interfaces
107
108
109 Create Sub-Interfaces
110 ++++++++++++++++++++++
111
112 This command is used to add VLAN IDs to interfaces, also known as
113 subinterfaces. The primary input to this command is the *interface*
114 and *subId* (subinterface Id) parameters. If no additional VLAN ID is
115 provide, the VLAN ID is assumed to be the *subId*. The VLAN ID and
116 *subId* can be different, but this is not recommended.
117
118 This command has several variations:
119
120 -  **create sub-interfaces** <*interface*> <*subId*> - Create a subinterface
121    to process packets with a given 802.1q VLAN ID (same value as the
122    *subId*).
123 -  **create sub-interfaces** <*interface*> <*subId*> default - Adding the
124    *default* parameter indicates that packets with VLAN IDs that do
125    not match any other subinterfaces should be sent to this
126    subinterface.
127 -  **create sub-interfaces** <*interface*> <*subId*> untagged - Adding the
128    *untagged* parameter indicates that packets no VLAN IDs should be
129    sent to this subinterface.
130 -  **create sub-interfaces** <*interface*> <*subId*>-<*subId*> - Create a
131    range of subinterfaces to handle a range of VLAN IDs.
132 -  **create sub-interfaces** <*interface*> <*subId*> dot1q|dot1ad <*vlanId*>|any
133    [exact-match] - Use this command to specify the outer VLAN ID, to
134    either be explicited or to make the VLAN ID different from the
135    *subId*.
136 -  **create sub-interfaces** <*interface*> <*subId*> dot1q|dot1ad <*vlanId*>|any
137    inner-dot1q <*vlanId*>|any [exact-match] - Use this command to
138    specify the outer VLAN ID and the innner VLAN ID.
139
140 When *dot1q* or *dot1ad* is explictly entered, subinterfaces can be
141 configured as either *exact-match* or *non-exact match*. *Non-exact match* is
142 the CLI default. If *exact-match* is specified, packets must have the
143 same number of VLAN tags as the configuration. For *non-exact-match*,
144 packets must at least that number of tags. L3 (routed) interfaces must
145 be configured as exact-match. L2 interfaces are typically configured as
146 non-exact-match. If *dot1q* or *dot1ad* is NOT entered, then the
147 default behavior is *exact-match*.
148
149 Use the **show interface** command to display all subinterfaces.
150
151 Summary/Usage
152 -------------
153
154 .. code-block:: shell
155
156     create sub-interfaces <interface> {<subId> [default|untagged]} | {<subId>-<subId>} | {<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}
157
158 Example Usage
159 --------------
160
161 Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
162
163 .. code-block:: console
164
165     vpp# create sub-interfaces GigabitEthernet2/0/0 11
166
167 The previous example is shorthand and is equivalent to:
168
169 .. code-block:: console
170
171     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match
172
173 Example of how to create a subinterface number that is different from the VLAN ID:
174
175 .. code-block:: console
176
177     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100
178
179 Examples of how to create q-in-q and q-in-any subinterfaces:
180
181 .. code-block:: console
182
183     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200
184     vpp# create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any
185
186 Examples of how to create dot1ad interfaces:
187
188 .. code-block:: console
189
190     vpp# create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11
191     vpp# create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200
192
193 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:
194
195 .. code-block:: console
196
197     vpp# create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100
198
199 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:
200
201 .. code-block:: console
202
203     vpp# create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match
204
205 Example of how to created a subinterface to process untagged packets:
206
207 .. code-block:: console
208
209    vpp# create sub-interfaces GigabitEthernet2/0/0 5 untagged
210
211 Example of how to created a subinterface to process any packet with a VLAN ID that does not match any other subinterface:
212
213 .. code-block:: console
214
215     vpp# create sub-interfaces GigabitEthernet2/0/0 7 default
216
217 When subinterfaces are created, they are in the down state. Example of how to enable a newly created subinterface:
218
219 .. code-block:: console
220
221     vpp# set interface GigabitEthernet2/0/0.7 up
222