]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network/dhclient-script.sh:DHCP IPv6 interface setup
authorHarald Hoyer <harald@redhat.com>
Tue, 25 Feb 2014 13:04:05 +0000 (14:04 +0100)
committerHarald Hoyer <harald@redhat.com>
Wed, 26 Feb 2014 14:02:51 +0000 (15:02 +0100)
configure IPv6 interface for DHCP6

https://bugzilla.redhat.com/show_bug.cgi?id=1064365

modules.d/40network/dhclient-script.sh

index b8d770b7f4555a9e9eff58e2d39b26a844517c8e..8af48f7f31b8ef4cf4b823310b192ca34d164f17 100755 (executable)
@@ -48,6 +48,31 @@ setup_interface() {
     [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
 }
 
+setup_interface6() {
+    domain=$new_domain_name
+    search=$(printf -- "$new_domain_search")
+    namesrv=$new_domain_name_servers
+    hostname=$new_host_name
+    lease_time=$new_dhcp_lease_time
+
+    [ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+
+    ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
+        dev ${netif} scope global valid_lft ${lease_time} \
+        preferred_lft ${lease_time}
+
+    [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
+    if  [ -n "$namesrv" ] ; then
+        for s in $namesrv; do
+            echo nameserver $s
+        done
+    fi >> /tmp/net.$netif.resolv.conf
+
+    # Note: hostname can be fqdn OR short hostname, so chop off any
+    # trailing domain name and explicity add any domain if set.
+    [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
+}
+
 PATH=/usr/sbin:/usr/bin:/sbin:/bin
 
 export PS4="dhclient.$interface.$$ + "
@@ -66,6 +91,7 @@ case $reason in
         echo "dhcp: PREINIT $netif up"
         linkup $netif
         ;;
+
     BOUND)
         echo "dhcp: BOND setting $netif"
         unset layer2
@@ -95,6 +121,29 @@ case $reason in
             echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
         } > $hookdir/initqueue/setup_net_$netif.sh
 
+        echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
+        >/tmp/net.$netif.up
+        ;;
+
+    BOUND6)
+        echo "dhcp: BOND6 setting $netif"
+        setup_interface6
+
+        set | while read line; do
+            [ "${line#new_}" = "$line" ] && continue
+            echo "$line"
+        done >/tmp/dhclient.$netif.dhcpopts
+
+        {
+            echo '. /lib/net-lib.sh'
+            echo "setup_net $netif"
+            echo "source_hook initqueue/online $netif"
+            [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
+            echo "> /tmp/setup_net_$netif.ok"
+            echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
+            echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
+        } > $hookdir/initqueue/setup_net_$netif.sh
+
         echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh
         >/tmp/net.$netif.up
         ;;