From 3587a2c0737d374c01ea374710eb09671055fdbc Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Sat, 11 Jun 2011 16:09:40 +0200 Subject: IPv6: add support for static configuration. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enabled by "IP6=static": it uss parameters ADDR6, GATEWAY6, IP6CFG similar to their IPv4 counterparts, as well as an additional PREFIXLEN parameter. Signed-off-by: Olivier Mehani Signed-off-by: Rémy Oudompheng --- src/connections/ethernet | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/connections/ethernet') diff --git a/src/connections/ethernet b/src/connections/ethernet index c402e83..ebd3a78 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -46,6 +46,11 @@ ethernet_up() { fi fi + if [[ -z "$IP" && -z "$IP6" ]]; then + report_iproute "At least one of IP or IP6 should be specified" + return 1 + fi + case "$IP" in dhcp) if checkyesno "${DHCLIENT:-no}"; then @@ -100,6 +105,8 @@ ethernet_up() { fi fi ;; + "") + ;; *) report_iproute "IP must be either 'dhcp' or 'static'" ;; @@ -115,6 +122,29 @@ ethernet_up() { done fi + case "$IP6" in + static) + if [[ -n "$ADDR6" ]]; then + [[ -z $PREFIXLEN ]] && PREFIXLEN=64 + report_debug ethernet_iproute_up ip -6 addr add "$ADDR6/$PREFIXLEN" dev "$INTERFACE" + if ! ip -6 addr add "$ADDR6/$PREFIXLEN" dev "$INTERFACE"; then + report_iproute "Could not configure interface" + fi + fi + if [[ -n "$GATEWAY6" ]]; then + report_debug ethernet_iproute_up ip -6 route add default via "$GATEWAY6" + if ! ip -6 route add default via "$GATEWAY6"; then + report_iproute "Adding gateway $GATEWAY6 failed" + fi + fi + ;; + "") + ;; + *) + report_iproute "IP6 must be 'static'" + ;; + esac + # Set hostname if [[ -n "$HOSTNAME" ]]; then report_debug ethernet_iproute_up hostname "$HOSTNAME" -- cgit v1.2.3-24-g4f1b