diff options
author | Olivier Mehani <olivier.mehani@nicta.com.au> | 2011-06-11 16:09:40 +0200 |
---|---|---|
committer | Rémy Oudompheng <remy@archlinux.org> | 2011-06-11 16:11:33 +0200 |
commit | 3587a2c0737d374c01ea374710eb09671055fdbc (patch) | |
tree | 5a780a9c6ad972aaa472ae80302b04a1d65bcb35 /src | |
parent | 3d54e86a27a0e670ab5a95cb08e965d3ad25dd53 (diff) | |
download | netctl-3587a2c0737d374c01ea374710eb09671055fdbc.tar.gz netctl-3587a2c0737d374c01ea374710eb09671055fdbc.tar.xz |
IPv6: add support for static configuration.
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 <shtrom-arch@ssji.net>
Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/connections/ethernet | 30 |
1 files changed, 30 insertions, 0 deletions
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" |