]> git.ipfire.org Git - people/ms/network.git/blob - helpers/miredo-helper
456fa66d6483ee35096fa018272a292d0b283f84
[people/ms/network.git] / helpers / miredo-helper
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 LOG_FACILITY="miredo-helper"
23
24 . /usr/lib/network/functions
25
26 action="${STATE}"
27 assert isset action
28
29 zone="${IFACE}"
30 assert zone_exists ${zone}
31
32 log DEBUG "Called for zone=${zone} action=${action}."
33
34 case "${action}" in
35 up)
36 # Configure the requested MTU.
37 isset MTU && device_set_mtu ${zone} ${MTU}
38
39 # Bring up the device.
40 device_set_up ${zone}
41
42 # Apply the link-local address.
43 ip_address_add ${zone} "${LLADDRESS}/64"
44
45 # Apply the public IP address.
46 ip_address_add ${zone} "${ADDRESS}/32"
47
48 # Write all data to the routing database.
49 routing_db_set ${zone} ipv6 type "teredo"
50 routing_db_set ${zone} ipv6 local-ip-address "${ADDRESS}/32"
51 routing_db_set ${zone} ipv6 active 1
52
53 # Update the routing database.
54 routing_update ${zone} ipv6
55 routing_default_update
56 ;;
57
58 down)
59 # Remove the routing database and update the tables.
60 routing_db_remove ${zone} ipv6
61 routing_update ${zone} ipv6
62 routing_default_update
63
64 # Set down the device.
65 device_set_down ${zone}
66 ;;
67
68 destroy)
69 # Do nothing here.
70 ;;
71
72 *)
73 log ERROR "Unknown action passed: ${action}"
74 exit ${EXIT_ERROR}
75 ;;
76 esac
77
78 exit ${EXIT_OK}