1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
5 | <meta http-equiv="Content-Style-Type" content="text/css" /> |
---|
6 | <meta name="generator" content="pandoc" /> |
---|
7 | <title>SDN / OpenFlow tutorial</title> |
---|
8 | <style type="text/css">code{white-space: pre;}</style> |
---|
9 | <link rel="stylesheet" href="./style.css" type="text/css" /> |
---|
10 | </head> |
---|
11 | <body> |
---|
12 | <div id="header"> |
---|
13 | <h1 class="title">SDN / OpenFlow tutorial</h1> |
---|
14 | <h3 class="date">DataPath Element Config</h3> |
---|
15 | </div> |
---|
16 | <h1 id="introduction">Introduction</h1> |
---|
17 | <p>In this lab we will connect to our datapath element and perform the necessary steps to ensure that it is running Open vSwitch and can connect to our controller.</p> |
---|
18 | <h1 id="goals">Goals</h1> |
---|
19 | <ul> |
---|
20 | <li>Connect to Datapath Element</li> |
---|
21 | <li>Start Open vSwitch</li> |
---|
22 | <li>Connect to Controller</li> |
---|
23 | </ul> |
---|
24 | <h1 id="notes">Notes</h1> |
---|
25 | <ul> |
---|
26 | <li>Commands preceded with "$" imply that you should execute the command as a general user - not as root.</li> |
---|
27 | <li>Commands preceded with "#" imply that you should be working as root.</li> |
---|
28 | <li>Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>") imply that you are executing commands on remote equipment, or within another program.</li> |
---|
29 | </ul> |
---|
30 | <h1 id="installation">Installation</h1> |
---|
31 | <h2 id="installing-telnet">Installing telnet</h2> |
---|
32 | <p>To connect to the datapath element from your controller you will need to install telnet on your VM. Alternatively you can telnet directly from your laptop</p> |
---|
33 | <pre><code>$ sudo apt-get install telnet</code></pre> |
---|
34 | <h2 id="telnet-to-your-datapath-element">Telnet to your datapath element</h2> |
---|
35 | <pre><code>$ telnet 10.10.0.1XX |
---|
36 | Trying 10.10.0.1XX... |
---|
37 | Connected to 10.10.0.1XX. |
---|
38 | Escape character is '^]'. |
---|
39 | === IMPORTANT ============================ |
---|
40 | Use 'passwd' to set your login password |
---|
41 | this will disable telnet and enable SSH |
---|
42 | ------------------------------------------ |
---|
43 | |
---|
44 | |
---|
45 | BusyBox v1.15.3 (2013-12-28 17:47:54 NZDT) built-in shell (ash) |
---|
46 | Enter 'help' for a list of built-in commands. |
---|
47 | |
---|
48 | _______ ________ __ |
---|
49 | | |.-----.-----.-----.| | | |.----.| |_ |
---|
50 | | - || _ | -__| || | | || _|| _| |
---|
51 | |_______|| __|_____|__|__||________||__| |____| |
---|
52 | |__| W I R E L E S S F R E E D O M |
---|
53 | --------------------------------------------------- |
---|
54 | Backfire (10.03.x Snapshot, r33081) |
---|
55 | --------------------------------------------------- |
---|
56 | * 1/3 shot Kahlua In a shot glass, layer Kahlua |
---|
57 | * 1/3 shot Bailey's on the bottom, then Bailey's, |
---|
58 | * 1/3 shot Vodka then Vodka. |
---|
59 | --------------------------------------------------- |
---|
60 | root@SDNX:/# </code></pre> |
---|
61 | <h2 id="creating-a-boot-script">Creating a boot script</h2> |
---|
62 | <p>Change to the root users home directory</p> |
---|
63 | <pre><code># cd</code></pre> |
---|
64 | <p>Start editing the following file</p> |
---|
65 | <pre><code># vi bootovs-rb532.sh</code></pre> |
---|
66 | <p>Enter in the following information being careful to change the top three variables to suit your number in class</p> |
---|
67 | <pre><code>#Setup variables |
---|
68 | #My IP address is required for the ovsdb server. |
---|
69 | MYIP=10.10.0.1XX |
---|
70 | |
---|
71 | # This is the OpenFlow controller ID which we're going to load into the OVS |
---|
72 | CTLIP=10.10.0.X |
---|
73 | |
---|
74 | # This is our DataPath ID |
---|
75 | DPID=00000000000000XX |
---|
76 | |
---|
77 | # This is the name of the bridge that we're going to be creating |
---|
78 | SW=br0 |
---|
79 | |
---|
80 | #What ports are we going to put in the OVS? |
---|
81 | DPPORTS="eth0 eth1" |
---|
82 | |
---|
83 | #Alias some variables |
---|
84 | VSCTL="ovs-vsctl --db=tcp:$MYIP:9999" |
---|
85 | OVSDB=/tmp/ovs-vswitchd.conf.db |
---|
86 | |
---|
87 | # Subroutine to wait until a port is ready |
---|
88 | wait_port_listen() { |
---|
89 | port=$1 |
---|
90 | while ! `netstat -na | grep $port` ; do |
---|
91 | echo -n . |
---|
92 | sleep 1 |
---|
93 | done |
---|
94 | } |
---|
95 | |
---|
96 | # Kill off the servers and remove any stale lockfiles |
---|
97 | /usr/bin/killall ovsdb-server |
---|
98 | /usr/bin/killall ovs-vswitchd |
---|
99 | rm /tmp/.ovs-vswitchd.conf.db.~lock~ |
---|
100 | |
---|
101 | # Remove the OVS Database and then recreate. |
---|
102 | rm -f $OVSDB |
---|
103 | ovsdb-tool create $OVSDB /usr/share/openvswitch/vswitch.ovsschema |
---|
104 | |
---|
105 | # Start the OVSDB server and wait until it starts |
---|
106 | ovsdb-server $OVSDB --remote=ptcp:9999:$MYIP & |
---|
107 | #wait_port_listen 9999 |
---|
108 | sleep 5 |
---|
109 | |
---|
110 | # Start vSwitchd |
---|
111 | ovs-vswitchd tcp:$MYIP:9999 --pidfile=ovs-vswitchd.pid --overwrite-pidfile -- & |
---|
112 | |
---|
113 | # Create the bridge and pass in some configuration options |
---|
114 | $VSCTL add-br $SW -- set bridge $SW datapath_type=netdev |
---|
115 | $VSCTL set bridge $SW datapath_type=netdev |
---|
116 | $VSCTL set bridge $SW protocols=OpenFlow13 |
---|
117 | |
---|
118 | #Cycle through the DataPath ports adding them to the switch |
---|
119 | for i in $DPPORTS ; do |
---|
120 | PORT=$i |
---|
121 | ifconfig $PORT up |
---|
122 | $VSCTL add-port $SW $PORT |
---|
123 | done |
---|
124 | |
---|
125 | #Ensure that the switch has the correct DataPath ID |
---|
126 | $VSCTL set bridge $SW other-config:datapath-id=$DPID |
---|
127 | |
---|
128 | #Configure the switch to have an OpenFlow Controller. This will contact the controller. |
---|
129 | $VSCTL set-controller $SW tcp:$CTLIP:6633</code></pre> |
---|
130 | <p>Make the file executable</p> |
---|
131 | <pre><code># chmod 755 /root/bootovs-rb532.sh</code></pre> |
---|
132 | <p>Edit the startup script to start this by default</p> |
---|
133 | <pre><code># vi /etc/rc.local</code></pre> |
---|
134 | <p>Change the file to look like this.</p> |
---|
135 | <pre><code># Put your custom commands here that should be executed once |
---|
136 | # the system init finished. By default this file does nothing. |
---|
137 | /root/bootovs-rb532.sh |
---|
138 | exit 0</code></pre> |
---|
139 | <h2 id="creating-a-flow-monitor-script">Creating a flow monitor script</h2> |
---|
140 | <p>Start editing the following file</p> |
---|
141 | <pre><code># cd |
---|
142 | # vi monitor_flows.sh</code></pre> |
---|
143 | <p>Put the following information into that file</p> |
---|
144 | <pre><code>#!/bin/ash |
---|
145 | |
---|
146 | clear |
---|
147 | while true |
---|
148 | do |
---|
149 | date |
---|
150 | ovs-ofctl -O OpenFlow13 dump-flows br0 |
---|
151 | sleep 5 |
---|
152 | clear |
---|
153 | done</code></pre> |
---|
154 | <p>Make the file executable</p> |
---|
155 | <pre><code> # chmod 755 /root/monitor_flows.sh</code></pre> |
---|
156 | <h1 id="running-the-bootscript">Running the bootscript</h1> |
---|
157 | <p>Even if the script has been started at boot time it's ok to start it from the command line. The script will kill any existing instances of the daemons.</p> |
---|
158 | <p>Here is an example below</p> |
---|
159 | <pre><code># /root/bootovs-rb532.sh |
---|
160 | 2014-01-28T03:05:18Z|00001|ovsdb_server|INFO|ovsdb-server (Open vSwitch) 2.0.0 |
---|
161 | 2014-01-28T03:05:23Z|00001|reconnect|INFO|tcp:10.10.0.101:9999: connecting... |
---|
162 | 2014-01-28T03:05:23Z|00002|reconnect|INFO|tcp:10.10.0.101:9999: connected |
---|
163 | 2014-01-28T03:05:23Z|00003|bridge|INFO|bridge br0: added interface br0 on port 65534 |
---|
164 | 2014-01-28T03:05:23Z|00004|dpif_linux|ERR|Generic Netlink family 'ovs_datapath' does not exist. The Open vSwitch kernel module is probably not loaded. |
---|
165 | 2014-01-28T03:05:23Z|00005|bridge|INFO|bridge br0: using datapath ID 0000ee25de8f4343 |
---|
166 | 2014-01-28T03:05:23Z|00006|connmgr|INFO|br0: added service controller "punix:/var/run/br0.mgmt" |
---|
167 | 2014-01-28T03:05:23Z|00007|bridge|INFO|ovs-vswitchd (Open vSwitch) 2.0.0 |
---|
168 | 2014-01-28T03:05:24Z|00008|connmgr|INFO|br0: re-added service controller "punix:/var/run/br0.mgmt" |
---|
169 | 2014-01-28T03:05:24Z|00009|bridge|INFO|bridge br0: added interface eth0 on port 1 |
---|
170 | 2014-01-28T03:05:24Z|00010|bridge|INFO|bridge br0: using datapath ID 0000000c42065803 |
---|
171 | 2014-01-28T03:05:25Z|00011|bridge|INFO|bridge br0: added interface eth1 on port 2 |
---|
172 | 2014-01-28T03:05:25Z|00012|bridge|INFO|bridge br0: using datapath ID 0000000000000001 |
---|
173 | 2014-01-28T03:05:25Z|00013|connmgr|INFO|br0: added primary controller "tcp:10.10.0.4:6633" |
---|
174 | 2014-01-28T03:05:25Z|00014|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting... |
---|
175 | 2014-01-28T03:05:26Z|00015|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out |
---|
176 | 2014-01-28T03:05:26Z|00016|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 1 seconds before reconnect |
---|
177 | 2014-01-28T03:05:27Z|00017|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting... |
---|
178 | 2014-01-28T03:05:28Z|00018|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out |
---|
179 | 2014-01-28T03:05:28Z|00019|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 2 seconds before reconnect |
---|
180 | 2014-01-28T03:05:28Z|00002|memory|INFO|1440 kB peak resident set size after 10.2 seconds |
---|
181 | 2014-01-28T03:05:28Z|00003|memory|INFO|cells:200 monitors:1 sessions:1 |
---|
182 | 2014-01-28T03:05:30Z|00020|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting... |
---|
183 | 2014-01-28T03:05:32Z|00021|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection timed out |
---|
184 | 2014-01-28T03:05:32Z|00022|rconn|INFO|br0<->tcp:10.10.0.4:6633: waiting 4 seconds before reconnect |
---|
185 | 2014-01-28T03:05:33Z|00023|memory|INFO|1720 kB peak resident set size after 10.2 seconds |
---|
186 | 2014-01-28T03:05:33Z|00024|memory|INFO|facets:2 ofconns:1 ports:3 rules:10 subfacets:2 |
---|
187 | 2014-01-28T03:05:36Z|00025|rconn|INFO|br0<->tcp:10.10.0.4:6633: connecting... |
---|
188 | 2014-01-28T03:05:39Z|00026|rconn|INFO|br0<->tcp:10.10.0.4:6633: connection failed (No route to host) |
---|
189 | 2014-01-28T03:05:39Z|00027|rconn|INFO|br0<->tcp:10.10.0.4:6633: continuing to retry connections in the background but suppressing further logging |
---|
190 | 2014-01-28T03:05:40Z|00028|fail_open|WARN|Could not connect to controller (or switch failed controller's post-connection admission control policy) for 15 seconds, failing open</code></pre> |
---|
191 | <p>You can see that in this case OVS is trying and failing to contact the OpenFlow controller. We will fix this in a later lab.</p> |
---|
192 | <p>--End</p> |
---|
193 | </body> |
---|
194 | </html> |
---|