Last active
December 29, 2023 07:00
-
-
Save abhiverma866/c40024fd9245e90d3645922b1ffe22e6 to your computer and use it in GitHub Desktop.
Setting up SDN network using OpenVSwitch (2.17.2) on Raspberry Pi running with Raspbian OS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Download the most recent OpenvSwitch from LTS series [https://www.openvswitch.org/releases/openvswitch-2.17.2.tar.gz] | |
wget http://openvswitch.org/releases/openvswitch-2.17.2.tar.gz | |
tar -xvzf openvswitch-2.17.2.tar.gz | |
cd openvswitch-2.17.2 | |
### Install all dependencies: | |
sudo apt-get install python-simplejson python-qt4 libssl-dev python-twisted-conch automake autoconf gcc uml-utilities libtool build-essential pkg-config | |
### if python-simplejson python-qt4 python-twisted-conch fail to install then manually install them using pip. | |
pip install simplejson | |
pip install python-qt | |
pip install Twisted | |
### Build openvswitch: if fails then try with sudo (root permissions) | |
./configure | |
make -j4 | |
make -j4 install | |
### Set up local variables: | |
cd datapath/linux/ | |
modprobe openvswitch | |
cd ../.. | |
touch /usr/local/etc/ovs-vswitchd.conf | |
mkdir -p /usr/local/etc/openvswitch | |
ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema | |
mkdir -p /usr/local/var/run/openvswitch | |
### Create starting master script: | |
sudo nano /etc/init.d/superscript.sh | |
""" | |
#!/bin/bash | |
ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \ | |
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \ | |
--private-key=db:Open_vSwitch,SSL,private_key \ | |
--certificate=db:Open_vSwitch,SSL,certificate \ | |
--bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \ | |
--pidfile --detach | |
ovs-vsctl --no-wait init | |
ovs-vswitchd --pidfile --detach | |
ovs-vsctl show | |
""" | |
### Start openvswitch service: | |
/etc/init.d/superscript.sh | |
### Set up starting openvswitch on boot: | |
/etc/init.d/superscript | |
sudo chmod 755 /etc/init.d/superscript | |
sudo update-rc.d superscript defaults | |
###Configuring and Starting the Switch | |
###Add a new bridge | |
ovs-vsctl add-br br0 | |
###Connect USB-to-ethernet to the pi. Note their interface names; say it’s eth1, eth2 | |
###Connect the interfaces to the bridge | |
ovs-vsctl add-port br0 eth1 | |
ovs-vsctl add-port br0 eth2 | |
#Turn on the interfaces | |
ifconfig eth1 0 up | |
ifconfig eth2 0 up | |
###Connect the switch to an external controller running on host with IP 10.10.20.20 in this case | |
ovs-vsctl set-controller br0 tcp:10.10.20.20:6633 | |
###The OpenFlow switch is now running and can be checked from top/htop or system resource monitor | |
## Turning on the switch the next time when you reboot | |
### run master script e.g. superscript.sh | |
sudo ./etc/inint.d/superscript.sh | |
###Turn on all the OVS interfaces in each switch (eth1, eth2) | |
### Pro Tips: | |
1. Manually assign IP to host that you connect with USB LAN adapters. Also you may assign IP to eth0 port (Pi's LAN port). | |
2. Try to check connectivity b/w switch-eth0 and controller, and host to host connected on USB LAN adapters. | |
Line 75: sudo ./etc/inint.d/superscript.sh
Do you mean init.d
instead of inint.d
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Noted and corrected the same in [instructions_commands.txt].