In this post we cover the configuration of a testbed that was used at SDNcon 2016, hosted at Victoria University of Wellington. The test beds that were provided comprised of Zodiac FX switches and Raspberry Pi 2's. The diagram below illustrates the topology that was used. The grey box represents a Zodiac FX and the green boxes represent Raspberry Pi 2's.
The configuration of the switches were not changed, however firmware was updated when required. Information on updating the Zodiac FX firmware can be through the User Guide link at http://forums.northboundnetworks.com/index.php?topic=52.0. What we describe below is the configuration of the controller and the network hosts.
Pre-build Information
Use the following checklist before jumping into the build of the testbed.Hardware
- Raspberry Pis for the controller and hosts. Raspberry Pi 2's were used with Raspbian May 2016 (kernel version 4.4) as the OS.
- Zodiac FX with firmware version 0.63 (if you would like to run Faucet) or higher. 0.64 was used for this testbed.
- A USB-to-Ethernet adapter.
- A USB WiFi dongle if the controller device is a Raspberry Pi 2 or earlier.
Skills
- Competent use of the Linux command line (using bash) including a terminal-based text-editor.
- Knowledge of configuring Linux-based hosts for network connectivity via the command line.
- Ability to update the firmware of a Zodiac FX switch and access it via a console connection for debugging purposes.
Controller Configuration
This part of the post describes how to configure the controller. Details on the setup of Raspbian are provided, along with network configuration details. Following this, we go through the installation of the Ryu controller and the Faucet application.
Raspbian Configuration
- Write the Raspbian image to the micro SD card. Insert the card into the Raspberry Pi along with a mouse, keyboard and cable to a monitor. Turn on the device.
- After the Raspberry Pi has booted, a desktop should be presented with the Raspberry Pi logo. Open a terminal and run sudo raspi-config.
- The Raspberry Pi Software Con figuration Tool should be displayed in the terminal, this is the main menu. Select option 1 Expand Filesystem. Select OK in the prompt that follows.
- From the main menu select option 3 Boot Options to change the environment the Raspberry Pi boots into. Select option B1 Console.
- From the main menu select option 5 Internationalisation Options and change the following (note that you will need to navigate back to this menu after each change):
- Set the locale under the option I1 Change Locale. Use the space-bar to add a '*' next to en_NZ.UTF-8 UTF-8. In the Con figuring locales prompt use the up and down arrow keys to highlight en_NZ.UTF-8 and select using enter.
- Set the timezone under the option I2 Change Timezone. Using the up and down arrow keys to navigate and enter to select, select the following: Pacific Ocean, Auckland.
- Set the keyboard layout under the option I3 Change Keyboard Layout. Using the up and down arrow keys to navigate and enter to select, select the following:
- Keyboard model: Generic 105-key (Intl) PC
- Keyboard layout: Other
- Country of origin: English (US)
- Keyboard layout: English (US)
- Key to function as AltGr: The default for the keyboard layout
- Compose key: No compose key
- X server termination with Control+Alt+Backspace: <Yes>.
- Set the Wi-Fi country under the option I4 Change Wi- Country. Using the up and down arrow keys to navigate and enter to select, select NZ New Zealand then <OK> from the following prompt.
- From the main menu select option 9 Advanced Options, then option A2 Hostname. Acknowledge the character restrictions for hostnames by selecting <OK>. In the prompt, change the hostname to controller. Once done, press the down arrow key to select <OK>.
- From the main menu use the left and right arrow keys to select <Finish>, press enter. When presented with a prompt asking if you would like to reboot now select <Yes>. Keep in mind that the hostname can be assigned arbitrarily, the aforementioned hostname was used to match the diagram above.
- Boot the Raspberry Pi and login. Update the packages on the device by running sudo apt-get update followed by sudo apt-get upgrade. Following this, update the firmware by running sudo rpi-update.
Installation of Useful Packages
The lists below contains other useful packages that can be downloaded via apt-get.
General
- git
- python-dev
- python-pip
- tcpdump
- vim
Serial Connections
- cu
- minicom
- screen
Terminal Multiplexers
- screen
- tmux
Configuring the Network Interfaces
Open the file /etc/network/interfaces and edit the entries for eth0, eth1 and wlan0 to match the following.
# OpenFlow control-plane
auto eth0
iface eth0 inet static
address 10.0.1.8
netmask 255.255.255.0
# Gateway for the data-plane
allow-hotplug eth1
iface eth1 inet static
address 172.16.0.254
netmask 255.255.255.0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Open the file /etc/wpa_supplicant/wpa_supplicant.conf to configure the WiFi interface to connect to your network. Below are the necessary details for connecting to an WiFi network using WiFi Protected Access (WPA).
network={
ssid="My network
key_mgmt=WPA-PSK
psk="My password"
}
# OpenFlow control-plane
auto eth0
iface eth0 inet static
address 10.0.1.8
netmask 255.255.255.0
# Gateway for the data-plane
allow-hotplug eth1
iface eth1 inet static
address 172.16.0.254
netmask 255.255.255.0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Open the file /etc/wpa_supplicant/wpa_supplicant.conf to configure the WiFi interface to connect to your network. Below are the necessary details for connecting to an WiFi network using WiFi Protected Access (WPA).
network={
ssid="My network
key_mgmt=WPA-PSK
psk="My password"
}
NAT Configuration
Add the following lines to /etc/rc.local to configure the controller for NAT on boot. Ensure that the last line in the file is exit 0. Note that the controller will need to be restarted for the changes to take effect.
printf "Configuring NAT between interfaces eth1 and wlan0.\n"
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
/sbin/iptables -A FORWARD -i wlan0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i eth1 -o wlan0 -j ACCEPT
printf "NAT configuration complete.\n"
printf "Configuring NAT between interfaces eth1 and wlan0.\n"
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
/sbin/iptables -A FORWARD -i wlan0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i eth1 -o wlan0 -j ACCEPT
printf "NAT configuration complete.\n"
Installing Ryu and Faucet
The below instructions have been adapted from a Blogspot entry made by Josh Bailey (available as of 15/06/2016 from https://faucet-sdn.blogspot.co.nz/2016/06/raucet-raspberry-pi-faucet-controlling.html). The adaptation assumes that the network interfaces were configured as shown in the Configuring the Network Interfaces section of this post.
- Install Faucet's dependencies on the controller from a terminal.
- Install Faucet by cloning the source code from GitHub into the controller's home directory.
- Configure Faucet to use the Zodiac FX switch. Create a directory to store the configuration information in and create a file called faucet.yaml. vi is used as a terminal text-editor in the example below.
pi@controller ~ $ mkdir ~/zodiacfx
pi@controller ~ $ vi ~/zodiacfx/faucet.yaml
Add the following configuration information and pay close attention to the indentation. Note that the value associated with the dp_id item should match the MAC address sticker on the bottom of your Zodiac FX. This is the MAC address associated with the controller switch port. This can also be obtained by connecting to the switch via a console connection and viewing the switch configuration if the sticker is not present. The X's present the hexadecimal digits that most probably need to be changed. - Create a script to start Faucet. vi is used as a terminal text-editor in the example below.
pi@controller ~ $ sudo apt-get install python-pip git libpython-dev python-yaml
pi@controller ~ $ sudo pip install ipaddr
pi@controller ~ $ sudo pip install --upgrade six
pi@controller ~ $ sudo pip install ryu
pi@controller ~ $ cd
pi@controller ~ $ git clone https://github.com/REANNZ/faucet
dp_id: 0x70b3d56cXXXX
name: "zodiac-fx-1"
hardware: "ZodiacFX"
interfaces:
1:
native_vlan: 100
2:
native_vlan: 100
3:
native_vlan: 100
vlans:
100:
name: "100"
pi@controller ~ $ cd
pi@controller ~ $ vi start_faucet.sh
Enter the following into the script.
-
export FAUCET_CONFIG=~/zodiacfx/faucet.yaml
export FAUCET_LOG=~/zodiacfx/faucet.log
export FAUCET_EXCEPTION_LOG=~/zodiacfx/faucet_exception.log
/usr/local/bin/ryu-manager --config-file=~/faucet/src/ryu_faucet/org/onfsdn/faucet/ryu-faucet.conf --ofp-listen-host=10.0.1.8 --ofp-tcp-listen-port=6633 ~/faucet/src/ryu_faucet/org/onfsdn/faucet/faucet.py --verbose
Host Configuration
This part of the post describes how to configure the host devices. Details on the setup of Raspbian are provided, along with network configuration details.
Raspbian Configuration
- Write the Raspbian image to the micro SD card. Insert the card into the Raspberry Pi along with a mouse, keyboard and cable to a monitor. Turn on the device.
- After the Raspberry Pi has booted, a desktop should be presented with the Raspberry Pi logo. Open a terminal and run sudo raspi-config.
- The Raspberry Pi Software Con figuration Tool should be displayed in the terminal, this is the main menu. Select option 1 Expand Filesystem. Select OK in the prompt that follows.
- From the main menu select option 3 Boot Options to change the environment the Raspberry Pi boots into. Select option B1 Console.
- From the main menu select option 5 Internationalisation Options and change the following (note that you will need to navigate back to this menu after each change):
- Set the locale under the option I1 Change Locale. Use the space-bar to add a '*' next to en_NZ.UTF-8 UTF-8. In the Con figuring locales prompt use the up and down arrow keys to highlight en_NZ.UTF-8 and select using enter.
- Set the timezone under the option I2 Change Timezone. Using the up and down arrow keys to navigate and enter to select, select the following: Pacific Ocean, Auckland.
- Set the keyboard layout under the option I3 Change Keyboard Layout. Using the up and down arrow keys to navigate and enter to select, select the following:
- Keyboard model: Generic 105-key (Intl) PC
- Keyboard layout: Other
- Country of origin: English (US)
- Keyboard layout: English (US)
- Key to function as AltGr: The default for the keyboard layout
- Compose key: No compose key
- X server termination with Control+Alt+Backspace: <Yes>.
- Set the Wi-Fi country under the option I4 Change Wi- Country. Using the up and down arrow keys to navigate and enter to select, select NZ New Zealand then <OK> from the following prompt.
- From the main menu select option 9 Advanced Options, then option A2 Hostname. Acknowledge the character restrictions for hostnames by selecting <OK>. In the prompt, change the hostname to hosta for the first host and hostb for the second host. Once done, press the down arrow key to select <OK>. Keep in mind that the hostnames can be assigned arbitrarily, the aforementioned hostnames are used to match the diagram above.
- From the main menu use the left and right arrow keys to select <Finish>, press enter. When presented with a prompt asking if you would like to reboot now select <Yes>.
- Boot the Raspberry Pi and login. Update the packages on the device by running sudo apt-get update followed by sudo apt-get upgrade. Following this, update the firmware by running sudo rpi-update.
Installation of Useful Packages
The lists below contains other useful packages that can be downloaded via apt-get.
General
- git
- libpcap-dev
- python-dev
- python-pip
- tcpdump
- vim
Terminal Multiplexers
- screen
- tmux
Traffic Generators and Manipulators
- d-itg
- iperf
- nmap (nping is included)
- python-scapy
Configuring the Network Interfaces
Open the file /etc/network/interfaces and edit the entry for eth0 to match the following. Note that the X should be set to 101 for hosta and 102 for hostb.
# Host data-plane
auto eth0
iface eth0 inet static
address 172.16.0.X
netmask 255.255.255.0
gateway 172.16.0.254
dns-nameservers 8.8.8.8
# Host data-plane
auto eth0
iface eth0 inet static
address 172.16.0.X
netmask 255.255.255.0
gateway 172.16.0.254
dns-nameservers 8.8.8.8
Bonus: Password-less SSH Connections
As a bonus, here is some information on configuring password-less SSH connections between the hosts. Be sure to note the data-plane IP addresses of each Raspberry Pi and their respective hostnames.- On each host run ssh-keygen -t rsa -b 4096 to generate a private/public key pair for SSH.
- Add the public key of each host (found at ~/.ssh/id_rsa.pub) to the ~/.ssh/authorized_keys file on the other hosts. Each key should be on its own line.
- On each host, add the other hosts to the file ~/.ssh/config in the form bellow.
Host <hostname>
User pi
HostName <Host IP address>