diff options
| author | Mitch Riedstra <mitch@riedstra.us> | 2019-03-06 18:58:20 -0500 |
|---|---|---|
| committer | Mitch Riedstra <mitch@riedstra.us> | 2019-03-06 18:58:20 -0500 |
| commit | fc65c2b1fce9aca00658734c287b5e71971e5a5c (patch) | |
| tree | b7e309402f30a6d8fb94f43be64571481e405359 /net/vlan.sh | |
| parent | f69fa3387a1a6f20edd301bda8f9c8cc00cf5aea (diff) | |
| download | dotfiles-fc65c2b1fce9aca00658734c287b5e71971e5a5c.tar.gz dotfiles-fc65c2b1fce9aca00658734c287b5e71971e5a5c.tar.xz | |
Move the current network script that focus on vlans and copy the file from my workstation.
Diffstat (limited to 'net/vlan.sh')
| -rw-r--r-- | net/vlan.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/net/vlan.sh b/net/vlan.sh new file mode 100644 index 0000000..2ca1f0c --- /dev/null +++ b/net/vlan.sh @@ -0,0 +1,48 @@ +#!/bin/sh +set -e +# A short script to setup the network on a server creating bridges for each +# vlan specified. + +# Why? NetworkManager sucks and so do other network utilities. This is simple +# and fits the need of creating a virtual machine host that can place VMs +# on any one of the vlans. + +defaultrouter="10.9.8.7" +nameservers="10.11.12.13 10.12.14.16" +vlan_ifs="eth0 eth1 eth3" +eth0_vlan_ids="10" +eth0_vlan_10_inet="10.10.1.2/24" +eth1_vlan_ids="20 34 38 60 160 240 432" +eth1_vlan_60_inet="10.60.8.2/24" +eth3_vlan_ids=50 +eth3_vlan_50_inet="10.50.0.1/24" +echo="echo" + +for if in $vlan_ifs ; do + $echo ip link set up $if + eval vlan_ids="\$${if}_vlan_ids" + + for id in $vlan_ids; do + $echo ip link add link $if name ${if}.${id} type vlan id ${id} + $echo brctl addbr vlan${id} + $echo brctl addif vlan${id} ${if}.${id} + $echo ip link set up ${if}.${id} + + eval inet="\$${if}_vlan_${id}_inet" + if ! [ -z "$inet" ] ; then + $echo ip -4 addr add "$inet" dev ${if}.${id}. + fi + done +done + +$echo ip route add default via $defaultrouter + +$echo truncate -s 0 /etc/resolv.conf +for ns in $nameservers ; do + if ! [ -z "$echo" ] ; then + echo echo nameserver $ns '>>' /etc/resolv.conf + else + echo nameserver $ns >> /etc/resolv.conf + fi +done + |
