aboutsummaryrefslogtreecommitdiff
path: root/net/workstation.sh
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2019-03-06 18:58:20 -0500
committerMitch Riedstra <mitch@riedstra.us>2019-03-06 18:58:20 -0500
commitfc65c2b1fce9aca00658734c287b5e71971e5a5c (patch)
treeb7e309402f30a6d8fb94f43be64571481e405359 /net/workstation.sh
parentf69fa3387a1a6f20edd301bda8f9c8cc00cf5aea (diff)
downloaddotfiles-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/workstation.sh')
-rw-r--r--net/workstation.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/net/workstation.sh b/net/workstation.sh
new file mode 100644
index 0000000..7639a6e
--- /dev/null
+++ b/net/workstation.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+# net.sh
+# Sets up a bridged network specifically for use on a laptop or workstation.
+# Called by `/etc/rc.local` on my Void Linux machine
+
+bridges="vbr0 br0"
+
+br0_ifs="enp2s0"
+# vbr0_ifs=""
+vbr0_inet="10.33.33.1/24"
+vbr0_inet6="fc00:333::1/64"
+
+assign_inet_for_if() {
+_if="$1" ; shift
+eval _inet="\$${_if}_inet"
+for addr in $_inet ; do
+ ip -4 addr add $addr dev $br
+done
+}
+
+assign_inet6_for_if() {
+_if="$1" ; shift
+eval _inet="\$${_if}_inet6"
+for addr in $_inet ; do
+ ip -6 addr add $addr dev $br
+done
+}
+
+for br in $bridges ; do
+ brctl addbr $br
+ ip link set up "$br"
+
+ eval _ifs="\$${br}_ifs"
+ for _if in $_ifs ; do
+ brctl addif "$br" "$_if"
+ ip link set up "$_if"
+ done
+
+ assign_inet_for_if "${br}"
+ assign_inet6_for_if "${br}"
+done
+
+for _if in $_ifs ; do
+ assign_inet_for_if "$_if"
+ assign_inet6_for_if "$_if"
+
+ ip link set up "$_if"
+done