source-directory /etc/network/interfaces.d
EOF
else
- ip=$(getent ahosts $HOSTNAME |grep ^209.*RAW| sed 's/ .*//')
- ip6=$(getent ahosts $HOSTNAME |grep ^2001.*RAW| sed 's/ .*//')
- gateway=209.51.188.1
+ ip6=$(getent ahosts $HOSTNAME |grep ^2001.*RAW| sed 's/ .*//' ||:)
gateway6=2001:470:142::1
- cat > $target/etc/network/interfaces <<EOF
-# The loopback network interface
+
+ # todo: this needs adjustment per machine
+ internal_ip=10.0.0.25/16
+
+ if ip l show dev bond0 &>/dev/null; then
+ cat >$target/etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
-iface eth0 inet static
- address $ip
- gateway $gateway
- netmask 255.255.255.0
+allow-bond eth0
+iface eth0 inet manual
+ bond-master bond0
-iface eth0 inet6 static
- pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_dad
+auto eth1
+allow-bond eth1
+iface eth1 inet manual
+ bond-master bond0
+
+auto bond0
+iface bond0 inet static
+ bond-slaves none
+ bond-mode 0
+ bond-miimon 100
+ address $internal_ip
+ pre-up ip link add link bond0 name macvtap-bond0 type macvtap mode bridge
+# no iptables files exist yet
+# post-up iptables-restore < /etc/default/iptables ; ip6tables-restore < /etc/default/ip6tables || :
+
+auto macvtap-bond0
+iface macvtap-bond0 inet static
+ address $CIDR
+ gateway $GATEWAYS
+ post-up ip a add $internal_ip broadcast 10.0.255.255 dev macvtap-bond0
+
+EOF
+
+ # I'm not sure ipv6 works well with the macvtap stuff. todo: research.
+ # anyways, other kvm hosts dont have it enabled.
+ if false && [[ $ip6 ]]; then
+ cat >>$target/etc/network/interfaces <<EOF
+iface bond0 inet6 static
+ pre-up echo 0 > /proc/sys/net/ipv6/conf/bond0/accept_dad
address $ip6
netmask 48
gateway $gateway6
EOF
+ fi
+
+ else
+ cat > $target/etc/network/interfaces <<EOF
+auto lo
+iface lo inet loopback
+
+auto eth0
+iface eth0 inet static
+address $CIDR
+gateway $GATEWAYS
+EOF
+
+ if [[ $ip6 ]]; then
+ cat >>$target/etc/network/interfaces <<EOF
+iface eth0 inet6 static
+pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/accept_dad
+address $ip6
+netmask 48
+gateway $gateway6
+EOF
+ fi
+ fi
fi
# previously had an else condition after
##### end network setup #####
+# note: systemd-resolved + ifupdown causes networking.service to fail in t11,
+# https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1907878
+systemctl disable systemd-resolved
# rm first to remove any symlink
rm -f $target/etc/resolv.conf
-if ifclass demohost; then
+if ifclass demohost || [[ $GATEWAYS != 209.51.188.* ]]; then
cat >$target/etc/resolv.conf <<'EOF'
nameserver 8.8.8.8
EOF