Building an SDN Network with Ubuntu, OVS, and Docker
Preparations
To build a Software-Defined Network (SDN) using Ubuntu, Open Virtual Switch (OVS), and Docker, you’ll need to prepare your environment. This involves downloading and installing the necessary tools, including VirtualBox and Vagrant on your host machine. If you’re using Windows, we recommend downloading Cmder, a console emulator that will make the next steps easier.
Installing Ubuntu 16.04
First, download Ubuntu 16.04 using the following commands:
$ vagrant box add ubuntu/xenial64$ vagrant init ubuntu/xenial64# vagrant init will automatically generate Vagrantfile
Modifying Vagrantfile
To customize the virtual machine (VM) settings, you’ll need to modify the Vagrantfile. Add the following code to the file:
# Vagrantfile modifications
config.vm.provider "virtualbox" do |vb|
vb.customize ['modifyvm', :id, '--nictype1', 'Am79C973']
vb.customize ['modifyvm', :id, '--nicpromisc1', 'allow-all']
end
This code sets the network card type to Am79C973 and enables promiscuous mode.
Provisioning the VM
To install the necessary tools on the VM, you’ll need to create a bootstrap script. Add the following code to the bootstrap.sh file:
#!/usr/bin/env bash
apt-get update
apt-get install -y vim tree htop git
apt-get install -y openvswitch-switch
# Install docker-engine
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
apt-get update
apt-get install -y docker-engine
# Download ovs-docker shell
wget https://raw.githubusercontent.com/openvswitch/ovs/master/utilities/ovs-docker -P /usr/local/bin
chmod a+rwx /usr/local/bin/ovs-docker
# Download pipework
wget https://raw.githubusercontent.com/jpetazzo/pipework/master/pipework -P /usr/local/bin
chmod a+rwx /usr/local/bin/pipework
Starting the VM
Once you’ve modified the Vagrantfile and created the bootstrap script, you can start the VM using the following command:
$ vagrant up
Wait for the installation process to complete, and then you can access the VM using SSH:
$ vagrant ssh
Conclusion
Building an SDN network using Ubuntu, OVS, and Docker requires careful preparation and configuration. By following the steps outlined in this article, you can create a functional SDN environment that’s perfect for testing and development.