summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2014-11-20 14:16:15 +1100
committerMartin Schwenke <martin@meltin.net>2014-11-25 11:24:56 +1100
commitd2b95463295b21fce7636a1373abca5282d14fa8 (patch)
tree12e9283195241d7c47bd6cc0c315b2b770ade562
parent56c33c7376523eb8db06b5be7d35be61290a9cb2 (diff)
downloadautocluster-d2b95463295b21fce7636a1373abca5282d14fa8.tar.gz
autocluster-d2b95463295b21fce7636a1373abca5282d14fa8.tar.xz
autocluster-d2b95463295b21fce7636a1373abca5282d14fa8.zip
Add IPv6 support
New configuration variable NETWORK_STACK. Signed-off-by: Amitay Isaacs <amitay@gmail.com>
-rwxr-xr-xautocluster14
-rw-r--r--config.d/00base.defconf7
-rwxr-xr-xhost_setup/setup_networks.sh11
3 files changed, 22 insertions, 10 deletions
diff --git a/autocluster b/autocluster
index 0eb26f5..0ae0f12 100755
--- a/autocluster
+++ b/autocluster
@@ -352,12 +352,14 @@ make_network_map ()
local ip="${net%.*}.${IPNUM}/${ip_bits#*/}"
+ local ipv6="fc00:${net//./:}::${IPNUM}/64"
+
# This can be used to override the variables in the echo
# statement below. The hook can use any other variables
# available in this function.
run_hooks hack_network_map_hooks
- echo "${netname} ${dev} ${ip} ${mac} ${opts}"
+ echo "${netname} ${dev} ${ip} ${ipv6} ${mac} ${opts}"
count=$(($count + 1))
done >"$network_map"
}
@@ -718,8 +720,8 @@ guess_install_network ()
# specified then use the IP address associated with it.
INSTALL_IP=""
INSTALL_GW=""
- local netname dev ip mac opts
- while read netname dev ip mac opts; do
+ local netname dev ip ipv6 mac opts
+ while read netname dev ip ipv6 mac opts; do
local o
for o in $opts ; do
case "$o" in
@@ -1007,8 +1009,8 @@ setup_network()
diskimage rm_rf "/etc/udev/rules.d/70-persistent-net.rules"
echo "Setting up network interfaces: "
- local netname dev ip mac opts
- while read netname dev ip mac opts; do
+ local netname dev ip ipv6 mac opts
+ while read netname dev ip ipv6 mac opts; do
echo " $dev"
local o gw addr mask
@@ -1031,6 +1033,8 @@ TYPE=Ethernet
IPADDR=$addr
NETMASK=$mask
HWADDR=$mac
+IPV6INIT=yes
+IPV6ADDR=$ipv6
${gw:+GATEWAY=}${gw}
EOF
diff --git a/config.d/00base.defconf b/config.d/00base.defconf
index f366f1e..1196b07 100644
--- a/config.d/00base.defconf
+++ b/config.d/00base.defconf
@@ -228,6 +228,9 @@ defconf DNSSEARCH "$DOMAIN" \
defconf NETWORKS "10.0.0.0/24,eth0,gw=10.0.0.1 10.0.1.0/24,eth1 10.0.2.0/24,eth2" \
"<list>" "description of IP networks"
+defconf NETWORK_STACK "ipv4" \
+ "ipv4|dual|ipv6" "Configure IPv4/IPv6 stacks"
+
make_public_addresses()
{
local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
@@ -279,8 +282,8 @@ defconf NETWORK_TEMPLATE "|network_template" \
network_template ()
{
- local netname dev ip mac opts
- while read netname dev ip mac opts ; do
+ local netname dev ip ipv6 mac opts
+ while read netname dev ip ipv6 mac opts ; do
cat <<EOF
<interface type='network'>
<mac address='${mac}'/>
diff --git a/host_setup/setup_networks.sh b/host_setup/setup_networks.sh
index 52dc29f..65c19fb 100755
--- a/host_setup/setup_networks.sh
+++ b/host_setup/setup_networks.sh
@@ -21,7 +21,8 @@ gen_xml ()
{
local netname="$1"
local ip="$2"
- local opts="$3"
+ local ipv6="$3"
+ local opts="$4"
local uuid=$(uuidgen)
@@ -55,9 +56,13 @@ EOF
ip_addr=${ip%/*}
ip_mask=${ip#*/}
+ ipv6_addr=${ipv6%/*}
+ ipv6_mask=${ipv6#*/}
+
cat <<EOF
<bridge name='${netname}' stp='on' forwardDelay='0' />
<ip address='${ip_addr}' prefix='${ip_mask}' />
+ <ip family='ipv6' address='${ipv6_addr}' prefix='${ipv6_mask}' />
</network>
EOF
}
@@ -78,10 +83,10 @@ if [ $? -ne 0 -o -z "$network_map" ]; then
fi
-while read netname dev ip mac opts ; do
+while read netname dev ip ipv6 mac opts ; do
echo "Setting up network \"${netname}\""
t=$(mktemp)
- gen_xml "$netname" "$ip" "$opts" >"$t"
+ gen_xml "$netname" "$ip" "$ipv6" "$opts" >"$t"
if $dry_run ; then
cat "$t"
else