From fc65c2b1fce9aca00658734c287b5e71971e5a5c Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Wed, 6 Mar 2019 18:58:20 -0500 Subject: Move the current network script that focus on vlans and copy the file from my workstation. --- net/workstation.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 net/workstation.sh (limited to 'net/workstation.sh') 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 -- cgit v1.2.3