Blame | Last modification | View Log | RSS feed
#!/bin/sh## init.ipv6-global### Taken from: init.ipv6-global# (P) & (C) 2001-2005 by Peter Bieringer <pb@bieringer.de>## You will find more information on the initscripts-ipv6 homepage at# http://www.deepspace6.net/projects/initscripts-ipv6.html## RHL integration assistance by Pekka Savola <pekkas@netcore.fi>## Version: 2005-01-04## Calling parameters:# $1: action (currently supported: start|stop|showsysctl)# $2: position for start|stop (currently supported: pre|post)## Called by hooks from /etc/[rc.d/]init.d/network## Uses following information from /etc/sysconfig/network:# IPV6FORWARDING=yes|no: controls global IPv6 forwarding (default: no)# IPV6_AUTOCONF=yes|no: controls global automatic IPv6 configuration# (default: yes if IPV6FORWARDING=no, no if IPV6FORWARDING=yes)# IPV6_AUTOTUNNEL=yes|no: controls automatic IPv6 tunneling (default: no)# IPV6_DEFAULTGW=<ipv6address[%interface]> [optional]# IPV6_DEFAULTDEV=<interface> [optional]#. /etc/sysconfig/networkcd /etc/sysconfig/network-scripts. ./network-functions# Get action and hook positionACTION="$1"POSITION="$2"[ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1. /etc/sysconfig/network-scripts/network-functions-ipv6# Initialize IPv6, depending on caller optioncase $ACTION instart)case $POSITION inpre)# IPv6 test, module loaded, exit if system is not IPv6-readyipv6_test || exit 1if [ "$IPV6FORWARDING" = "yes" ]; thenipv6_global_forwarding=1ipv6_global_auto=0elseipv6_global_forwarding=0if [ "$IPV6_AUTOCONF" = "no" ]; thenipv6_global_auto=0elseipv6_global_auto=1fifi# Reset IPv6 sysctl switches for "all", "default" and still existing devicesfor i in /proc/sys/net/ipv6/conf/* ; dointerface=${i##*/}sinterface=${interface/.//}# Host/Router behaviour for the interface/sbin/sysctl -e -w net.ipv6.conf.$sinterface.forwarding=$ipv6_global_forwarding >/dev/null 2>&1# Autoconfiguration and redirect handling for Hosts/sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_ra=$ipv6_global_auto >/dev/null 2>&1/sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_redirects=$ipv6_global_auto >/dev/null 2>&1done;;post)# IPv6 test, module loaded, exit if system is not IPv6-readyipv6_test || exit 1if [ "$IPV6_AUTOTUNNEL" = "yes" ]; thenipv6_enable_autotunnel# autotunnel interface doesn't require a MTU setupfi## Add some routes which should never appear on the wire# Unreachable IPv4-only addresses, normally blocked by source address selection/sbin/ip route add unreach ::ffff:0.0.0.0/96# Unreachable IPv4-mapped addresses/sbin/ip route add unreach ::0.0.0.0/96# Unreachable 6to4: IPv4 multicast, reserved, limited broadcast/sbin/ip route add unreach 2002:e000::/19# Unreachable 6to4: IPv4 loopback/sbin/ip route add unreach 2002:7f00::/24# Unreachable 6to4: IPv4 private (RFC 1918)/sbin/ip route add unreach 2002:0a00::/24/sbin/ip route add unreach 2002:ac10::/28/sbin/ip route add unreach 2002:c0a8::/32# Unreachable 6to4: IPv4 private (APIPA / DHCP link-local)/sbin/ip route add unreach 2002:a9fe::/32# Unreachable IPv6: 6bone test addresses/sbin/ip route add unreach 3ffe:ffff::/32# Set default route for autotunnel, if specifiedif [ "$IPV6_DEFAULTDEV" = "sit0" -a "$IPV6_AUTOTUNNEL" = "yes" ]; thenif [ -n "$IPV6_DEFAULTGW" ]; thenipv6_set_default_route $IPV6_DEFAULTGW $IPV6_DEFAULTDEV sit0elif [ -n "$IPV6_DEFAULTDEV" ]; thenipv6_set_default_route "" $IPV6_DEFAULTDEV sit0fifi;;*)echo "Usage: $0 $1 {pre|post}";;esac;;stop)case $POSITION inpre);;post)# IPv6 test, no module loaded, exit if system is not IPv6-readyipv6_test testonly || exit 0for i in /proc/sys/net/ipv6/conf/* ; dointerface=${i##*/}sinterface=${interface/.//}# Assume Host behaviour/sbin/sysctl -e -w net.ipv6.conf.$sinterface.forwarding=0 >/dev/null 2>&1# Disable autoconfiguration and redirects/sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_ra=0 >/dev/null 2>&1/sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_redirects=0 >/dev/null 2>&1done# Cleanup still existing tunnel devicesipv6_cleanup_tunnel_devices# Shut down generic tunnel interface nowif ipv6_test_device_status sit0 ; then/sbin/ip link set sit0 downfi;;*)echo "Usage: $0 $1 {pre|post}";;esac;;*)echo $"Usage: $0 {start|stop|reload|restart|showsysctl}"exit 1;;esac