> I fixed it and other problems, and added another changes. (In
> particular, I mistakenly left my testing part in router
> case. Sorry.)
> I'll attach the new diffs.

I still made more several fixes to IPv6 configuration scripts.

  -changed the file rc.net6 to rc.network6
  -changed the func net6_pass1 to network6_pass1
  -changed several var name more unlikely to confilict
  -changed if several sentenses in rc.network6 to case sentence
   like in rc.network
  -wrapped many var names by {}
  -and other fixes

I believe now it successfully configure each of router and
host case, very well.
Please try it anyone interested.

Thanks,
Yoshinobu Inoue



Index: defaults/rc.conf
===================================================================
RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.48
diff -u -r1.48 rc.conf
--- defaults/rc.conf    2000/02/06 19:25:00     1.48
+++ defaults/rc.conf    2000/02/18 12:53:06
@@ -184,6 +184,32 @@
 ### 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.
+prefixcmd_enable="YES"         # Use prefix command to assigne 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.
+ipv6_default_interface="lo0"   # Default output interface for scoped addrs.
 
 ##############################################################
 ###  System console options  #################################
Index: rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.210
diff -u -r1.210 rc
--- rc  2000/02/03 06:06:36     1.210
+++ rc  2000/02/18 12:53:07
@@ -191,6 +191,15 @@
        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
Index: rc.network6
===================================================================
RCS file: rc.network6
diff -N rc.network6
--- /dev/null   Fri Feb 18 03:29:51 2000
+++ rc.network6 Fri Feb 18 04:53:07 2000
@@ -0,0 +1,219 @@
+#! /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 unicast packets without outgoing scope identifiers.
+       # if you instead want to route such packets to a "default" interface,
+       # comment out the 1st two lines, and enable the lines after them.
+       case ${ipv6_default_interface} in
+       '')
+               route add -inet6 fe80:: -prefixlen 10 ::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
+
+       # 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
+
+               # 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, unicaset 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}
+
+               # install the "default interface" to kernel, which will be used
+               # as the default route when there's no router.
+               # ndp -I ${ipv6_default_interface}
+
+               # wait for DAD's completion (for global addrs)
+               sleep `sysctl net.inet6.ip6.dad_count | awk '{print $NF}'`
+               sleep 1
+
+               # gifconfig
+               network6_gif_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
+}

Reply via email to