3 # Miredo client hook script for Linux/iproute2
4 # Copyright © 2007 Rémi Denis-Courmont.
5 # Distributed under the terms of the GNU General Public License version 2.
10 # Linux default route default metric is 1024
11 # (we put 1029 so that Teredo is used as a last resort):
14 # Linux routing table ID
15 # (possible values: 1-252 from /etc/iproute/rt_tables):
18 # Linux routing rule priority
19 # (possible values: 1-32765, lowest number is highest priority):
22 # MTU for the tunnel interface
23 # (default: specified by the Teredo server, or 1280)
26 if ! test -x "$IP"; then
27 echo "$0: iproute2 is required! Please install it." >&2
31 # Nothing to do with destroy event
32 if test "$STATE" = "destroy"; then exit 0; fi
34 # If the source routing table is not configured, ignore it.
35 if ! "$IP" route show table
"$TABLE" >/dev
/null
2>&1; then
38 if test "$OLD_ADDRESS"; then
39 "$IP" -6 rule del from
"$OLD_ADDRESS" \
40 prio
"$PRIO" table
"$TABLE" 2>/dev
/null
42 "$IP" -6 route flush table
"$TABLE" 2>/dev
/null
45 "$IP" -6 route flush dev
"$IFACE" 2>/dev
/null
46 "$IP" -6 address flush dev
"$IFACE" 2>/dev
/null
48 "$IP" -6 link
set dev
"$IFACE" "$STATE"
50 "$IP" link
set dev
"$IFACE" mtu
"$MTU"
55 "$IP" -6 address add
"${LLADDRESS}/64" dev
"$IFACE"
56 "$IP" -6 address add
"${ADDRESS}/32" dev
"$IFACE"
57 "$IP" -6 route add default dev
"$IFACE" metric
"$METRIC"
59 if test "$TABLE"; then
60 "$IP" -6 route add default dev
"$IFACE" table
"$TABLE"
61 "$IP" -6 rule add from
"$ADDRESS" \
62 prio
"$PRIO" table
"$TABLE"
66 # This should be required when changing policy routing rules, but it
67 # seems to confuse certain kernels into removing our default route!
68 #"$IP" -6 route flush cache 2>/dev/null