John DeNisco | c8e7f41 | 2018-08-03 11:02:24 -0400 | [diff] [blame^] | 1 | .. _interface: |
| 2 | |
| 3 | .. toctree:: |
| 4 | |
| 5 | Interface |
| 6 | ========= |
| 7 | |
| 8 | VPP command learned in this exercise |
| 9 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 10 | #. `create host-interface <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_devices_af_packet.html#clicmd_create_host-interface>`_ |
| 11 | #. `set int state <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_set_interface_state>`_ |
| 12 | #. `set int ip address <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_set_interface_ip_address>`_ |
| 13 | #. `show hardware <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_show_hardware-interfaces>`_ |
| 14 | #. `show int <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_show_interfaces>`_ |
| 15 | #. `show int addr <https://docs.fd.io/vpp/17.04/clicmd_src_vnet.html#clicmd_show_interfaces>`_ |
| 16 | #. `trace add <https://docs.fd.io/vpp/17.04/clicmd_src_vlib.html#clicmd_trace_add>`_ |
| 17 | #. `clear trace <https://docs.fd.io/vpp/17.04/clicmd_src_vlib.html#clicmd_clear_trace>`_ |
| 18 | #. `ping <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ip.html#clicmd_ping>`_ |
| 19 | #. `show ip arp <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_ethernet.html#clicmd_show_ip_arp>`_ |
| 20 | #. `show ip fib <https://docs.fd.io/vpp/17.04/clicmd_src_vnet_fib.html#clicmd_show_ip_fib>`_ |
| 21 | |
| 22 | Topology |
| 23 | ~~~~~~~~ |
| 24 | |
| 25 | .. figure:: /_images/Create_Interface_Topology.jpg |
| 26 | :alt: Figure: Create Interface Topology |
| 27 | |
| 28 | Figure: Create Interface Topology |
| 29 | |
| 30 | Initial State |
| 31 | ~~~~~~~~~~~~~ |
| 32 | |
| 33 | The initial state here is presumed to be the final state from the |
| 34 | exercise `VPP Basics <VPP/Progressive_VPP_Tutorial#Exercise:_vpp_basics>`__ |
| 35 | |
| 36 | Create veth interfaces on host |
| 37 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 38 | |
| 39 | In Linux, there is a type of interface call 'veth'. Think of a 'veth' |
| 40 | interface as being an interface that has two ends to it (rather than |
| 41 | one). |
| 42 | |
| 43 | Create a veth interface with one end named **vpp1out** and the other |
| 44 | named **vpp1host** |
| 45 | |
| 46 | .. code-block:: console |
| 47 | |
| 48 | $ sudo ip link add name vpp1out type veth peer name vpp1host |
| 49 | |
| 50 | Turn up both ends: |
| 51 | |
| 52 | .. code-block:: console |
| 53 | |
| 54 | $ sudo ip link set dev vpp1out up |
| 55 | $ sudo ip link set dev vpp1host up |
| 56 | |
| 57 | Assign an IP address |
| 58 | ~~~~~~~~~~~~~~~~~~~~ |
| 59 | |
| 60 | .. code-block:: console |
| 61 | |
| 62 | $ sudo ip addr add 10.10.1.1/24 dev vpp1host |
| 63 | |
| 64 | Display the result: |
| 65 | |
| 66 | .. code-block:: console |
| 67 | |
| 68 | $ sudo ip addr show vpp1host |
| 69 | 5: vpp1host@vpp1out: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 |
| 70 | link/ether e2:0f:1e:59:ec:f7 brd ff:ff:ff:ff:ff:ff |
| 71 | inet 10.10.1.1/24 scope global vpp1host |
| 72 | valid_lft forever preferred_lft forever |
| 73 | inet6 fe80::e00f:1eff:fe59:ecf7/64 scope link |
| 74 | valid_lft forever preferred_lft forever |
| 75 | |
| 76 | Create vpp host-interface |
| 77 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 78 | |
| 79 | Create a host interface attached to **vpp1out**. |
| 80 | |
| 81 | .. code-block:: console |
| 82 | |
| 83 | vpp# create host-interface name vpp1out |
| 84 | host-vpp1out |
| 85 | |
| 86 | Confirm the interface: |
| 87 | |
| 88 | .. code-block:: console |
| 89 | |
| 90 | vpp# show hardware |
| 91 | Name Idx Link Hardware |
| 92 | host-vpp1out 1 up host-vpp1out |
| 93 | Ethernet address 02:fe:d9:75:d5:b4 |
| 94 | Linux PACKET socket interface |
| 95 | local0 0 down local0 |
| 96 | local |
| 97 | |
| 98 | Turn up the interface: |
| 99 | |
| 100 | .. code-block:: console |
| 101 | |
| 102 | vpp# set int state host-vpp1out up |
| 103 | |
| 104 | Confirm the interface is up: |
| 105 | |
| 106 | .. code-block:: console |
| 107 | |
| 108 | vpp# show int |
| 109 | Name Idx State MTU (L3/IP4/IP6/MPLS) Counter Count |
| 110 | host-vpp1out 1 up 9000/0/0/0 |
| 111 | local0 0 down 0/0/0/0 |
| 112 | |
| 113 | Assign ip address 10.10.1.2/24 |
| 114 | |
| 115 | .. code-block:: console |
| 116 | |
| 117 | vpp# set int ip address host-vpp1out 10.10.1.2/24 |
| 118 | |
| 119 | Confirm the ip address is assigned: |
| 120 | |
| 121 | .. code-block:: console |
| 122 | |
| 123 | vpp# show int addr |
| 124 | host-vpp1out (up): |
| 125 | L3 10.10.1.2/24 |
| 126 | local0 (dn): |