diff options
author | shin <shin@FreeBSD.org> | 2000-02-23 18:05:58 +0000 |
---|---|---|
committer | shin <shin@FreeBSD.org> | 2000-02-23 18:05:58 +0000 |
commit | af0bb085250e0cfb160fc34ac4d3aa545bc5940a (patch) | |
tree | 9ecbdd1111b9f930840a3a81e289545774991a0d | |
parent | 8e95d00d2495c79517e8b1865fabe090db0bade2 (diff) | |
download | FreeBSD-src-af0bb085250e0cfb160fc34ac4d3aa545bc5940a.zip FreeBSD-src-af0bb085250e0cfb160fc34ac4d3aa545bc5940a.tar.gz |
Add IPv6 configuration scripts.
Initial version created by, and kindly much tested by:
bmah@CA.Sandia.GOV (Bruce A. Mah)
Approved by: jkh
Reviewed by: bmah@CA.Sandia.GOV (Bruce A. Mah),
Ollivier Robert <roberto@keltia.freenix.fr>
Obtained from: KAME project
-rw-r--r-- | etc/defaults/rc.conf | 28 | ||||
-rw-r--r-- | etc/rc | 9 | ||||
-rw-r--r-- | etc/rc.d/network_ipv6 | 246 | ||||
-rw-r--r-- | etc/rc.network6 | 246 |
4 files changed, 529 insertions, 0 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 3d04582..30f48e4 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -184,6 +184,34 @@ isdn_traceflags="-f /var/tmp/isdntrace0" # Flags for isdntrace ### Miscellaneous network options: ### icmp_bmcastecho="NO" # respond to broadcast ping packets +### IPv6 options: ### +ipv6_enable="NO" # Set to YES to set up for IPv6. +ipv6_network_interfaces="auto" # List of network interfaces (or "auto"). +ipv6_gateway_enable="NO" # Set to YES if this host will be a gateway. +ipv6_router_enable="NO" # Set to YES to enable an IPv6 routing daemon. +ipv6_router="/usr/sbin/route6d" # Name of IPv6 routing daemon. +ipv6_router_flags="" # Flags to IPv6 routing daemon. +#ipv6_router_flags="-l" # Example for route6d with only IPv6 site local + # addrs. +#ipv6_network_interfaces="ed0 ep0" # Examples for router. + # Choose correct prefix value. +#ipv6_prefix_ed0="fec0:0000:0000:0001 fec0:0000:0000:0002" # Examples for rtr. +#ipv6_prefix_ep0="fec0:0000:0000:0003 fec0:0000:0000:0004" # Examples for rtr. +ipv6_default_interface="" # Default output interface for scoped addrs. + # Now this works only for IPv6 link local + # multicast addrs. +prefixcmd_enable="YES" # Use prefix command to assign router prefix. +rtadvd_enable="NO" # Set to YES to enable an IPv6 router + # advertisement daemon. +mroute6d_enable="NO" # Do IPv6 multicast routing. +mroute6d_program="/usr/sbin/pim6dd" # Name of IPv6 multicast routing + # daemon. +mroute6d_flags="" # Flags to IPv6 multicast routing daemon. +gif_interfaces="NO" # List of GIF tunnels (or "NO"). +#gif_interfaces="gif0 gif1" # Examples typically for a router. + # Choose correct tunnel addrs. +#gifconfig_gif0="10.1.1.1 10.1.2.1" # Examples typically for a router. +#gifconfig_gif1="10.1.1.2 10.1.2.2" # Examples typically for a router. ############################################################## ### System console options ################################# @@ -191,6 +191,15 @@ if [ -r /etc/rc.network ]; then network_pass1 fi +case ${ipv6_enable} in +[Yy][Ee][Ss]) + if [ -r /etc/rc.network6 ]; then + . /etc/rc.network6 # We only need to do this once also. + network6_pass1 + fi + ;; +esac + # Mount NFS filesystems. echo -n "Mounting NFS file systems" mount -a -t nfs diff --git a/etc/rc.d/network_ipv6 b/etc/rc.d/network_ipv6 new file mode 100644 index 0000000..bc18d79 --- /dev/null +++ b/etc/rc.d/network_ipv6 @@ -0,0 +1,246 @@ +#! /bin/sh +# $FreeBSD$ + +# Note that almost all of the user-configurable behavior is no longer in +# this file, but rather in /etc/defaults/rc.conf. Please check that file +# first before contemplating any changes here. If you do need to change +# this file for some reason, we would like to know about it. + +# IPv6 startup + +network6_pass1() { + echo -n 'Doing IPv6 network setup:' + + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + # + # list of interfaces, and prefix for interfaces + # + case ${ipv6_network_interfaces} in + [Aa][Uu][Tt][Oo]) + ipv6_network_interfaces="`ifconfig -l`" + ;; + esac + ;; + *) + # + # manual configurations - in case ip6_gateway_enable=NO + # you can configure only single interface, + # as specification assumes that + # autoconfigured host has single interface only. + # + case ${ipv6_network_interfaces} in + [Aa][Uu][Tt][Oo]) + ipv6_network_interfaces="`ifconfig -l \ + | sed -e 's/ .*//'`" + ;; + esac + ;; + esac + + # just to make sure + ifconfig lo0 up + + # disallow "internal" addresses to appear on the wire + route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject + route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject + + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + # act as a router + sysctl -w net.inet6.ip6.forwarding=1 + sysctl -w net.inet6.ip6.accept_rtadv=0 + + # wait for DAD + for i in $ipv6_network_interfaces; do + ifconfig $i up + done + sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'` + sleep 1 + + # setting up interfaces + for i in $ipv6_network_interfaces; do + eval prefix=\$ipv6_prefix_$i + case ${prefix} in + '') + continue; + ;; + esac + for j in ${prefix}; do + case ${prefixcmd_enable} in + [Yy][Ee][Ss]) + prefix $i $j:: + ;; + *) + laddr=`ifconfig $i inet6 \ + | grep 'inet6 fe80:' \ + | head -1 | awk '{print $2}'` + hostid=`echo ${laddr} | sed \ + -e 's/fe80:[0-9a-fA-F]+::/fe80::/' \ + -e 's/fe80:://' -e 's/@.*//'` + address=$j\:${hostid} + + eval hostid_$i=${hostid} + eval address_$i=${address} + + ifconfig $i inet6 ${address} \ + prefixlen 64 alias + ;; + esac + + # subnet-router anycast address (rfc2373) + ifconfig $i inet6 $j:: prefixlen 64 \ + alias anycast + done + + ifconfig $i inet6 + done + + # again, wait for DAD's completion (for global addrs) + sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'` + sleep 1 + + # gifconfig + network6_gif_setup + + # install the "default interface" to kernel, which will be used + # as the default route when there's no router. + network6_default_interface_setup + + # ipv6_router + case ${ipv6_router_enable} in + [Yy][Ee][Ss]) + if [ -x ${ipv6_router} ]; then + echo -n " ${ipv6_router}" + ${ipv6_router} ${ipv6_router_flags} + fi + ;; + esac + + # rtadvd + # This should enabled with a great care. + # You may want to fine-tune /etc/rtadvd.conf. + # + # And if you wish your rtadvd to receive and process + # router renumbering messages, specify your Router Renumbering + # security policy by -P option. + # + # See `man 3 ipsec_set_policy` for IPsec policy specification + # details. + # (CAUTION: This enables your routers prefix renumbering + # from another machine, so if you enable this, do it with + # enough care.) + # + case ${rtadvd_enable} in + [Yy][Ee][Ss]) + # default + rtadvd ${ipv6_network_interfaces} + # + # Enable Router Renumbering, unicast case + # (use correct src/dst addr) + # rtadvd -P "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" \ + ${ipv6_network_interfaces} + # Enable Router Renumbering, multicast case + # (use correct src addr) + # rtadvd -P "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" \ + ${ipv6_network_interfaces} + ;; + esac + + # mroute6d + case ${mroute6d_enable} in + [Yy][Ee][Ss]) + if [ -x ${mroute6d_program} ]; then + echo -n " ${mroute6d_program}" + ${mroute6d_program} ${mroute6d_flags} + fi + ;; + esac + ;; + *) + # act as endhost - automatically configured + sysctl -w net.inet6.ip6.forwarding=0 + sysctl -w net.inet6.ip6.accept_rtadv=1 + + ifconfig ${ipv6_network_interfaces} up + rtsol ${ipv6_network_interfaces} + + + + # wait for DAD's completion (for global addrs) + sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'` + sleep 1 + + # gifconfig + network6_gif_setup + + # install the "default interface" to kernel, which will be used + # as the default route when there's no router. + # ndp -I ${ipv6_default_interface} + network6_default_interface_setup + ;; + esac + + echo '.' + + # Let future generations know we made it. + # + network6_pass1_done=YES +} + +network6_gif_setup() { + case ${gif_interfaces} in + [Nn][Oo] | '') + ;; + *) + for i in ${gif_interfaces}; do + eval peers=\$gifconfig_$i + case ${peers} in + '') + continue + ;; + *) + gifconfig $i ${peers} + ;; + esac + done + ;; + esac +} + +network6_default_interface_setup() { + # Choose IPv6 default interface if it is not clearly specified. + case ${ipv6_default_interface} in + '') + for i in ${ipv6_network_interfaces}; do + laddr=`ifconfig $i inet6 | grep 'inet6 fe80:' | \ + head -1 | grep -v tentative` + case ${laddr} in + '') + ;; + *) + ipv6_default_interface=$i + break + ;; + esac + done + ;; + esac + + # Disallow unicast packets without outgoing scope identifiers, + # or route such packets to a "default" interface, if it is specified. + case ${ipv6_default_interface} in + '') + route add -inet6 fe80:: -prefixlen 10 ::1 -reject + route add -inet6 ff02:: -prefixlen 16 ::1 -reject + ;; + *) + laddr=`ifconfig ${ipv6_default_interface} inet6 \ + | grep 'inet6 fe80:' | head -1 | awk '{print $2}'` + route add -inet6 fe80:: ${laddr} -prefixlen 10 -interface \ + -cloning + route add -inet6 ff02:: ${laddr} -prefixlen 16 -interface \ + -cloning + ;; + esac +} diff --git a/etc/rc.network6 b/etc/rc.network6 new file mode 100644 index 0000000..bc18d79 --- /dev/null +++ b/etc/rc.network6 @@ -0,0 +1,246 @@ +#! /bin/sh +# $FreeBSD$ + +# Note that almost all of the user-configurable behavior is no longer in +# this file, but rather in /etc/defaults/rc.conf. Please check that file +# first before contemplating any changes here. If you do need to change +# this file for some reason, we would like to know about it. + +# IPv6 startup + +network6_pass1() { + echo -n 'Doing IPv6 network setup:' + + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + # + # list of interfaces, and prefix for interfaces + # + case ${ipv6_network_interfaces} in + [Aa][Uu][Tt][Oo]) + ipv6_network_interfaces="`ifconfig -l`" + ;; + esac + ;; + *) + # + # manual configurations - in case ip6_gateway_enable=NO + # you can configure only single interface, + # as specification assumes that + # autoconfigured host has single interface only. + # + case ${ipv6_network_interfaces} in + [Aa][Uu][Tt][Oo]) + ipv6_network_interfaces="`ifconfig -l \ + | sed -e 's/ .*//'`" + ;; + esac + ;; + esac + + # just to make sure + ifconfig lo0 up + + # disallow "internal" addresses to appear on the wire + route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject + route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject + + case ${ipv6_gateway_enable} in + [Yy][Ee][Ss]) + # act as a router + sysctl -w net.inet6.ip6.forwarding=1 + sysctl -w net.inet6.ip6.accept_rtadv=0 + + # wait for DAD + for i in $ipv6_network_interfaces; do + ifconfig $i up + done + sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'` + sleep 1 + + # setting up interfaces + for i in $ipv6_network_interfaces; do + eval prefix=\$ipv6_prefix_$i + case ${prefix} in + '') + continue; + ;; + esac + for j in ${prefix}; do + case ${prefixcmd_enable} in + [Yy][Ee][Ss]) + prefix $i $j:: + ;; + *) + laddr=`ifconfig $i inet6 \ + | grep 'inet6 fe80:' \ + | head -1 | awk '{print $2}'` + hostid=`echo ${laddr} | sed \ + -e 's/fe80:[0-9a-fA-F]+::/fe80::/' \ + -e 's/fe80:://' -e 's/@.*//'` + address=$j\:${hostid} + + eval hostid_$i=${hostid} + eval address_$i=${address} + + ifconfig $i inet6 ${address} \ + prefixlen 64 alias + ;; + esac + + # subnet-router anycast address (rfc2373) + ifconfig $i inet6 $j:: prefixlen 64 \ + alias anycast + done + + ifconfig $i inet6 + done + + # again, wait for DAD's completion (for global addrs) + sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'` + sleep 1 + + # gifconfig + network6_gif_setup + + # install the "default interface" to kernel, which will be used + # as the default route when there's no router. + network6_default_interface_setup + + # ipv6_router + case ${ipv6_router_enable} in + [Yy][Ee][Ss]) + if [ -x ${ipv6_router} ]; then + echo -n " ${ipv6_router}" + ${ipv6_router} ${ipv6_router_flags} + fi + ;; + esac + + # rtadvd + # This should enabled with a great care. + # You may want to fine-tune /etc/rtadvd.conf. + # + # And if you wish your rtadvd to receive and process + # router renumbering messages, specify your Router Renumbering + # security policy by -P option. + # + # See `man 3 ipsec_set_policy` for IPsec policy specification + # details. + # (CAUTION: This enables your routers prefix renumbering + # from another machine, so if you enable this, do it with + # enough care.) + # + case ${rtadvd_enable} in + [Yy][Ee][Ss]) + # default + rtadvd ${ipv6_network_interfaces} + # + # Enable Router Renumbering, unicast case + # (use correct src/dst addr) + # rtadvd -P "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" \ + ${ipv6_network_interfaces} + # Enable Router Renumbering, multicast case + # (use correct src addr) + # rtadvd -P "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" \ + ${ipv6_network_interfaces} + ;; + esac + + # mroute6d + case ${mroute6d_enable} in + [Yy][Ee][Ss]) + if [ -x ${mroute6d_program} ]; then + echo -n " ${mroute6d_program}" + ${mroute6d_program} ${mroute6d_flags} + fi + ;; + esac + ;; + *) + # act as endhost - automatically configured + sysctl -w net.inet6.ip6.forwarding=0 + sysctl -w net.inet6.ip6.accept_rtadv=1 + + ifconfig ${ipv6_network_interfaces} up + rtsol ${ipv6_network_interfaces} + + + + # wait for DAD's completion (for global addrs) + sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'` + sleep 1 + + # gifconfig + network6_gif_setup + + # install the "default interface" to kernel, which will be used + # as the default route when there's no router. + # ndp -I ${ipv6_default_interface} + network6_default_interface_setup + ;; + esac + + echo '.' + + # Let future generations know we made it. + # + network6_pass1_done=YES +} + +network6_gif_setup() { + case ${gif_interfaces} in + [Nn][Oo] | '') + ;; + *) + for i in ${gif_interfaces}; do + eval peers=\$gifconfig_$i + case ${peers} in + '') + continue + ;; + *) + gifconfig $i ${peers} + ;; + esac + done + ;; + esac +} + +network6_default_interface_setup() { + # Choose IPv6 default interface if it is not clearly specified. + case ${ipv6_default_interface} in + '') + for i in ${ipv6_network_interfaces}; do + laddr=`ifconfig $i inet6 | grep 'inet6 fe80:' | \ + head -1 | grep -v tentative` + case ${laddr} in + '') + ;; + *) + ipv6_default_interface=$i + break + ;; + esac + done + ;; + esac + + # Disallow unicast packets without outgoing scope identifiers, + # or route such packets to a "default" interface, if it is specified. + case ${ipv6_default_interface} in + '') + route add -inet6 fe80:: -prefixlen 10 ::1 -reject + route add -inet6 ff02:: -prefixlen 16 ::1 -reject + ;; + *) + laddr=`ifconfig ${ipv6_default_interface} inet6 \ + | grep 'inet6 fe80:' | head -1 | awk '{print $2}'` + route add -inet6 fe80:: ${laddr} -prefixlen 10 -interface \ + -cloning + route add -inet6 ff02:: ${laddr} -prefixlen 16 -interface \ + -cloning + ;; + esac +} |