SDN in BASH
Using BASH to manage Bridged VLANs on Debian.
Script to manage VLANS, https://github.com/lathama/bridged-vlan-debian-script
possibly out of date
#!/bin/bash clear addvlanbridge () { clear echo echo "What interface to use? [eth0]" read interface if [[ -z ${interface} ]]; then interface="eth0" fi echo "The interface you selected is: $interface" echo -e "Please type the VLAN ID number you want to add as a bridged device: \c " read vlan echo "The VLAN ID you entered is: $vlan" vconfig set_name_type VLAN_PLUS_VID_NO_PAD vconfig add $interface $vlan brctl addbr brvlan$vlan brctl addif brvlan$vlan vlan$vlan ifconfig vlan$vlan up ifconfig brvlan$vlan up echo "You need to add some entries to the /etc/network/interfaces file" echo echo " auto vlan$vlan iface vlan$vlan inet manual vlan_raw_device $interface up ifconfig \$IFACE up" echo " auto brvlan$vlan iface brvlan$vlan inet manual bridge_ports vlan$vlan up ifconfig \$IFACE up" echo echo "Press enter to return" read back } removebridgevlan () { clear echo echo "What VLAN to remove?" read vlan echo "You selected $vlan" ifconfig brvlan$vlan down brctl delif brvlan$vlan vlan$vlan brctl delbr brvlan$vlan ifconfig vlan$vlan down vconfig rem vlan$vlan echo echo "Warning: You need to clean up the /etc/network/interfaces file!" echo echo "Press enter to return" read back } showvlan () { clear echo echo "Look at the VLANs" echo echo cat /proc/net/vlan/config echo echo "Press enter to return" read back } showbridge () { clear echo echo "Look at the bridges" echo echo brctl show echo echo "Press enter to return" read back } while : # Loop forever do clear cat << ! 1. Add VLAN and Bridge 2. Remove Bridge and VLAN 3. Show current VLAN config 4. Show current Bridge config 5. Exit ! echo -n " Your choice? : " read choice case $choice in 1) addvlanbridge ;; 2) removebridgevlan ;; 3) showvlan ;; 4) showbridge ;; 5) exit ;; *) echo "\"$choice\" is not valid "; sleep 2 ;; esac done
Sponsorship and Advertising space here. Please contact me if interested.