aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2001-02-07 21:47:16 +0000
committerBill Nottingham <notting@redhat.com>2001-02-07 21:47:16 +0000
commit3dbc16abe698daa238f76b3a1add4c41ec225067 (patch)
tree9e4943fc5b1db987a6c3667a5254f037ffa7fed9 /sysconfig
parent4db6d852afc433a7559e2de32f586458f70f79bf (diff)
downloadinitscripts-3dbc16abe698daa238f76b3a1add4c41ec225067.tar
initscripts-3dbc16abe698daa238f76b3a1add4c41ec225067.tar.gz
initscripts-3dbc16abe698daa238f76b3a1add4c41ec225067.tar.bz2
initscripts-3dbc16abe698daa238f76b3a1add4c41ec225067.tar.xz
initscripts-3dbc16abe698daa238f76b3a1add4c41ec225067.zip
updated ipv6 stuff from Peter Bieringer
Diffstat (limited to 'sysconfig')
-rwxr-xr-xsysconfig/network-scripts/ifdown-ipv656
-rwxr-xr-xsysconfig/network-scripts/ifdown-sit42
-rwxr-xr-xsysconfig/network-scripts/ifup-ipv644
-rwxr-xr-xsysconfig/network-scripts/ifup-sit41
-rw-r--r--sysconfig/network-scripts/network-functions-ipv6476
-rw-r--r--sysconfig/static-routes-ipv631
6 files changed, 450 insertions, 240 deletions
diff --git a/sysconfig/network-scripts/ifdown-ipv6 b/sysconfig/network-scripts/ifdown-ipv6
index fcef285b..a4396aa7 100755
--- a/sysconfig/network-scripts/ifdown-ipv6
+++ b/sysconfig/network-scripts/ifdown-ipv6
@@ -1,11 +1,13 @@
-#!/bin/bash
+#!/bin/sh
#
# ifdown-ipv6
#
-# Taken from scripts from:
#
-# (P) & (C) 2000 Peter Bieringer <pb@bieringer.de>
-# some hints taken from RedHat scripts
+# Taken from:
+# (P) & (C) 2000-2001 by Peter Bieringer <pb@bieringer.de>
+#
+# Version 2001-02-02
+#
. /etc/sysconfig/network
@@ -14,44 +16,44 @@ cd /etc/sysconfig/network-scripts
CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
-source_config
+source_config
-# Test if IPv6 configuration is enabled for this interface
+# Test if IPv6 configuration is enabled
if [ ! "$IPV6INIT" = "yes" ]; then
- # not enabled, stop here
- exit 0
+ # not enabled, stop here
+ exit 0
fi
# Test if IPv6 is up
if [ "${NETWORKING_IPV6}" = "yes" ]; then
+
. /etc/sysconfig/network-scripts/network-functions-ipv6
# Delete additional static IPv6 routes on specified interface
- if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
+ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
grep "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device args; do
- if [ "$device" = "$DEVICE" ]; then
- ifdown_ipv6_route $args $DEVICE
- fi
+ if [ "$device" = "$DEVICE" ]; then
+ ifdown_ipv6_route $args $DEVICE
+ fi
done
fi
- # Delete tunnel
- if ! [ -z "$IPV6TUNNELIPV4" -o -z "$IPV6TUNNELROUTE" ]; then
- ifdown_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $IPV6TUNNELROUTE
- fi
+ # Switch off forwarding per device (packets received on this
+ # interface aren't forwarded
+ forwarding_ipv6 no $DEVICE
- # Shutdown additional (1) IPv6 address on specified interface
- if ! [ -z "$IPV6ADDR_0" -o -z "$IPV6PREFIXLENGTH_0" ]; then
- ifdown_ipv6_real $DEVICE $IPV6ADDR_0 $IPV6PREFIXLENGTH_0
- fi
-
- # Shutdown additional (2) IPv6 address on specified interface
- if ! [ -z "$IPV6ADDR_1" -o -z "$IPV6PREFIXLENGTH_1" ]; then
- ifdown_ipv6_real $DEVICE $IPV6ADDR_1 $IPV6PREFIXLENGTH_1
+ # Delete additional IPv6 addresses from list
+ if [ ! -z "$IPV6ADDR_SECONDARIES" ]; then
+ for ipv6addr in $IPV6ADDR_SECONDARIES; do
+ ifdown_ipv6_real $DEVICE $ipv6addr $IPV6PREFIXLENGTH
+ done
fi
-
- # Shutdown IPv6 address on specified interface
- if ! [ -z "$IPV6ADDR" -o -z "$IPV6PREFIXLENGTH" ]; then
+
+ # Shutdown basic configured IPv6 address on specified interface
+ if ! [ -z "$IPV6ADDR" ]; then
ifdown_ipv6_real $DEVICE $IPV6ADDR $IPV6PREFIXLENGTH
fi
+
+ # Cleanup all IPv6 configuration on specified interface (prevents from kernel crashing)
+ ifdown_ipv6_real_all $DEVICE
fi
diff --git a/sysconfig/network-scripts/ifdown-sit b/sysconfig/network-scripts/ifdown-sit
index 3eba5d79..c2323362 100755
--- a/sysconfig/network-scripts/ifdown-sit
+++ b/sysconfig/network-scripts/ifdown-sit
@@ -2,10 +2,14 @@
#
# ifdown-sit
#
+#
# Taken from:
+# (P) & (C) 2000-2001 by Peter Bieringer <pb@bieringer.de>
+#
+# Version 2001-02-03
#
-# (P) & (C) 2000 Peter Bieringer <pb@bieringer.de>
-# some hints taken from RedHat scripts
+
+# Filter tags (for stripping, empty lines following if all is stripped)
. /etc/sysconfig/network
@@ -14,29 +18,35 @@ cd /etc/sysconfig/network-scripts
CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
-source_config
+source_config
# Test if IPv6 configuration is enabled for this interface
if [ ! "$IPV6INIT" = "yes" ]; then
- # not enabled, stop here
- exit 0
+ # not enabled, stop here
+ exit 0
fi
# Test if IPv6 is up
if [ "${NETWORKING_IPV6}" = "yes" ]; then
+
. /etc/sysconfig/network-scripts/network-functions-ipv6
- # Delete additional static IPv6 routes on specified interface
- if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
- grep "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
- if [ "$device" = "$DEVICE" ]; then
- ifdown_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $ipv6route
- fi
- done
- fi
+ # Delete IPv6-in-IPv4 tunnel(s)
+ if [ "$DEVICE" = "sit0" ]; then
+ ifdown_ipv6_autotunnel
+ elif [ ! -z "$IPV6TUNNELIPV4" ]; then
+ # Delete static IPv6 tunnel routes on specified virtual interface
+ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
+ grep "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
+ if [ "$device" = "$DEVICE" ]; then
+ ifdown_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $ipv6route
+ fi
+ done
+ fi
- # Delete tunnel
- if ! [ -z "$IPV6TUNNELIPV4" -o -z "$IPV6TUNNELROUTE" ]; then
- ifdown_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $IPV6TUNNELROUTE
+ if [ ! -z "$IPV6ADDR" ]; then
+ # Numbered tunnel
+ ifdown_ipv6_real sit0 $IPV6ADDR $IPV6PREFIXLENGTH
+ fi
fi
fi
diff --git a/sysconfig/network-scripts/ifup-ipv6 b/sysconfig/network-scripts/ifup-ipv6
index e69262c8..4ef124ae 100755
--- a/sysconfig/network-scripts/ifup-ipv6
+++ b/sysconfig/network-scripts/ifup-ipv6
@@ -2,9 +2,14 @@
#
# ifup-ipv6
#
+#
# Taken from:
+# (P) & (C) 2000-2001 by Peter Bieringer <pb@bieringer.de>
+#
+# Version 2001-02-02
#
-# (P) & (C) 2000 Peter Bieringer <pb@bieringer.de>
+
+# Filter tags (for stripping, empty lines following if all is stripped)
. /etc/sysconfig/network
@@ -15,7 +20,7 @@ CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config
-# Test if IPv6 configuration is enabled for this interface
+# Test if IPv6 configuration is enabled
if [ ! "$IPV6INIT" = "yes" ]; then
# not enabled, stop here
exit 0
@@ -23,34 +28,39 @@ fi
# Test if IPv6 is up
if [ "${NETWORKING_IPV6}" = "yes" ]; then
+
. /etc/sysconfig/network-scripts/network-functions-ipv6
# Setup IPv6 address on specified interface
- if ! [ -z "$IPV6ADDR" -o -z "$IPV6PREFIXLENGTH" ]; then
+ if ! [ -z "$IPV6ADDR" ]; then
ifup_ipv6_real $DEVICE $IPV6ADDR $IPV6PREFIXLENGTH
fi
-
- # Setup additional (1) IPv6 address on specified interface
- if ! [ -z "$IPV6ADDR_0" -o -z "$IPV6PREFIXLENGTH_0" ]; then
- ifup_ipv6_real $DEVICE $IPV6ADDR_0 $IPV6PREFIXLENGTH_0
+
+ # Switch forwarding per device like defined
+ # Packets received on selected interface are forwarded
+ if ! [ -z "$IPV6FORWARDING" ]; then
+ if [ "$IPV6FORWARDING" = "yes" ]; then
+ forwarding_ipv6 yes $DEVICE
+ # also for all (otherwise, nothing is forwarded)
+ forwarding_ipv6 yes
+ else
+ forwarding_ipv6 no $DEVICE
+ fi
fi
-
- # Setup additional (2) IPv6 address on specified interface
- if ! [ -z "$IPV6ADDR_1" -o -z "$IPV6PREFIXLENGTH_1" ]; then
- ifup_ipv6_real $DEVICE $IPV6ADDR_1 $IPV6PREFIXLENGTH_1
+
+ # Setup additional IPv6 addresses from list
+ if [ ! -z "$IPV6ADDR_SECONDARIES" ]; then
+ for ipv6addr in $IPV6ADDR_SECONDARIES; do
+ ifup_ipv6_real $DEVICE $ipv6addr $IPV6PREFIXLENGTH
+ done
fi
# Setup additional static IPv6 routes on specified interface
- if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
+ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
grep "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device args; do
if [ "$device" = "$DEVICE" ]; then
ifup_ipv6_route $args $DEVICE
fi
done
fi
-
- # Setup tunnel
- if ! [ -z "$IPV6TUNNELIPV4" -o -z "$IPV6TUNNELROUTE" ]; then
- ifup_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $IPV6TUNNELROUTE
- fi
fi
diff --git a/sysconfig/network-scripts/ifup-sit b/sysconfig/network-scripts/ifup-sit
index ef703943..8a1daa56 100755
--- a/sysconfig/network-scripts/ifup-sit
+++ b/sysconfig/network-scripts/ifup-sit
@@ -2,9 +2,14 @@
#
# ifup-sit
#
+#
# Taken from:
-# (P) & (C) 2000 Peter Bieringer <pb@bieringer.de>
-# some hints taken from RedHat scripts
+# (P) & (C) 2000-2001 by Peter Bieringer <pb@bieringer.de>
+#
+# Version 2001-02-06
+#
+
+# Filter tags (for stripping, empty lines following if all is stripped)
. /etc/sysconfig/network
@@ -23,19 +28,25 @@ fi
# Test if IPv6 is up
if [ "${NETWORKING_IPV6}" = "yes" ]; then
- . /etc/sysconfig/network-scripts/network-functions-ipv6
+
+ . /etc/sysconfig/network-scripts/network-functions-ipv6
- # Setup tunnel
- if ! [ -z "$IPV6TUNNELIPV4" -o -z "$IPV6TUNNELROUTE" ]; then
- ifup_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $IPV6TUNNELROUTE
- fi
+ # Setup IPv6-in-IPv4 tunnel(s)
+ if [ "$DEVICE" = "sit0" ]; then
+ ifup_ipv6_autotunnel
+ elif [ ! -z "$IPV6TUNNELIPV4" ]; then
+ if [ ! -z "$IPV6ADDR" ]; then
+ # Numbered tunnel
+ ifup_ipv6_real sit0 $IPV6ADDR $IPV6PREFIXLENGTH
+ fi
- # Add additional static IPv6 routes on specified interface
- if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
- grep "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
- if [ "$device" = "$DEVICE" ]; then
- ifup_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $ipv6route
- fi
- done
- fi
+ # Add static IPv6 tunnel routes on specified virtual interface
+ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
+ grep "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
+ if [ "$device" = "$DEVICE" ]; then
+ ifup_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $ipv6route
+ fi
+ done
+ fi
+ fi
fi
diff --git a/sysconfig/network-scripts/network-functions-ipv6 b/sysconfig/network-scripts/network-functions-ipv6
index c8c61cc4..2c0e7846 100644
--- a/sysconfig/network-scripts/network-functions-ipv6
+++ b/sysconfig/network-scripts/network-functions-ipv6
@@ -3,86 +3,127 @@
# network-functions-ipv6
#
# Taken from:
-# (P) & (C) 1997-2000 Peter Bieringer <pb@bieringer.de>
+# (P) & (C) 1997-2001 by Peter Bieringer <pb@bieringer.de>
+#
+# Version: 2001-02-05
+#
+
+
+# Filter tags (for stripping, empty lines following if all is stripped)
+
+
-# DEBUG_IPV6 & 1 "set -x" mode
-# DEBUG_IPV6 & 2 prevents from executing any network configuration
-# DEBUG_IPV6 & 4 shows messages in the test section
-#DEBUG_IPV6=$[ 65535 - 1 -2 -4]
-DEBUG_IPV6=0
# Return values
# 0 = ok
# 1 = error occurs
# 2 = not enabled, i.e. no IPv6 kernel support or switched off by configuration
+
##### Test for IPv6 capabilites
function test_ipv6()
{
- if [ -z $DEBUG_IPV6 ] ; then DEBUG_IPV6=0; fi
- if ! [ $[ $DEBUG_IPV6 & 4 ] = 0 ] ; then
- echo " Tests for IPv6"
- fi
+ # Test for IPv6 enabled kernel
+
+ if ! [ -f /proc/net/if_inet6 ]; then
+ echo "Did not find IPv6 in kernel, trying to load module"
+ modprobe ipv6
+
+ if ! [ -f /proc/net/if_inet6 ]; then
+ echo "Kernel not compiled for IPv6 - stop!"
+ return 2
+ fi
+ fi
+
+ # Test for IPv6 enabled needed binaries
+
+ if ! ifconfig -? 2>&1 | grep -q "(IPv6)"; then
+ echo "'`which ifconfig`' (net-tools) not compiled for IPv6 - stop!"
+ return 2
+ fi
+
+ if ! route -? 2>&1 | grep -q "(IPv6)"; then
+ echo "'`which route`' (net-tools) not compiled for IPv6 - stop!"
+ return 2
+ fi
+
+
+ return 0
+}
+
+##### Control IPv6 forwarding
+# Display usage
+function forwarding_ipv6_usage() {
+ echo "Usage: $0 yes|no [device]"
+}
+
+
+# Control IPv6 forwarding
+# $1: control [yes|no|on|off]
+# $2: network device (if not given, global IPv6 forwarding is set)
+function forwarding_ipv6() {
+ control=$1
+ device=$2 # maybe empty
+
+ if [ -z $control ]; then
+ echo "Missing option forwarding control'"
+ forwarding_ipv6_usage
+ return 1
+ fi
+
+ if ! [ "$control" = "yes" -o "$control" = "no" -o "$control" = "on" -o "$control" = "off" ]; then
+ echo "Don't understand forwarding control option '$control'"
+ forwarding_ipv6_usage
+ return 1
+ fi
+
+ # Device "lo" need no IPv6 configuration
+ if [ "$device" = "lo" ]; then
+ return 0;
+ fi
+
+ # Run IPv6 test
+ test_ipv6 || return
- # Test for IPv6 kernel
- if ! [ $[ $DEBUG_IPV6 & 4 ] = 0 ] ; then
- echo -n " Test kernel for IPv6..."
- fi
- if ! [ -f /proc/net/if_inet6 ]; then
- echo "Did not find IPv6 in kernel, trying to load module"
- modprobe ipv6
+ if [ "$control" = "yes" -o "$control" = "on" ]; then
+ status=1
+ else
+ status=0
+ fi
+
+ # Global control? (if no device is given)
+ if [ -z $device ]; then
+ if [ -f /proc/sys/net/ipv6/conf/all/forwarding ]; then
+ echo "$status" > /proc/sys/net/ipv6/conf/all/forwarding
+ fi
+ fi
- if ! [ -f /proc/net/if_inet6 ]; then
- if ! [ $[ $DEBUG_IPV6 & 4 ] = 0 ] ; then
- echo "Not compiled for IPv6 - stop!"
- else
- echo "Kernel not compiled for IPv6 - stop!"
- fi
- return 2
- fi
- else
- if ! [ $[ $DEBUG_IPV6 & 4 ] = 0 ] ; then
- echo " Ok!"
- fi
- fi
-
- # Test for IPv6 enabled needed binaries
- if ! [ $[ $DEBUG_IPV6 & 4 ] = 0 ] ; then
- echo n " Test binaries for IPv6 capability..."
- fi
-
- if ! ifconfig -? 2>&1 | grep -q "(IPv6)"; then
- echo "'`which ifconfig`' (net-tools) not compiled for IPv6 - stop!"
- return 2
- fi
+ # Per device control
+ if [ ! -z $device ]; then
+ if [ -f /proc/sys/net/ipv6/conf/$device/forwarding ]; then
+ echo "$string IPv6 forwarding for device '$device'"
+ echo "$status" > /proc/sys/net/ipv6/conf/$device/forwarding
+ fi
+ fi
- if ! route -? 2>&1 | grep -q "(IPv6)"; then
- echo "'`which route`' (net-tools) not compiled for IPv6 - stop!"
- return 2
- fi
-
- if ! [ $[ $DEBUG_IPV6 & 4 ] = 0 ] ; then
- echo " Ok!"
- fi
-
- # Info about executing
- if [ $[ $DEBUG_IPV6 > 0 ] = 1 ]; then
- echo " Executing in DEBUG_IPV6 mode: $DEBUG_IPV6"
- fi
}
-##### Static route configuration
+
+##### Static IPv6 route configuration
# Display usage
-function ifup_ipv6_route_usage() {
+function ifupdown_ipv6_route_usage() {
echo $"Usage: $0 IPv6-network IPv6-gateway [device]"
}
-# set route
+# Set static IPv6 route
+# $1: IPv6 network to route
+# $2: IPv6 gateway over which $1 should be routed
+# $3: Interface (optional)
function ifup_ipv6_route() {
networkipv6=$1
gatewayipv6=$2
@@ -90,31 +131,37 @@ function ifup_ipv6_route() {
if [ -z $networkipv6 ]; then
echo $"Missing option 'IPv6-network'"
- ifup_ipv6_route_usage
+ ifupdown_ipv6_route_usage
return 1
fi
if [ -z $gatewayipv6 ]; then
- echo $"Missing option 'IPv6-gateway'"
- ifup_ipv6_route_usage
+ echo "Missing option 'IPv6-gateway'"
+ ifupdown_ipv6_route_usage
return 1
fi
- # Run IPv6 test
+ # Device "lo" need no IPv6 configuration
+ if [ "$device" = "lo" ]; then
+ return 0;
+ fi
+
+ # Run IPv6 test
test_ipv6 || return
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set -x
if [ -z $device ]; then
- route -A inet6 add $networkipv6 gw $gatewayipv6
+ route -A inet6 add $networkipv6 gw $gatewayipv6
else
- route -A inet6 add $networkipv6 gw $gatewayipv6 dev $device
+ route -A inet6 add $networkipv6 gw $gatewayipv6 dev $device
fi
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set +x
}
-# delete route
+# Delete static IPv6 route
+# $1: IPv6 network to route
+# $2: IPv6 gateway over which $1 should be routed
+# $3: Interface (optional)
function ifdown_ipv6_route() {
networkipv6=$1
gatewayipv6=$2
@@ -132,210 +179,319 @@ function ifdown_ipv6_route() {
return 1
fi
- # Run IPv6 test
+ # Device "lo" need no IPv6 configuration
+ if [ "$device" = "lo" ]; then
+ return 0;
+ fi
+
+ # Run IPv6 test
test_ipv6 || return
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set -x
if [ -z $device ]; then
- route -A inet6 del $networkipv6 gw $gatewayipv6
+ echo "Delete IPv6 route '$networkipv6' gateway '$gatewayipv6'"
+ route -A inet6 del $networkipv6 gw $gatewayipv6
else
- route -A inet6 del $networkipv6 gw $gatewayipv6 dev $device
+ route -A inet6 del $networkipv6 gw $gatewayipv6 dev $device
fi
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set +x
}
-##### tunnel configuration
+##### automatic tunneling configuration
-# Display usage
-function ifup_ipv6_tunnel_usage() {
- echo $"Usage: $0 interfacename IPv4-tunneladdress IPv6-route"
+## Configure automatic tunneling up
+function ifup_ipv6_autotunnel() {
+
+ # Run IPv6 test
+ test_ipv6 || return
+
+
+ # enable IPv6-over-IPv4 tunnels
+ if ifconfig sit0 | grep -q "UP "; then
+ # already up, do nothing
+ true
+ else
+ # basic tunnel device to up
+ ifconfig sit0 up
+
+ # Switch on forwarding
+ forwarding_ipv6 on sit0
+ fi
+
+}
+
+
+## Configure automatic tunneling down
+function ifdown_ipv6_autotunnel() {
+
+ # Run IPv6 test
+ test_ipv6 || return
+
+
+ # disable IPv6-over-IPv4 tunnels (if a tunnel is no longer up)
+ if route -A inet6 -n | grep sit0 | grep -v -q "^::"; then
+ # existing routes, do nothing
+ true
+ else
+ # basic tunnel device to down
+ echo "Bring down basic tunnel device 'sit0'"
+ # Switch off forwarding
+ forwarding_ipv6 off sit0
+
+ ifconfig sit0 down
+ fi
+
+}
+
+
+##### static tunneling configuration
+
+function ifupdown_ipv6_tunnel_usage() {
+ echo "Usage: $0 interfacename IPv4-tunneladdress IPv6-route"
}
-## Configure tunnels up
+
+## Configure static tunnels up
+# $1: Interface (not needed - dummy)
+# $2: IPv4 address of foreign tunnel
+# $3: IPv6 route through this tunnel
function ifup_ipv6_tunnel() {
device=$1
addressipv4tunnel=$2
routeipv6=$3
if [ -z $device ]; then
- echo $"Missing option 'device'"
- ifup_ipv6_tunnel_usage
+ echo "Missing option 'device'"
+ ifupdown_ipv6_tunnel_usage
return 1
fi
if [ -z $addressipv4tunnel ]; then
- echo $"Missing option 'IPv4-tunneladdress'"
- ifup_ipv6_tunnel_usage
+ echo "Missing option 'IPv4-tunneladdress'"
+ ifupdown_ipv6_tunnel_usage
return 1
fi
if [ -z $routeipv6 ]; then
- echo $"Missing option 'IPv6-route'"
- ifup_ipv6_tunnel_usage
+ echo "Missing option 'IPv6-route'"
+ ifupdown_ipv6_tunnel_usage
return 1
fi
- # Run IPv6 test
+ # Run IPv6 test
test_ipv6 || return
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set -x
- # enable IPv6-over-IPv4 tunnels
- if ifconfig sit0 | grep -q "UP "; then
- # already up, do nothing
- true
- else
- # basic tunnel device to up
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ] ; then
- ifconfig sit0 up
- fi
- fi
-
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ]; then
- # Set up a tunnel
+ # enable general IPv6-over-IPv4 tunneling
+ ifup_ipv6_autotunnel
+
+ # Set up a tunnel
route -A inet6 add $routeipv6 gw ::$addressipv4tunnel dev sit0
- fi
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set +x
}
-## Configure tunnels down
+## Configure static tunnels down
+# $1: Interface (not used - dummy)
+# $2: IPv4 address of foreign tunnel
+# $3: IPv6 route through this tunnel
function ifdown_ipv6_tunnel() {
device=$1
addressipv4tunnel=$2
routeipv6=$3
if [ -z $device ]; then
- echo $"Missing option 'device'"
- ifup_ipv6_tunnel_usage
+ echo "Missing option 'device'"
+ ifupdown_ipv6_tunnel_usage
return 1
fi
if [ -z $addressipv4tunnel ]; then
- echo $"Missing option 'IPv4-tunneladdress'"
- ifup_ipv6_tunnel_usage
+ echo "Missing option 'IPv4-tunneladdress'"
+ ifupdown_ipv6_tunnel_usage
return 1
fi
if [ -z $routeipv6 ]; then
- echo $"Missing option 'IPv6-route'"
- ifup_ipv6_tunnel_usage
+ echo "Missing option 'IPv6-route'"
+ ifupdown_ipv6_tunnel_usage
return 1
fi
- # Run IPv6 test
+ # Run IPv6 test
test_ipv6 || return
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set -x
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ]; then
- # Set up a tunnel
+ # Set up a tunnel
route -A inet6 del $routeipv6 gw ::$addressipv4tunnel dev sit0
- fi
- # disable IPv6-over-IPv4 tunnels (if tunnel is no longer up)
- if route -A inet6 -n | grep sit0 | grep -v -q "^::"; then
- # existing routes, do nothing
- true
- else
- # basic tunnel device to down
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ] ; then
- ifconfig sit0 down
- fi
- fi
+ # disable IPv6-over-IPv4 tunneling (if no longer a tunnel is up)
+ ifdown_ipv6_autotunnel
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set +x
}
-
-##### Interface configuration
-# Display usage
-function ifup_ipv6_usage() {
- echo $"Usage: $0 interfacename IPv6-address IPv6-prefixlength"
+##### Interface configuration
+function ifupdown_ipv6_usage() {
+ echo "Usage: $0 interfacename IPv6-address [IPv6-prefixlength]"
}
-## Configure interfaces up
+## Add an IPv6 address for given interface
+# $1: Interface
+# $2: IPv6 address
+# $3: IPv6 prefix length (optional)
function ifup_ipv6_real() {
device=$1
address=$2
prefixlength=$3
if [ -z $device ]; then
- echo $"Missing option 'device'"
- ifup_ipv6_usage
+ echo "Missing option 'device'"
+ ifupdown_ipv6_usage
return 1
fi
+ # Device "lo" need no IPv6 configuration
+ if [ "$device" = "lo" ]; then
+ return 0;
+ fi
+
if [ -z $address ]; then
- echo $"Missing option 'IPv6-address'"
- ifup_ipv6_usage
+ echo "Missing option 'IPv6-address'"
+ ifupdown_ipv6_usage
return 1
fi
- if [ -z $prefixlength ]; then
- echo $"Missing option 'Prefixlength'"
- ifup_ipv6_usage
- return 1
+ # Test status of interface
+ if ifconfig $device | grep -q "UP "; then
+ # Interface is up
+ true
+ else
+ # no IPv4 for this interface, interface is still down, do up ...
+ ifconfig $device up
fi
- # Run IPv6 test
+ # Extract address parts
+ prefixlength_implicit="`echo $address | awk -F/ '{ print $2 }'`"
+ address_implicit="`echo $address | awk -F/ '{ print $1 }'`"
+
+ # Overwrite optional given one
+ if [ ! -z $prefixlength_implicit ]; then
+ prefixlength=$prefixlength_implicit
+ elif [ -z $prefixlength ]; then
+ prefixlength=128
+ fi
+
+ # Build IPv6 address
+ address="$address_implicit/$prefixlength"
+
+ # Run IPv6 test
test_ipv6 || return
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set -x
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ]; then
- ifconfig $device add $address/$length || return 2
+ # Only add, if address do not already exist
+ address_configured="`ifconfig $device | grep "inet6 addr:" | grep "$address" | awk '{ print $3 }'`"
+ address_configured_type="`ifconfig $device | grep "inet6 addr:" | grep "$address" | awk '{ print $4 }'`"
+
+ if [ "$address_configured" = "$address" ]; then
+ true
+ else
+ ifconfig $device add $address || return 2
fi
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ]; then
- route -A inet6 add $address/$prefixlength dev $device || return 2
- fi
+# route -A inet6 add $address/$prefixlength dev $device || return 2
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set +x
}
-## Configure interfaces down
+## Remove all IPv6 routes and addresses for given interface
+# cleanup to prevent kernel crashes
+# $1: Interface
+function ifdown_ipv6_real_all() {
+ device=$1
+
+ if [ -z $device ]; then
+ echo "Missing option 'device'"
+ echo "Usage: ifdown_ipv6_real_all interfacename"
+ return 1
+ fi
+
+ # Get all IPv6 routes through given interface and remove them
+ route -A inet6 | grep $device | while read ipv6net nexthop flags metric ref use iface args; do
+ if [ "$device" = "$iface" ]; then
+ if echo $flags | grep -v -q "A"; then
+ # Only non addrconf (automatic installed) routes should be removed
+ ifdown_ipv6_route $ipv6net $nexthop $iface
+ fi
+ fi
+ done
+
+ # Get all IPv6 addresses assigned to given interface and remove them
+ ifconfig $device | grep "inet6 addr:" | awk '{ print $3 }' | while read ipv6addr args; do
+ ifdown_ipv6_real $device $ipv6addr
+ done
+}
+
+## Remove an IPv6 address on given interface
+# $1: Interface
+# $2: IPv6 address
+# $3: IPv6 prefix length (optional)
function ifdown_ipv6_real() {
device=$1
address=$2
prefixlength=$3
if [ -z $device ]; then
- echo $"Missing option 'device'"
- ifup_ipv6_usage
+ echo "Missing option 'device'"
+ ifupdown_ipv6_usage
return 1
fi
+ # Device "lo" need no IPv6 configuration
+ if [ "$device" = "lo" ]; then
+ return 0;
+ fi
+
if [ -z $address ]; then
- echo $"Missing option 'IPv6-address'"
- ifup_ipv6_usage
+ echo "Missing option 'IPv6-address'"
+ ifupdown_ipv6_usage
return 1
fi
- if [ -z $prefixlength ]; then
- echo $"Missing option 'Prefixlength'"
- ifup_ipv6_usage
- return 1
+ # Extract address parts
+ prefixlength_implicit="`echo $address | awk -F/ '{ print $2 }'`"
+ address_implicit="`echo $address | awk -F/ '{ print $1 }'`"
+
+ # Overwrite optional given one
+ if [ ! -z $prefixlength_implicit ]; then
+ prefixlength=$prefixlength_implicit
+ elif [ -z $prefixlength ]; then
+ prefixlength=128
fi
- # Run IPv6 test
+ # Build IPv6 address
+ address="$address_implicit/$prefixlength"
+
+ # Run IPv6 test
test_ipv6 || return
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set -x
+#
+# route -A inet6 del $address/$prefixlength dev $device || return 2
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ]; then
- route -A inet6 del $address/$prefixlength dev $device || return 2
- fi
- if [ $[ $DEBUG_IPV6 & 2 ] = 0 ]; then
- ifconfig $device del $address/$length || return 2
+ # Only remove, if address exists and is not link-local (prevents from kernel crashing)
+ address_configured="`ifconfig $device | grep "inet6 addr:" | grep "$address" | awk '{ print $3 }'`"
+ address_configured_type="`ifconfig $device | grep "inet6 addr:" | grep "$address" | awk '{ print $4 }'`"
+ if [ ! -z "$address_configured" ]; then
+ if [ "$address_configured_type" = "Scope:Link" ]; then
+ true
+ else
+ ifconfig $device del $address || return 2
+ fi
+ else
+ true
fi
- [ $[ $DEBUG_IPV6 & 1 ] = 0 ] || set +x
}
+
diff --git a/sysconfig/static-routes-ipv6 b/sysconfig/static-routes-ipv6
index 79733cd6..92df51fc 100644
--- a/sysconfig/static-routes-ipv6
+++ b/sysconfig/static-routes-ipv6
@@ -1,9 +1,30 @@
-# static-routes-ipv6
+# file: /etc/sysconfig/static-routes-ipv6
#
-# Taken from:
-# (P) & (C) 2000 Peter Bieringer <pb@bieringer.de>
+# description: this file contains all static IPv6 routes
+# description: Here you can specify several routes to specified gateways
+# description: and also route through a virtual tunnel interface
+#
+# (P) 2000 by Peter Bieringer <pb@bieringer.de>
+#
+# Changes to
+# 20000704: initial taken from my network-ip6.conf
+# 20001125: remove (C)opyright (makes no sense in a configuration file)
+# and add path to file information
-#Device IPv6 network to route IPv6 gateway address
+#Device IPv6 network to route IPv6 gateway address
#eth0 fec0:0:0:2::/64 fec0:0:0:1:0:0:0:20
#eth0 3ffe::/16 3ffe:0400:0100:f102:0:0:0:1
-#sit1 2001::/16
+
+## enable following as "default" routes through a gateway (but review gateway!)
+# IPv6 Testing Address Allocation (6bone testbed)
+#eth0 3ffe::/16 3ffe:0400:0100:f102:0:0:0:1
+# IPv6 official addresses
+#eth0 2000::/3 3ffe:0400:0100:f102:0:0:0:1
+
+
+## enable following as "default" routes through a tunnel
+## Virtual tunnel interface IPv6 network to route through
+# IPv6 Testing Address Allocation (6bone testbed)
+#sit1 3ffe::/16
+# IPv6 official addresses
+#sit1 2000::/3