aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rwxr-xr-xinit39
1 files changed, 28 insertions, 11 deletions
diff --git a/init b/init
index 672c9f1..d84e0bb 100755
--- a/init
+++ b/init
@@ -84,7 +84,7 @@ sensors-detect --auto
#
# First we separete quoted variables and arguments with newlines (giving
# priority to assignments). Then we replace whitespaces with newline on
-# lines that don't contain quites. Finally, clean up by removing blank
+# lines that don't contain quotes. Finally, clean up by removing blank
# lines.
#
# Note: the same code as in buildos.
@@ -196,10 +196,18 @@ if [ -z "$eth" ]; then
error
fi
-mac="$(cat "/sys/class/net/$eth/address")"
-mid="$(sed -e 's/://g' <<<"$mac")" # Machine id.
+# Global and local MAC addresses (used below for br0 and br1, respectively).
+# Derive the local address from the global by fixing the first octet to 02
+# (locally-assigned).
+#
+gmac="$(cat "/sys/class/net/$eth/address")"
+lmac="$(sed -re 's/..:(.+)/02:\1/g' <<<"$gmac")"
+
+info "configured $eth ($gmac)"
-info "configured $eth ($mac)"
+# Machine id.
+#
+mid="$(sed -re 's/://g' <<<"$gmac")"
# Set the hostname.
#
@@ -219,12 +227,17 @@ info "hostname $hname"
#
dhclient -x 2>/dev/null
-# @@ Need to be made configurable.
+# @@ Needs to be made configurable. Something like 172.23.0.0/16.
#
-priv_network="172.16.123.0"
-priv_netmask="255.255.255.0"
-priv_netbase="$(sed -e 's/^\(.*\)\.0$/\1/' <<<"$priv_network")"
+priv_network="172.23.0.0"
+priv_netmask="255.255.0.0"
+priv_netbase="$(sed -e 's/^\(.*\)\.0\.0$/\1/' <<<"$priv_network")"
+# Note that if we don't assign the bridge MAC address, then it will keep
+# changing every time an interface with a greater address (e.g., a tap)
+# joins the bridge. Needless to say, constantly changing MAC will wreck
+# all kinds of networking havoc.
+#
cat <<EOF >/etc/network/interfaces
auto lo
iface lo inet loopback
@@ -237,18 +250,22 @@ iface br0 inet dhcp
bridge_stp off
bridge_maxwait 0
bridge_fd 0
- bridge_hw $mac
+ bridge_hw $gmac
+ post-up ip link set $eth txqueuelen 4000
+ post-up ip link set br0 txqueuelen 4000
# Private bridge with NAT to br0.
#
auto br1
iface br1 inet static
- address ${priv_netbase}.1
+ address ${priv_netbase}.0.1
netmask $priv_netmask
bridge_ports none
bridge_stp off
bridge_maxwait 0
bridge_fd 0
+ bridge_hw $lmac
+ post-up ip link set br1 txqueuelen 4000
post-up iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
post-up iptables -A FORWARD -i br0 -o br1 -m state --state RELATED,ESTABLISHED -j ACCEPT
post-up iptables -A FORWARD -i br1 -o br0 -j ACCEPT
@@ -257,7 +274,7 @@ EOF
cat <<EOF >/etc/dnsmasq.d/br1-dhcp
interface=br1
bind-interfaces
-dhcp-range=${priv_netbase}.10,${priv_netbase}.250,12h
+dhcp-range=${priv_netbase}.1.1,${priv_netbase}.255.255,$priv_netmask,2h
EOF
# Figure out disk configuration and generate the corresponding /etc/fstab.