blob: 7e35ca870f97d34d84434603ec8cc45330c8b372 [file] [log] [blame]
John DeNiscoc8e7f412018-08-03 11:02:24 -04001.. _interface:
2
3.. toctree::
4
John DeNiscoc4c72d22018-08-16 13:50:02 -04005Creating an Interface
6======================
John DeNiscoc8e7f412018-08-03 11:02:24 -04007
John DeNiscoc4c72d22018-08-16 13:50:02 -04008Skills to be Learned
9--------------------
10
11#. Create a veth interface in Linux host
12#. Assign an IP address to one end of the veth interface in the Linux host
13#. Create a vpp host-interface that connected to one end of a veth interface via AF_PACKET
14#. Add an ip address to a vpp interface
15
16VPP commands learned in this exercise
17--------------------------------------
18
John DeNiscoc8e7f412018-08-03 11:02:24 -040019#. `create host-interface <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_devices_af_packet.html#clicmd_create_host-interface>`_
20#. `set int state <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_set_interface_state>`_
21#. `set int ip address <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_set_interface_ip_address>`_
22#. `show hardware <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_show_hardware-interfaces>`_
23#. `show int <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_show_interfaces>`_
24#. `show int addr <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_show_interfaces>`_
25#. `trace add <https://docs.fd.io/vpp/17.04/clicmd_src_vlib.html#clicmd_trace_add>`_
26#. `clear trace <https://docs.fd.io/vpp/17.04/clicmd_src_vlib.html#clicmd_clear_trace>`_
27#. `ping <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_ping>`_
Arthur de Kerhor950d33e2021-02-11 03:02:44 -080028#. `show ip neighbors <https://docs.fd.io/vpp/21.06/db/dba/clicmd_src_vnet_ip-neighbor.html#clicmd_show_ip_neighbors>`_
John DeNiscoc8e7f412018-08-03 11:02:24 -040029#. `show ip fib <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_fib.html#clicmd_show_ip_fib>`_
30
31Topology
John DeNiscoc4c72d22018-08-16 13:50:02 -040032---------
John DeNiscoc8e7f412018-08-03 11:02:24 -040033
34.. figure:: /_images/Create_Interface_Topology.jpg
35 :alt: Figure: Create Interface Topology
36
37 Figure: Create Interface Topology
38
39Initial State
John DeNiscoc4c72d22018-08-16 13:50:02 -040040--------------
John DeNiscoc8e7f412018-08-03 11:02:24 -040041
John DeNiscoc4c72d22018-08-16 13:50:02 -040042The initial state here is presumed to be the final state from the previous sections
43of the tutorial.
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020044
John DeNiscoc8e7f412018-08-03 11:02:24 -040045Create veth interfaces on host
John DeNiscoc4c72d22018-08-16 13:50:02 -040046-------------------------------
John DeNiscoc8e7f412018-08-03 11:02:24 -040047
48In Linux, there is a type of interface call 'veth'. Think of a 'veth'
49interface as being an interface that has two ends to it (rather than
50one).
51
52Create a veth interface with one end named **vpp1out** and the other
53named **vpp1host**
54
55.. code-block:: console
56
57 $ sudo ip link add name vpp1out type veth peer name vpp1host
58
59Turn up both ends:
60
61.. code-block:: console
62
63 $ sudo ip link set dev vpp1out up
64 $ sudo ip link set dev vpp1host up
65
66Assign an IP address
John DeNiscoc4c72d22018-08-16 13:50:02 -040067---------------------
John DeNiscoc8e7f412018-08-03 11:02:24 -040068
69.. code-block:: console
70
71 $ sudo ip addr add 10.10.1.1/24 dev vpp1host
72
73Display the result:
74
75.. code-block:: console
76
John DeNiscoc4c72d22018-08-16 13:50:02 -040077 $ ip addr show vpp1host
John DeNiscoc8e7f412018-08-03 11:02:24 -040078 5: vpp1host@vpp1out: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
79 link/ether e2:0f:1e:59:ec:f7 brd ff:ff:ff:ff:ff:ff
80 inet 10.10.1.1/24 scope global vpp1host
81 valid_lft forever preferred_lft forever
82 inet6 fe80::e00f:1eff:fe59:ecf7/64 scope link
83 valid_lft forever preferred_lft forever
84
85Create vpp host-interface
John DeNiscoc4c72d22018-08-16 13:50:02 -040086--------------------------
87
88Make sure VPP is running, if not start it.
89
90.. code-block:: console
91
92 $ ps -eaf | grep vpp
93 vagrant 2141 903 0 05:28 pts/0 00:00:00 grep --color=auto vpp
94 # vpp is not running, so start it
95 $ sudo /usr/bin/vpp -c startup1.conf
96
97These commands are run from the vpp shell. Enter the VPP shell with the following
98command:
99
100.. code-block:: console
101
102 $ sudo vppctl -s /run/vpp/cli-vpp1.sock
103 _______ _ _ _____ ___
104 __/ __/ _ \ (_)__ | | / / _ \/ _ \
105 _/ _// // / / / _ \ | |/ / ___/ ___/
106 /_/ /____(_)_/\___/ |___/_/ /_/
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200107
John DeNiscoc4c72d22018-08-16 13:50:02 -0400108 vpp#
John DeNiscoc8e7f412018-08-03 11:02:24 -0400109
110Create a host interface attached to **vpp1out**.
111
112.. code-block:: console
113
114 vpp# create host-interface name vpp1out
115 host-vpp1out
116
117Confirm the interface:
118
119.. code-block:: console
120
121 vpp# show hardware
122 Name Idx Link Hardware
123 host-vpp1out 1 up host-vpp1out
124 Ethernet address 02:fe:d9:75:d5:b4
125 Linux PACKET socket interface
126 local0 0 down local0
127 local
128
129Turn up the interface:
130
131.. code-block:: console
132
133 vpp# set int state host-vpp1out up
134
135Confirm the interface is up:
136
137.. code-block:: console
138
139 vpp# show int
140 Name Idx State MTU (L3/IP4/IP6/MPLS) Counter Count
141 host-vpp1out 1 up 9000/0/0/0
142 local0 0 down 0/0/0/0
143
144Assign ip address 10.10.1.2/24
145
146.. code-block:: console
147
148 vpp# set int ip address host-vpp1out 10.10.1.2/24
149
150Confirm the ip address is assigned:
151
152.. code-block:: console
153
154 vpp# show int addr
155 host-vpp1out (up):
156 L3 10.10.1.2/24
157 local0 (dn):