summaryrefslogtreecommitdiff
path: root/templates/system/ipv6/disable-forwarding/node.def
blob: 323b99d68f35985b71f5b915920ea77958785be6 (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
priority: 400
help: Disable IPv6 forwarding on all interfaces

# Disable IPv6 forwarding for all interfaces we currently have,
# and set default such that it will be disabled on any new interfaces
# that come up after this.
#
create:
	sudo sh -c "echo 0 > /proc/sys/net/ipv6/conf/all/forwarding"
	sudo sh -c "echo 0 > /proc/sys/net/ipv6/conf/default/forwarding"

# Re-enable IPv6 forwarding globally.  But setting the global
# forwarding parameter under "all" has the side effect of setting the
# per-interface forwarding parameter for all interfaces.  Users may
# disable forwarding per-interface, so we have to restore the state of
# the per-interface parameter here.   A per-interface flag file under
# /var/run/vyatta/ tells us if forwarding is disabled on specific
# interfaces.  Restore default value of the forwarding parameter under
# "default" so that any new interfaces that come up after this will
# have forwarding enabled.
#
delete: 
	sudo sh -c "echo 1 > /proc/sys/net/ipv6/conf/all/forwarding"
	cd /proc/sys/net/ipv6/conf
	for i in * ; do
	    if [[ "$i" == "default" ]] ||
               [[ "$i" == "all" ]] ||
	       [[ ! -d "$i" ]]; then
		continue
	    fi
            if [[ -e /var/run/vyatta/ipv6_no_fwd.$i ]]; then
		sudo sh -c "echo 0 > $i/forwarding"
	    fi
	done
	sudo sh -c "echo 1 > /proc/sys/net/ipv6/conf/default/forwarding"
	#
	# If router advertisements were configured while global IPv6
	# forwarding was disabled, we will need to start the radvd daemon
	# now.
	running=$(pgrep -n radvd)
 	if [[ -z "$running" ]] &&
           [[ -e /etc/radvd.conf ]] &&
           [[ -x /etc/init.d/radvd ]]; then
		/etc/init.d/radvd start
	fi