John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 1 | .. _interface: |
| 2 | |
| 3 | .. toctree:: |
| 4 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 5 | Creating an Interface |
| 6 | ====================== |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 7 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 8 | Skills 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 | |
| 16 | VPP commands learned in this exercise |
| 17 | -------------------------------------- |
| 18 | |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 19 | #. `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 Kerhor | 950d33e | 2021-02-11 03:02:44 -0800 | [diff] [blame] | 28 | #. `show ip neighbors <https://docs.fd.io/vpp/21.06/db/dba/clicmd_src_vnet_ip-neighbor.html#clicmd_show_ip_neighbors>`_ |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 29 | #. `show ip fib <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_fib.html#clicmd_show_ip_fib>`_ |
| 30 | |
| 31 | Topology |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 32 | --------- |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 33 | |
| 34 | .. figure:: /_images/Create_Interface_Topology.jpg |
| 35 | :alt: Figure: Create Interface Topology |
| 36 | |
| 37 | Figure: Create Interface Topology |
| 38 | |
| 39 | Initial State |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 40 | -------------- |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 41 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 42 | The initial state here is presumed to be the final state from the previous sections |
| 43 | of the tutorial. |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 44 | |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 45 | Create veth interfaces on host |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 46 | ------------------------------- |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 47 | |
| 48 | In Linux, there is a type of interface call 'veth'. Think of a 'veth' |
| 49 | interface as being an interface that has two ends to it (rather than |
| 50 | one). |
| 51 | |
| 52 | Create a veth interface with one end named **vpp1out** and the other |
| 53 | named **vpp1host** |
| 54 | |
| 55 | .. code-block:: console |
| 56 | |
| 57 | $ sudo ip link add name vpp1out type veth peer name vpp1host |
| 58 | |
| 59 | Turn 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 | |
| 66 | Assign an IP address |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 67 | --------------------- |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 68 | |
| 69 | .. code-block:: console |
| 70 | |
| 71 | $ sudo ip addr add 10.10.1.1/24 dev vpp1host |
| 72 | |
| 73 | Display the result: |
| 74 | |
| 75 | .. code-block:: console |
| 76 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 77 | $ ip addr show vpp1host |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 78 | 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 | |
| 85 | Create vpp host-interface |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 86 | -------------------------- |
| 87 | |
| 88 | Make 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 | |
| 97 | These commands are run from the vpp shell. Enter the VPP shell with the following |
| 98 | command: |
| 99 | |
| 100 | .. code-block:: console |
| 101 | |
| 102 | $ sudo vppctl -s /run/vpp/cli-vpp1.sock |
| 103 | _______ _ _ _____ ___ |
| 104 | __/ __/ _ \ (_)__ | | / / _ \/ _ \ |
| 105 | _/ _// // / / / _ \ | |/ / ___/ ___/ |
| 106 | /_/ /____(_)_/\___/ |___/_/ /_/ |
Nathan Skrzypczak | 9ad39c0 | 2021-08-19 11:38:06 +0200 | [diff] [blame] | 107 | |
John DeNisco | c4c72d2 | 2018-08-16 13:50:02 -0400 | [diff] [blame] | 108 | vpp# |
John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame] | 109 | |
| 110 | Create a host interface attached to **vpp1out**. |
| 111 | |
| 112 | .. code-block:: console |
| 113 | |
| 114 | vpp# create host-interface name vpp1out |
| 115 | host-vpp1out |
| 116 | |
| 117 | Confirm 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 | |
| 129 | Turn up the interface: |
| 130 | |
| 131 | .. code-block:: console |
| 132 | |
| 133 | vpp# set int state host-vpp1out up |
| 134 | |
| 135 | Confirm 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 | |
| 144 | Assign 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 | |
| 150 | Confirm 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): |