1 ==== How To Create Mac Map In VTN
5 * This page demonstrates Mac Mapping. This demonstration aims at enabling communication between two hosts and denying communication of particular host by associating a Vbridge to the hosts and configuring Mac Mapping (mac address) to the Vbridge.
7 * This page targets Beryllium release, so the procedure described here does not work in other releases.
9 .Single Controller Mapping
10 image::vtn/Single_Controller_Mapping.png["Single_Controller_Mapping",width=500]
14 ====== Configure mininet and create a topology
16 * https://wiki.opendaylight.org/view/OpenDaylight_Virtual_Tenant_Network_(VTN):Scripts:Mininet#Network_with_Multiple_Hosts_for_Service_Function_Chain[Script for emulating network with multiple hosts].
17 * Before executing the mininet script, please confirm Controller is up and running.
18 * Run the mininet script.
19 * Replace <path> and <Controller IP> based on your environment.
22 sudo mn --controller=remote,ip=<Controller IP> --custom <path>\topo_handson.py --topo mytopo2
32 srvc1 srvc1-eth0:s3-eth3 srvc1-eth1:s4-eth3
33 srvc2 srvc2-eth0:s3-eth4 srvc2-eth1:s4-eth4
34 s1 lo: s1-eth1:h11-eth0 s1-eth2:h12-eth0 s1-eth3:s2-eth4 s1-eth4:s3-eth2
35 s2 lo: s2-eth1:h21-eth0 s2-eth2:h22-eth0 s2-eth3:h23-eth0 s2-eth4:s1-eth3 s2-eth5:s4-eth1
36 s3 lo: s3-eth1:s4-eth2 s3-eth2:s1-eth4 s3-eth3:srvc1-eth0 s3-eth4:srvc2-eth0
37 s4 lo: s4-eth1:s2-eth5 s4-eth2:s3-eth1 s4-eth3:srvc1-eth1 s4-eth4:srvc2-eth1
41 You need to manually add flow entries to OpenFlow switches in the Mininet. The flow entries are needed to forward packets to controller when there is a table-miss. This configuration is required only in case of OpenFlow 1.3 or using OVS versions (>2.1.1).
44 sudo ovs-ofctl add-flow s1 priority=0,actions=output:CONTROLLER
45 sudo ovs-ofctl add-flow s2 priority=0,actions=output:CONTROLLER
46 sudo ovs-ofctl add-flow s3 priority=0,actions=output:CONTROLLER
47 sudo ovs-ofctl add-flow s4 priority=0,actions=output:CONTROLLER
52 To create Mac Map in VTN, execute REST API provided by VTN Manager as follows. It uses curl command to call REST API.
54 * Create a virtual tenant named Tenant1 by executing
55 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn.html#update-vtn[the update-vtn RPC].
58 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn:update-vtn -d '{"input":{"tenant-name":"Tenant1"}}'
61 * Create a virtual bridge named vBridge1 in the tenant Tenant1 by executing
62 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-vbridge.html#update-vbridge[the update-vbridge RPC].
65 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-vbridge:update-vbridge -d '{"input":{"tenant-name":"Tenant1","bridge-name":"vBridge1"}}'
68 * Configuring Mac Mappings on the vBridge1 by giving the mac address of host h12 and host h22 as follows to allow the communication by executing
69 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn-mac-map.html#set-mac-map[the set-mac-map RPC].
72 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-mac-map:set-mac-map -d '{"input":{"operation":"SET","allowed-hosts":["de:05:40:c4:96:76@0","62:c5:33:bc:d7:4e@0"],"tenant-name":"Tenant1","bridge-name":"vBridge1"}}'
75 NOTE: Mac Address of host h12 and host h22 can be obtained with the following command in mininet.
79 h12-eth0 Link encap:Ethernet HWaddr 62:c5:33:bc:d7:4e
80 inet addr:10.0.0.2 Bcast:10.255.255.255 Mask:255.0.0.0
81 inet6 addr: fe80::60c5:33ff:febc:d74e/64 Scope:Link
86 h22-eth0 Link encap:Ethernet HWaddr de:05:40:c4:96:76
87 inet addr:10.0.0.4 Bcast:10.255.255.255 Mask:255.0.0.0
88 inet6 addr: fe80::dc05:40ff:fec4:9676/64 Scope:Link
91 * MAC Mapping will not be activated just by configuring it, a two end communication needs to be established to activate Mac Mapping.
93 * Ping host h22 from host h12 in mininet, the ping will not happen between the hosts as only one way activation is enabled.
97 PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
98 From 10.0.0.2 icmp_seq=1 Destination Host Unreachable
99 From 10.0.0.2 icmp_seq=2 Destination Host Unreachable
102 * Ping host h12 from host h22 in mininet, now the ping communication will take place as the two end communication is enabled.
105 mininet> h22 ping h12
106 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
107 64 bytes from 10.0.0.2: icmp_req=1 ttl=64 time=91.8 ms
108 64 bytes from 10.0.0.2: icmp_req=2 ttl=64 time=0.510 ms
111 * After two end communication enabled, now host h12 can ping host h22
114 mininet> h12 ping h22
115 PING 10.0.0.4 (10.0.0.4) 56(84) bytes of data.
116 64 bytes from 10.0.0.4: icmp_req=1 ttl=64 time=0.780 ms
117 64 bytes from 10.0.0.4: icmp_req=2 ttl=64 time=0.079 ms
122 * To view the configured Mac Map of allowed host execute the following command.
125 curl --user "admin":"admin" -H "Content-type: application/json" -X GET http://localhost:8181/restconf/operational/vtn:vtns/vtn/Tenant1/vbridge/vBridge1/mac-map
134 "mac-address": "c6:44:22:ba:3e:72",
136 "port-id": "openflow:1:2"
139 "mac-address": "f6:e0:43:b6:3a:b7",
141 "port-id": "openflow:2:2"
147 "vlan-host-desc-list": [
149 "host": "c6:44:22:ba:3e:72@0"
152 "host": "f6:e0:43:b6:3a:b7@0"
162 When Deny is configured a broadcast message is sent to all the hosts connected to the vBridge, so a two end communication need not be establihed like allow, the hosts can communicate directly without any two way communication enabled.
164 . To Deny host h23 communication from hosts connected on vBridge1, the following configuration can be applied.
167 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn-mac-map:set-mac-map -d '{"input":{"operation": "SET", "denied-hosts": ["0a:d3:ea:3d:8f:a5@0"],"tenant-name": "Tenant1","bridge-name": "vBridge1"}}'
172 * You can delete the virtual tenant Tenant1 by executing
173 https://jenkins.opendaylight.org/releng/view/vtn/job/vtn-merge-beryllium/lastSuccessfulBuild/artifact/manager/model/target/site/models/vtn.html#remove-vtn[the remove-vtn RPC].
176 curl --user "admin":"admin" -H "Content-type: application/json" -X POST http://localhost:8181/restconf/operations/vtn:remove-vtn -d '{"input":{"tenant-name":"Tenant1"}}'