aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifup-sit
blob: 15ed67cd856b827af173f2411e5b83abab8aa06a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
#
# ifup-sit
#
#
# Taken from:
# (P) & (C) 2000-2001 by Peter Bieringer <pb@bieringer.de>
#
# RHL integration assistance by Pekka Savola <pekkas@netcore.fi>
#
# Version 2001-07-17
#
# Uses following information from "/etc/sysconfig/network":
#  NETWORKING_IPV6=yes|no: controls IPv6 initialization (global setting)
#
# 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>"
#  IPV6ADDR=<ipv6address>/<prefixlength> [OPTIONAL: numbered tunnels]
#


# Get global network configuration
. /etc/sysconfig/network 

# Source IPv4 helper functions
cd /etc/sysconfig/network-scripts
. network-functions 

CONFIG=$1
[ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG
source_config  

# Test whether IPv6 configuration is enabled for this interface, else stop
[ "$IPV6INIT" = "yes" ] || exit 0

# 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
fi

# Source IPv6 helper functions	
. /etc/sysconfig/network-scripts/network-functions-ipv6

# IPv6 test, module loaded, exit if system is not IPv6-ready
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
		if [ ! -z "$IPV6ADDR" ]; then
			ifup_ipv6_real sit0 $IPV6ADDR
		fi

		# Add static IPv6 tunnel routes on specified virtual interface
		if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
			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
			ifup_ipv6_real $DEVICE $IPV6ADDR
		fi
			
		if [ -f /etc/sysconfig/static-routes-ipv6 ]; then
			grep -w "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do
				ifup_ipv6_route $ipv6route :: $DEVICE
			done
		fi
	else
		echo $"Tunnel creation mode '$IPV6_TUNNELMODE' not supported - skip!"
	fi
fi