aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2001-07-24 20:09:07 +0000
committerBill Nottingham <notting@redhat.com>2001-07-24 20:09:07 +0000
commitee673429a7dae3de798f97ec323ea2530c22348e (patch)
treef5bb9cc241fe4cfbccfb06b4ebf1ff04c5276703 /sysconfig/network-scripts
parent4bd3e0cd786167ab7cb8bf7e33974c482fa44296 (diff)
downloadinitscripts-ee673429a7dae3de798f97ec323ea2530c22348e.tar
initscripts-ee673429a7dae3de798f97ec323ea2530c22348e.tar.gz
initscripts-ee673429a7dae3de798f97ec323ea2530c22348e.tar.bz2
initscripts-ee673429a7dae3de798f97ec323ea2530c22348e.tar.xz
initscripts-ee673429a7dae3de798f97ec323ea2530c22348e.zip
ipv6 update (<pekkas@netcore.fi>)
Diffstat (limited to 'sysconfig/network-scripts')
-rwxr-xr-xsysconfig/network-scripts/ifdown-ipv648
-rwxr-xr-xsysconfig/network-scripts/ifdown-sit11
-rwxr-xr-xsysconfig/network-scripts/ifup-ipv675
-rwxr-xr-xsysconfig/network-scripts/ifup-sit47
-rwxr-xr-xsysconfig/network-scripts/init.ipv6-global8
-rw-r--r--sysconfig/network-scripts/network-functions-ipv6142
6 files changed, 167 insertions, 164 deletions
diff --git a/sysconfig/network-scripts/ifdown-ipv6 b/sysconfig/network-scripts/ifdown-ipv6
index d111d1cb..8f4319ba 100755
--- a/sysconfig/network-scripts/ifdown-ipv6
+++ b/sysconfig/network-scripts/ifdown-ipv6
@@ -8,7 +8,7 @@
#
# RHL integration assistance by Pekka Savola <pekkas@netcore.fi>
#
-# Version 2001-05-22d
+# Version 2001-07-15
#
# Uses following information from /etc/sysconfig/network:
# NETWORKING_IPV6=yes|no: controls IPv6 initialization (global setting)
@@ -36,14 +36,10 @@ CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config
-# Test if IPv6 is globally enabled
-if [ ! "${NETWORKING_IPV6}" = "yes" ]; then
- # Global IPv6 switch not enabled, end now
- exit 0
-fi
+# Test whether IPv6 should be configured, else stop
+[ "${NETWORKING_IPV6}" = "yes" ] || exit 0
if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then
- # IPv6 setup isn't well
exit 1
fi
@@ -68,7 +64,6 @@ if [ "$valid6to4config" = "yes" ]; then
if [ "$IPV6TO4_CONTROL_RADVD" = "yes" ]; then
# stop RADVD from distributing no longer usable 6to4 prefixes
if [ -z "$IPV6TO4_RADVD_PIDFILE" ]; then
- # Take default
IPV6TO4_RADVD_PIDFILE="/var/run/radvd/radvd.pid"
fi
# Send SIGHUP to radvd
@@ -92,8 +87,43 @@ if [ "$valid6to4config" = "yes" ]; then
done
fi
+ # Detect type of address, whether it is IPv4 or IPv6
+ if testipv6_valid $IPV6TO4_RELAY; then
+ relay6to4type="ipv6"
+ fi
+
# Delete all static IPv6to4 routes
- ifdown_ipv6_route_all sit0 ::$IPV6TO4_RELAY
+ if [ "$relay6to4type" = "ipv6" ]; then
+ ifdown_ipv6_route_all sit0 $IPV6TO4_RELAY
+ else
+ ifdown_ipv6_route_all sit0 ::$IPV6TO4_RELAY
+ fi
+
+ # Delete old 6to4 routes, even if IPV6TO4_RELAY was changed
+ if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
+ grep -w "^sit0" /etc/sysconfig/static-routes-ipv6 | while read device network dummy; do
+ if [ "$EXISTS_ipv6calc" = "yes" ]; then
+ # Convert given network to compressed one
+ network="`ipv6calc --addr_to_compressed $network`"
+ fi
+ LC_ALL=C route -A inet6 | grep "^$network" | while read destination nexthop flags metric ref use iface dummy; do
+ if ! [ "$device" = "$iface" -a "$network" = "$destination" ]; then
+ continue
+ fi
+ # Look for routes to a compatible IPv4 address, delete them
+ if echo $nexthop | egrep -q '^::[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'; then
+ ifdown_ipv6_route $destination $nexthop $iface
+ fi
+ # Look for routes to a IPv6to4 address, delete them
+ if echo $nexthop | egrep -q '^2002::'; then
+ ifdown_ipv6_route $destination $nexthop $iface
+ fi
+ done
+ done
+ fi
+
+ # Delete 6to4 route
+ ifdown_ipv6_route 2002::/16 :: sit0
# Delete all configured 6to4 address
ifdown_ipv6to4_all sit0
diff --git a/sysconfig/network-scripts/ifdown-sit b/sysconfig/network-scripts/ifdown-sit
index a2a70c16..1fa4dad9 100755
--- a/sysconfig/network-scripts/ifdown-sit
+++ b/sysconfig/network-scripts/ifdown-sit
@@ -8,7 +8,7 @@
#
# RHL integration assistance by Pekka Savola <pekkas@netcore.fi>
#
-# Version 2001-05-22d
+# Version 2001-07-15a
#
# Uses following information from /etc/sysconfig/network:
# NETWORKING_IPV6=yes|no: controls IPv6 initialization (global setting)
@@ -31,14 +31,10 @@ CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config
-# Test if IPv6 is up
-if [ ! "${NETWORKING_IPV6}" = "yes" ]; then
- # Global IPv6 switch not enabled, end now
- exit 0
-fi
+# Test whether IPv6 should be configured, else stop
+[ "${NETWORKING_IPV6}" = "yes" ] || exit 0
if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then
- # IPv6 setup isn't well
exit 1
fi
@@ -54,7 +50,6 @@ if [ "$DEVICE" = "sit0" ]; then
elif [ ! -z "$IPV6TUNNELIPV4" ]; then
if [ "$IPV6_TUNNELMODE" = "NBMA" ]; then
if [ ! -z "$IPV6ADDR" ]; then
- # Numbered tunnel
ifdown_ipv6_real sit0 $IPV6ADDR
fi
diff --git a/sysconfig/network-scripts/ifup-ipv6 b/sysconfig/network-scripts/ifup-ipv6
index b8a5c71c..cd5d0062 100755
--- a/sysconfig/network-scripts/ifup-ipv6
+++ b/sysconfig/network-scripts/ifup-ipv6
@@ -8,7 +8,7 @@
#
# RHL integration assistance by Pekka Savola <pekkas@netcore.fi>
#
-# Version 2001-05-22d
+# Version 2001-07-16
#
# Uses following information from "/etc/sysconfig/network":
# NETWORKING_IPV6=yes|no: controls IPv6 initialization (global setting)
@@ -22,10 +22,11 @@
# defaults:
# IPV6FORWARDING=yes: IPV6_AUTOCONF=no, IPV6_ROUTER=yes
# IPV6FORWARDING=no: IPV6_AUTOCONF=yes
+# IPV6_MTU=<MTU for IPv6>: controls IPv6 MTU for this link [optional]
#
# Optional for 6to4 tunneling:
# IPV6TO4INIT=yes|no: controls 6to4 tunneling setup
-# IPV6TO4_RELAY=<ipv4address>: IPv4 address of the remote 6to4 relay
+# IPV6TO4_RELAY=<ipv4address|ipv6to4address>: IPv4/IPv6to4 address of the remote 6to4 relay
# IPV6TO4_IPV4ADDR=<ipv6address>: overwrite local IPv4 address [optional]
# IPV6TO4_ROUTING="eth0-:f101::0/64 eth1-:f102::0/64": information to setup local subnetting
# IPV6TO4_CONTROL_RADVD=yes|no: controls radvd triggering [optional]
@@ -47,20 +48,13 @@ CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config
-# Test if IPv6 configuration is enabled
-if [ ! "$IPV6INIT" = "yes" ]; then
- # not enabled, stop here
- exit 0
-fi
+# Test whether IPv6 configuration is enabled for this interface, else stop
+[ "$IPV6INIT" = "yes" ] || exit 0
-# Test if IPv6 is up
-if [ ! "${NETWORKING_IPV6}" = "yes" ]; then
- # Global IPv6 switch not enabled, end now
- exit 0
-fi
+# Test whether IPv6 should be configured, else stop
+[ "${NETWORKING_IPV6}" = "yes" ] || exit 0
if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then
- # IPv6 setup isn't well
exit 1
fi
@@ -85,19 +79,16 @@ if [ "$IPV6FORWARDING" = "yes" ]; then
# Check, if global IPv6 forwarding was already set by global script
if [ $ipv6_global_forwarding_current -ne 1 ]; then
- # Forwarding enabled, but not set, display warning
echo $"Global IPv6 forwarding is enabled in configuration, but not currently enabled in kernel"
- echo $"Please restart network with '/etc/rc.d/init.d/network restart'"
+# echo $"Please restart network with '/sbin/service network restart'"
fi
ipv6_local_forwarding=1
ipv6_local_auto=0
if [ "$IPV6_ROUTER" = "no" ]; then
- # Interface should not act as a Router
ipv6_local_forwarding=0
fi
if [ "$IPV6_AUTOCONF" = "yes" ]; then
- # Interface should be autoconfigured
ipv6_local_auto=1
fi
else
@@ -105,15 +96,13 @@ else
# Check, if global IPv6 forwarding was already set by global script
if [ $ipv6_global_forwarding_current -ne 0 ]; then
- # Forwarding disabled, but not set, display warning
echo $"Global IPv6 forwarding is disabled in configuration, but not currently disabled in kernel"
- echo $"Please restart network with '/etc/rc.d/init.d/network restart'"
+# echo $"Please restart network with '/sbin/service network restart'"
fi
ipv6_local_forwarding=0
ipv6_local_auto=1
if [ "$IPV6_AUTOCONF" = "no" ]; then
- # Interface should not be autoconfigured
ipv6_local_auto=0
fi
fi
@@ -121,6 +110,11 @@ sysctl -w net.ipv6.conf.$DEVICE.forwarding=$ipv6_local_forwarding >/dev/null
sysctl -w net.ipv6.conf.$DEVICE.accept_ra=$ipv6_local_auto >/dev/null
sysctl -w net.ipv6.conf.$DEVICE.accept_redirects=$ipv6_local_auto >/dev/null
+# Set IPv6 MTU, if given
+if [ ! -z "$IPV6_MTU" ]; then
+ ipv6_set_mtu $DEVICE $IPV6_MTU
+fi
+
# Setup additional IPv6 addresses from list
if [ ! -z "$IPV6ADDR_SECONDARIES" ]; then
for ipv6addr in $IPV6ADDR_SECONDARIES; do
@@ -130,10 +124,8 @@ fi
# Setup additional static IPv6 routes on specified interface
if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
- grep "^$DEVICE\W" /etc/sysconfig/static-routes-ipv6 | while read device args; do
- if [ "$device" = "$DEVICE" ]; then
- ifup_ipv6_route $args $DEVICE
- fi
+ grep -w "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device args; do
+ ifup_ipv6_route $args $DEVICE
done
fi
@@ -152,7 +144,6 @@ if [ "$IPV6TO4INIT" = "yes" ]; then
fi
fi
if [ ! -z "$ipv4addr" ]; then
- # Test for non-global IPv4 address
if ! testipv4_globalusable $ipv4addr; then
echo $"Given IPv4 address $ipv4addr is not a globally usable one, 6to4 configuration is not valid!"
valid6to4config="no"
@@ -162,8 +153,19 @@ if [ "$IPV6TO4INIT" = "yes" ]; then
valid6to4config="no"
fi
if [ "$valid6to4config" = "yes" ]; then
- if ! testipv4_globalusable $IPV6TO4_RELAY; then
- echo $"Given IPv4 address of relay is not a globally usable one, 6to4 configuration is not valid!"
+ if testipv4_globalusable $IPV6TO4_RELAY 2>/dev/null; then
+ true
+ elif testipv6_valid $IPV6TO4_RELAY; then
+ relay6to4type="ipv6"
+ if echo $IPV6TO4_RELAY | grep -q "^2002:"; then
+ # IPv6 address is a 6to4 (further tests not be implemented at the moment)
+ true
+ else
+ echo $"Given IPv6 address of relay is not a 6to4 one, 6to4 configuration is not valid!"
+ valid6to4config="no"
+ fi
+ else
+ echo $"Given address of relay is not a globally usable one, 6to4 configuration is not valid!"
valid6to4config="no"
fi
fi
@@ -173,27 +175,31 @@ if [ "$IPV6TO4INIT" = "yes" ]; then
fi
if [ "$valid6to4config" = "yes" ]; then
ifup_ipv6to4 $DEVICE $ipv4addr
+
+ # Add static routes
if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
- grep "^sit0" /etc/sysconfig/static-routes-ipv6 | while read device args; do
- if [ "$device" = "sit0" ]; then
- ifup_ipv6_route $args ::$IPV6TO4_RELAY sit0
+ grep -w "^sit0" /etc/sysconfig/static-routes-ipv6 | while read device network dummy; do
+ if [ "$relay6to4type" = "ipv6" ]; then
+ # Foreign 6to4 relay gateway as IPv6to4
+ ifup_ipv6_route $network $IPV6TO4_RELAY sit0
+ else
+ # Foreign 6to4 relay gateway as compatible IPv4
+ ifup_ipv6_route $network ::$IPV6TO4_RELAY sit0
fi
done
fi
if [ "$IPV6TO4_CONTROL_RADVD" = "yes" ]; then
- # RADVD is in use, so forwarding of IPv6 packets should be enabled
+ # RADVD is in use, so forwarding of IPv6 packets should be enabled, display warning
if [ $ipv6_global_forwarding_current -ne 1 ]; then
- # Forwarding not set, display warning
echo $"Using 6to4 and RADVD IPv6 forwarding usually should be enabled, but it isn't!"
fi
if [ -z "$IPV6TO4_RADVD_PIDFILE" ]; then
- # Take default
IPV6TO4_RADVD_PIDFILE="/var/run/radvd/radvd.pid"
fi
- # Send SIGHUP to radvd
+ # Send SIGHUP to radvd for prefix recalculation
if [ -f "$IPV6TO4_RADVD_PIDFILE" ]; then
pid="`cat $IPV6TO4_RADVD_PIDFILE`"
if [ ! -z "$pid" ]; then
@@ -204,7 +210,6 @@ if [ "$IPV6TO4INIT" = "yes" ]; then
fi
fi
if [ ! -z "$IPV6TO4_ROUTING" ]; then
- # Generate 6to4 address
ipv6to4prefix="`create6to4prefix $ipv4addr`"
if [ ! -z "$ipv6to4prefix" ]; then
# Add route to local networks
diff --git a/sysconfig/network-scripts/ifup-sit b/sysconfig/network-scripts/ifup-sit
index baf78a66..15ed67cd 100755
--- a/sysconfig/network-scripts/ifup-sit
+++ b/sysconfig/network-scripts/ifup-sit
@@ -8,7 +8,7 @@
#
# RHL integration assistance by Pekka Savola <pekkas@netcore.fi>
#
-# Version 2001-05-22d
+# Version 2001-07-17
#
# Uses following information from "/etc/sysconfig/network":
# NETWORKING_IPV6=yes|no: controls IPv6 initialization (global setting)
@@ -16,6 +16,7 @@
# Uses following information from "/etc/sysconfig/network-scripts/ifcfg-$1":
# IPV6INIT=yes|no: controls IPv6 configuration for this interface
# IPV6_TUNNELMODE=IP|NBMA: mode of tunnel creation [default: IP]
+# IPV6_MTU=<MTU for IPv6>: controls IPv6 MTU for this link [optional]
#
# For static tunnels
# IPV6TUNNELIPV4="<ipv4 address of foreign tunnel endpoint>"
@@ -34,18 +35,13 @@ CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config
-# Test if IPv6 configuration is enabled for this interface
-if [ ! "$IPV6INIT" = "yes" ]; then
- exit 0
-fi
+# Test whether IPv6 configuration is enabled for this interface, else stop
+[ "$IPV6INIT" = "yes" ] || exit 0
-# Test if IPv6 is up
-if [ ! "${NETWORKING_IPV6}" = "yes" ]; then
- exit 0
-fi
+# Test whether IPv6 should be configured, else stop
+[ "${NETWORKING_IPV6}" = "yes" ] || exit 0
if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then
- # IPv6 setup isn't well
exit 1
fi
@@ -58,36 +54,45 @@ test_ipv6 || exit 1
# Setup IPv6-in-IPv4 tunnel(s)
if [ "$DEVICE" = "sit0" ]; then
ifup_ipv6_autotunnel || exit 1
+
+ # Set IPv6 MTU, if given
+ if [ ! -z "$IPV6_MTU" ]; then
+ ipv6_set_mtu $DEVICE $IPV6_MTU
+ fi
elif [ ! -z "$IPV6TUNNELIPV4" ]; then
if [ "$IPV6_TUNNELMODE" = "NBMA" ]; then
- # NBMA-styled tunneling
if [ ! -z "$IPV6ADDR" ]; then
- # Numbered tunnel
ifup_ipv6_real sit0 $IPV6ADDR
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
+ grep -w "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
+ ifup_ipv6_tunnel $DEVICE $IPV6TUNNELIPV4 $ipv6route
done
fi
+
+ # Set IPv6 MTU, if given and in range
+ if [ ! -z "$IPV6_MTU" ]; then
+ ipv6_set_mtu sit0 $IPV6_MTU
+ fi
+
elif [ -z "$IPV6_TUNNELMODE" -o "$IPV6_TUNNELMODE" = "IP" ]; then
ifup_ipv6_tunneldev $DEVICE $IPV6TUNNELIPV4 || exit 1
+ # Set IPv6 MTU, if given and in range
+ if [ ! -z "$IPV6_MTU" ]; then
+ ipv6_set_mtu $DEVICE $IPV6_MTU
+ fi
+
if [ ! -z "$IPV6ADDR" ]; then
- # Numbered tunnel
ifup_ipv6_real $DEVICE $IPV6ADDR
fi
if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
- grep "^$DEVICE\W" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
- if [ "$device" = "$DEVICE" ]; then
- ifup_ipv6_route $ipv6route :: $DEVICE
- fi
+ grep -w "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
+ ifup_ipv6_route $ipv6route :: $DEVICE
done
fi
else
diff --git a/sysconfig/network-scripts/init.ipv6-global b/sysconfig/network-scripts/init.ipv6-global
index da46d4ba..aed005d8 100755
--- a/sysconfig/network-scripts/init.ipv6-global
+++ b/sysconfig/network-scripts/init.ipv6-global
@@ -8,7 +8,7 @@
#
# RHL integration assistance by Pekka Savola <pekkas@netcore.fi>
#
-# Version 2001-05-22d
+# Version 2001-07-15a
#
# Calling parameters:
# $1: action (currently supported: start|stop|showsysctl)
@@ -37,10 +37,8 @@ cd /etc/sysconfig/network-scripts
ACTION="$1"
POSITION="$2"
-# Test for IPv6 enabling
-if [ ! "${NETWORKING_IPV6}" = "yes" ]; then
- exit 0
-fi
+# Test whether IPv6 should be configured, else stop
+[ "${NETWORKING_IPV6}" = "yes" ] || exit 0
if [ ! -f /etc/sysconfig/network-scripts/network-functions-ipv6 ]; then
exit 1
diff --git a/sysconfig/network-scripts/network-functions-ipv6 b/sysconfig/network-scripts/network-functions-ipv6
index 6b4441a8..82c8d020 100644
--- a/sysconfig/network-scripts/network-functions-ipv6
+++ b/sysconfig/network-scripts/network-functions-ipv6
@@ -5,7 +5,7 @@
# Taken from:
# (P) & (C) 1997-2001 by Peter Bieringer <pb@bieringer.de>
#
-# Version: 2001-05-22d
+# Version: 2001-07-17a
#
# Extended address detection is enabled, if 'ipv6calc' is installed
# Available here: http://www.bieringer.de/linux/IPv6/tools/index.html#ipv6calc
@@ -23,7 +23,6 @@
##### Test for "ipv6calc" (used for better existing address detection)
EXISTS_ipv6calc=no
if which ipv6calc >/dev/null 2>&1; then
- # do checks, whether ipv6calc does what was expected
if ipv6calc --if_inet62addr 3ffe04000100f1010000000000000001 40 | grep -q -v '3ffe:400:100:f101::1/64'; then
false
elif ipv6calc --addr2if_inet6 3ffe:400:100::1/64 | grep -q -v '3ffe0400010000000000000000000001 00 40'; then
@@ -42,7 +41,6 @@ test_ipv6() {
local testflag=$1
- # Test for IPv6 enabled kernel
if ! [ -f /proc/net/if_inet6 ]; then
if [ "$testflag" = "testonly" ]; then
@@ -58,7 +56,6 @@ test_ipv6() {
fi
if [ ! -d /proc/sys/net/ipv6/conf/ ]; then
- # IPv6 related proc directory doesn't exist
return 2
fi
@@ -98,7 +95,6 @@ forwarding_ipv6() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
@@ -142,16 +138,10 @@ ifup_ipv6_route() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
- # Test, whether given IPv6 address is valid
- if ! testipv6_valid $networkipv6; then
- return 2
- fi
- if ! testipv6_valid $gatewayipv6; then
- return 2
- fi
+ testipv6_valid $networkipv6 || return 2
+ testipv6_valid $gatewayipv6 || return 2
if [ -z "$device" ]; then
@@ -195,16 +185,11 @@ ifdown_ipv6_route() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
# Test, whether given IPv6 address is valid
- if ! testipv6_valid $networkipv6; then
- return 2
- fi
- if ! testipv6_valid $gatewayipv6; then
- return 2
- fi
+ testipv6_valid $networkipv6 || return 2
+ testipv6_valid $gatewayipv6 || return 2
if [ -z "$device" ]; then
@@ -241,7 +226,6 @@ ifdown_ipv6_route_all() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
@@ -251,7 +235,6 @@ ifdown_ipv6_route_all() {
if [ ! -z "$gatewaymatch" ]; then
# Test if given gateway matches
if [ "$gatewaymatch" != "$nexthop" ]; then
- # No match, take next
continue
fi
fi
@@ -269,19 +252,16 @@ ifdown_ipv6_route_all() {
## Configure automatic tunneling up
ifup_ipv6_autotunnel() {
- # Run IPv6 test
test_ipv6 || return 2
# enable IPv6-over-IPv4 tunnels
if test_interface_status sit0; then
- # already up, do nothing
true
else
- # basic tunnel device to up
+ # bring up basic tunnel device
ifconfig sit0 up
- # Test, whether "up" has worked
if ! test_interface_status sit0; then
echo $"Tunnel device 'sit0' enabling didn't work - FATAL ERROR!"
return 2
@@ -299,12 +279,10 @@ ifup_ipv6_autotunnel() {
## Configure automatic tunneling down
ifdown_ipv6_autotunnel() {
- # Run IPv6 test
test_ipv6 || return 2
if test_interface_status sit0; then
- # still up?
# disable IPv6-over-IPv4 tunnels (if a tunnel is no longer up)
if LC_ALL=C route -A inet6 -n | grep "sit0\W*$" | awk '{ print $2 }' | grep -v -q "^::$"; then
@@ -314,15 +292,13 @@ ifdown_ipv6_autotunnel() {
# still existing IPv6 addresses, skip shutdown of sit0
true
else
- # basic tunnel device to down
- # Set sysctls proper
+ # take down basic tunnel device
sysctl -w net.ipv6.conf.sit0.forwarding=0 >/dev/null
sysctl -w net.ipv6.conf.sit0.accept_ra=0 >/dev/null
sysctl -w net.ipv6.conf.sit0.accept_redirects=0 >/dev/null
ifconfig sit0 down
- # Test, whether "down" has worked
if test_interface_status sit0; then
echo $"Tunnel device 'sit0' is still up - FATAL ERROR!"
return 2
@@ -351,7 +327,7 @@ ifup_ipv6_tunnel() {
fi
if [ -z "$addressipv4tunnel" ]; then
- echo $"Missing parameter 'IPv4-tunneladdress' (arg 2)"
+ echo $"Missing parameter 'IPv4-tunnel address' (arg 2)"
return 1
fi
@@ -360,14 +336,11 @@ ifup_ipv6_tunnel() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
# Test, whether given IPv6 address is valid
- if ! testipv6_valid $routeipv6; then
- return 2
- fi
+ testipv6_valid $routeipv6 || return 2
# enable general IPv6-over-IPv4 tunneling
@@ -397,33 +370,30 @@ ifdown_ipv6_tunnel() {
if [ -z "$device" ]; then
echo $"Missing parameter 'device' (arg 1)"
- ifupdown_ipv6_tunnel_usage
return 1
fi
if [ -z "$addressipv4tunnel" ]; then
echo $"Missing parameter 'IPv4-tunnel address' (arg 2)"
- ifupdown_ipv6_tunnel_usage
return 1
fi
if [ -z "$routeipv6" ]; then
echo $"Missing parameter 'IPv6-route' (arg 3)"
- ifupdown_ipv6_tunnel_usage
return 1
fi
- # Run IPv6 test
- test_ipv6 || return 2
+ test_ipv6 || return 2
+
# Delete a NBMA-styled tunnel
- ifdown_ipv6_route $routeipv6::$addressipv4tunnel sit0
+ ifdown_ipv6_route $routeipv6 ::$addressipv4tunnel sit0
if [ $? -ne 0 ]; then
return 2
fi
- # disable IPv6-over-IPv4 tunneling (if no longer a tunnel is up)
+ # disable IPv6-over-IPv4 tunneling (if this was the last tunnel)
ifdown_ipv6_autotunnel
}
@@ -431,7 +401,7 @@ ifdown_ipv6_tunnel() {
## Remove all IPv6 tunnels for a given tunnel endpoint
# $1: Interface (not used - dummy)
-# $2: IPv4-tunneladdress
+# $2: IPv4-tunnel address
ifdown_ipv6_tunnel_all() {
local idtuall_device=$1
local idtuall_tunnel=$2
@@ -442,11 +412,10 @@ ifdown_ipv6_tunnel_all() {
fi
if [ -z "$idtuall_tunnel" ]; then
- echo $"Missing parameter 'IPv4-tunneladdress' (arg 2)"
+ echo $"Missing parameter 'IPv4-tunnel address' (arg 2)"
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
@@ -460,7 +429,7 @@ ifdown_ipv6_tunnel_all() {
fi
done
- # disable IPv6-over-IPv4 tunneling (if no longer a tunnel is up)
+ # disable IPv6-over-IPv4 tunneling (if this was the last tunnel)
ifdown_ipv6_autotunnel
return 0
}
@@ -485,7 +454,7 @@ test_ipv6_address_exists() {
if [ "$EXISTS_ipv6calc" = "yes" ]; then
# Using ipv6calc and compare against /proc/net/if_inet6
- local convertresult="`LC_ALL=C ipv6calc --addr2if_inet6 $testaddr/$testprefix`"
+ local convertresult="`ipv6calc --addr2if_inet6 $testaddr/$testprefix`"
# Split in address, scope and prefix length
local test_addr="`echo $convertresult | awk '{ print $1 }'`"
local test_scope="`echo $convertresult | awk '{ print $2 }'`"
@@ -533,23 +502,15 @@ ifup_ipv6_real() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
- # Test, whether given IPv6 address is valid
- if ! testipv6_valid $address; then
- return 2
- fi
+ testipv6_valid $address || return 2
- # Test status of interface
if test_interface_status $device; then
- # Interface is already up
true
else
- # no IPv4 for this interface, interface is still down, do up ...
ifconfig $device up
- # Test, whether "up" has worked
if ! test_interface_status $device; then
echo $"Device '$device' enabling didn't work - FATAL ERROR!"
return 2
@@ -561,7 +522,7 @@ ifup_ipv6_real() {
local prefixlength_implicit="`echo $address | awk -F/ '{ print $2 }'`"
local address_implicit="`echo $address | awk -F/ '{ print $1 }'`"
- # Only add, if address do not already exist
+ # Only add if address does not already exist
test_ipv6_address_exists $device $address_implicit $prefixlength_implicit
retval=$?
if [ $retval -lt 10 ]; then
@@ -589,7 +550,6 @@ ifdown_ipv6_real_all() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
@@ -624,13 +584,9 @@ ifdown_ipv6_real() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
- # Test, whether given IPv6 address is valid
- if ! testipv6_valid $address; then
- return 2
- fi
+ testipv6_valid $address || return 2
# Extract address parts
@@ -664,7 +620,6 @@ testipv6_valid() {
if [ -z "$testipv6addr_valid" ]; then
- # nothing for testing
return 2
fi
@@ -713,7 +668,6 @@ testipv4_globalusable() {
if [ -z "$testipv4addr_globalusable" ]; then
- # nothing for testing
return 2
fi
@@ -823,23 +777,22 @@ ifup_ipv6to4() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
- # generate 6to4 address
+ # Generate 6to4 address
local prefix6to4="`create6to4prefix $localipv4`"
if [ $? -ne 0 -o -z "$prefix6to4" ]; then
return 2
fi
if [ -z "$localipv6to4suffix" ]; then
- local address6to4="${prefix6to4}::1/48"
+ local address6to4="${prefix6to4}::1/16"
else
- local address6to4="${prefix6to4}::${localipv6to4suffix}/48"
+ local address6to4="${prefix6to4}::${localipv6to4suffix}/16"
fi
- # enable general IPv6-over-IPv4 tunneling
+ # Enable general IPv6-over-IPv4 tunneling
ifup_ipv6_autotunnel
ifup_ipv6_real sit0 $address6to4
@@ -862,17 +815,15 @@ ifdown_ipv6to4_all() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
- # Get all configured 6to4 addresses
+ # Get all configured 6to4 addresses and delete them
LC_ALL=C ip addr show dev sit0 | grep inet6 | awk '{ print $2 }' | grep "^2002:" | while read ipv6to4addr; do
- # And delete them
ifdown_ipv6_real sit0 $ipv6to4addr
done
- # try to disable general IPv6-over-IPv4 tunneling
+ # Try to disable general IPv6-over-IPv4 tunneling
ifdown_ipv6_autotunnel
}
@@ -896,7 +847,6 @@ ifdown_ipv6to4() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
@@ -908,9 +858,9 @@ ifdown_ipv6to4() {
fi
if [ -z "$localipv6to4suffix" ]; then
- local address6to4="$prefix6to4::1/48"
+ local address6to4="$prefix6to4::1/16"
else
- local address6to4="${prefix6to4}::${localipv6to4suffix}/48"
+ local address6to4="${prefix6to4}::${localipv6to4suffix}/16"
fi
ifdown_ipv6_real sit0 $address6to4
@@ -918,7 +868,7 @@ ifdown_ipv6to4() {
return 2
fi
- # try to disable general IPv6-over-IPv4 tunneling
+ # Try to disable general IPv6-over-IPv4 tunneling
ifdown_ipv6_autotunnel
if [ $? -ne 0 ]; then
return 2
@@ -945,17 +895,15 @@ ifup_ipv6_tunneldev() {
fi
if [ -z "$addressipv4tunnel" ]; then
- echo $"Missing parameter 'IPv4-tunneladdress' (arg 2)"
+ echo $"Missing parameter 'IPv4-tunnel address' (arg 2)"
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
if ! test_interface_status $device; then
- # Get default TTL
local ttldefault="`sysctl net.ipv4.ip_default_ttl | awk '{ print $3 }'`"
if [ -z "$ttldefault" ]; then
local ttldefault=64
@@ -990,7 +938,6 @@ ifup_ipv6_tunneldev() {
ifconfig $device up
- # Test, whether creation did worked
if ! test_interface_status $device; then
echo $"Tunnel device '$device' bringing up didn't work - ERROR!"
return 2
@@ -1026,12 +973,10 @@ ifdown_ipv6_tunneldev() {
return 1
fi
- # Run IPv6 test
test_ipv6 || return 2
if test_interface_status $device; then
- # Shut down tunnel
ifdown_ipv6_real_all $device
else
if [ "$device" != "sit0" ]; then
@@ -1043,7 +988,6 @@ ifdown_ipv6_tunneldev() {
if ip tunnel | grep -q "^$device:" ; then
ip tunnel del $device
- # Test, whether removing did worked
if test_interface_status $device; then
false
fi
@@ -1055,3 +999,29 @@ ifdown_ipv6_tunneldev() {
return 0
}
+
+## Set IPv6 MTU for a device
+# $1: Interface
+# $2: IPv6 MTU
+ipv6_set_mtu() {
+ local device=$1
+ local ipv6_mtu=$2
+
+ if [ -z "$device" ]; then
+ echo $"Missing parameter 'device' (arg 1)"
+ return 1
+ fi
+
+ if [ -z "$ipv6_mtu" ]; then
+ echo $"Missing parameter 'IPv6 MTU' (arg 2)"
+ return 1
+ fi
+
+ # Check range
+ if [ $ipv6_mtu -lt 1280 -o $ipv6_mtu -gt 65535 ]; then
+ echo $"Given IPv6 MTU is out of range"
+ return 1
+ fi
+
+ sysctl -w net.ipv6.conf.$device.mtu=$ipv6_mtu >/dev/null
+}