Merge pull request #73 from OpenNebula/ipv6

Improved IPv6 support
pull/74/head
Vlastimil Holer 8 years ago committed by GitHub
commit f84361abc8

@ -155,8 +155,8 @@ EOT
gen_iface6_conf() {
cat <<EOT
iface $DEV inet6 static
address $IPV6
netmask 64
address $IP6
netmask ${IP6_PREFIX_LENGTH:-64}
autoconf 0
accept_ra 0
EOT
@ -169,6 +169,22 @@ EOT
echo " gateway $GATEWAY6"
fi
if [ -n "$IP6_ULA" ]; then
cat <<EOT
iface $DEV inet6 static
address $IP6_ULA
netmask 64
autoconf 0
accept_ra 0
EOT
if [ -n "$MTU" ]; then
echo " mtu $MTU"
fi
fi
echo ""
}
@ -214,17 +230,19 @@ EOT
MTU=$(get_mtu)
GATEWAY=$(get_gateway)
IPV6=$(get_iface_var "IPV6")
[[ -z $IPV6 ]] && IPV6=$(get_iface_var "IP6")
IP6=$(get_iface_var "IP6")
[[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6")
IP6_PREFIX_LENGTH=$(get_iface_var "IP6_PREFIX_LENGTH")
IP6_ULA=$(get_iface_var "IP6_ULA")
GATEWAY6=$(get_gateway6)
[ -z "${IP}${IPV6}" ] && continue
[ -z "${IP}${IP6}" ] && continue
[ -z "${DEV}" ] && continue
echo "auto $DEV"
[[ -n $IP ]] && gen_iface_conf
[[ -n $IPV6 ]] && gen_iface6_conf
[[ -n $IP6 ]] && gen_iface6_conf
done
}

@ -103,33 +103,34 @@ gen_iface_conf() {
NETMASK=$MASK
IPADDR=$IP
EOT
if [ -n "$MTU" ]; then
echo "MTU=$MTU"
fi
if [ -n "$GATEWAY" ]; then
echo "GATEWAY=$GATEWAY"
fi
echo ""
if [ -n "$MTU" ]; then
echo "MTU=$MTU"
fi
}
gen_iface6_conf() {
cat <<EOT
IPV6INIT=yes
IPV6ADDR=$IPV6
IPV6ADDR=$IP6/${IP6_PREFIX_LENGTH:-64}
IPV6_AUTOCONF=no
EOT
if [ -n "$MTU" ]; then
echo "MTU=$MTU"
if [ -n "$IP6_ULA" ]; then
echo "IPV6ADDR_SECONDARIES=$IP6_ULA/64"
fi
if [ -n "$GATEWAY6" ]; then
echo "IPV6_DEFAULTGW=$GATEWAY6"
fi
echo ""
if [ -n "$MTU" ]; then
echo "IPV6_MTU=$MTU"
fi
}
get_interface_mac()
@ -168,11 +169,13 @@ gen_network_configuration()
MTU=$(get_mtu)
GATEWAY=$(get_gateway)
IPV6=$(get_iface_var "IPV6")
[[ -z $IPV6 ]] && IPV6=$(get_iface_var "IP6")
IP6=$(get_iface_var "IP6")
[[ -z $IP6 ]] && IP6=$(get_iface_var "IPV6")
IP6_PREFIX_LENGTH=$(get_iface_var "IP6_PREFIX_LENGTH")
IP6_ULA=$(get_iface_var "IP6_ULA")
GATEWAY6=$(get_gateway6)
[ -z "${IP}${IPV6}" ] && continue
[ -z "${IP}${IP6}" ] && continue
[ -z "${DEV}" ] && continue
(
@ -184,7 +187,7 @@ NM_CONTROLLED=no
TYPE=Ethernet
EOT
[[ -n $IP ]] && gen_iface_conf
[[ -n $IPV6 ]] && gen_iface6_conf
[[ -n $IP6 ]] && gen_iface6_conf
) > /etc/sysconfig/network-scripts/ifcfg-${DEV}

@ -38,7 +38,6 @@ get_dev_from_pci()
return
fi
if [ `echo "$DEV" | wc -l` -gt 1 ]; then
echo "More than one PCI Device $1 found" >&2
return
@ -52,26 +51,62 @@ PCI_INTERFACES=$(get_pci_interfaces)
for pci in $PCI_INTERFACES; do
UPCASE_DEV=$pci
MAC=$(get_iface_var "MAC")
IP=$(get_iface_var "IP")
IPV6=$(get_iface_var "IP6")
MAC=$(get_iface_var "MAC")
MASK=$(get_iface_var "MASK")
MASK=${MASK:-255.255.255.0}
GATEWAY=$(get_iface_var "GATEWAY")
MTU=$(get_iface_var "MTU")
MTU=${MTU:-1500}
VLAN_ID=$(get_iface_var "VLAN_ID")
IP6=$(get_iface_var "IP6")
IP6_PREFIX_LENGTH=$(get_iface_var "IP6_PREFIX_LENGTH")
IP6_PREFIX_LENGTH=${IP6_PREFIX_LENGTH:-64}
IP6_ULA=$(get_iface_var "IP6_ULA")
GATEWAY6=$(get_iface_var "GATEWAY6")
ADDRESS=$(get_iface_var "ADDRESS")
[ -z "$ADDRESS" ] && continue
DEV=$(get_dev_from_pci "$ADDRESS")
[ -z "$DEV" ] && continue
# MAC
ip link set dev $DEV address $MAC
ip link set dev $DEV up
# MTU
if [ -n "$MTU" ]; then
ip link set dev $DEV mtu $MTU
fi
# VLAN (802.1Q)
if [ -n "$VLAN_ID" ]; then
ip link add link $DEV name $DEV.$VLAN_ID type vlan id $VLAN_ID
ip link set dev $DEV.$VLAN_ID up
DEV=$DEV.$VLAN_ID
fi
[ -n "$IP" ] && ip address add $IP/24 dev $DEV
[ -n "$IPV6" ] && ip address add $IPV6 dev $DEV
# IPv4
if [ -n "$IP" ]; then
ip address add $IP/$MASK dev $DEV
if [ -n "$GATEWAY" ]; then
ip route add default via $GATEWAY dev $DEV
fi
fi
# IPv6
if [ -n "$IP6" ]; then
ip -6 address add $IP6/$IP6_PREFIX_LENGTH dev $DEV
if [ -n "$IP6_ULA" ]; then
ip -6 address add $IP6_ULA/64 dev $DEV
fi
if [ -n "$GATEWAY6" ]; then
ip -6 route add default via $GATEWAY6 dev $DEV
fi
fi
done

Loading…
Cancel
Save