2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
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. #
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. #
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/>. #
20 ###############################################################################
22 RADVD_CONFIGFILE
="/etc/radvd.conf"
24 function radvd_update
() {
25 # (Re-)write the configuration file
28 # Reload the radvd service.
32 function radvd_write_config
() {
33 config_header
"radv daemon configuration file" > ${RADVD_CONFIGFILE}
35 # Write the configuration for all zones.
37 for zone
in $
(zones_get_local
); do
38 __radvd_config_interface
${zone}
40 done >> ${RADVD_CONFIGFILE}
45 function __radvd_config_interface
() {
49 log DEBUG
"Writing radvd configuration for ${zone}."
51 # If the interface does not provide any routing information,
52 # we can skip this whole stuff.
53 if ! routing_db_exists
${zone} ipv6
; then
57 # Skip if zone is not active.
58 local active
=$
(routing_db_get
${zone} ipv6 active
)
59 [ "${active}" = "0" ] && return ${EXIT_OK}
61 # Skip if there is no prefix or prefix is link-local.
62 local addr
=$
(routing_db_get
${zone} ipv6 local-ip-address
)
63 if [ -z "${addr}" ] ||
[ "${addr:0:5}" = "fe80:" ]; then
66 local prefix
=$
(ipv6_get_network
${addr})
68 # Check if the subnet is configured by the DHCP server.
70 if dhcpd_subnet_match ipv6
"${prefix}"; then
74 print
"interface ${zone} {"
75 print
" AdvSendAdvert on;"
76 print
" MinRtrAdvInterval 3;"
77 print
" MaxRtrAdvInterval 10;"
78 print
" IgnoreIfMissing on;"
80 if enabled dhcpd
; then
81 print
" AdvManagedFlag on;"
82 print
" AdvOtherConfigFlag on;"
86 print
" prefix ${prefix} {"
87 print
" AdvOnLink on;"
89 if enabled dhcpd
; then
90 print
" AdvRouterAddr off;"
91 print
" AdvAutonomous off;"
93 print
" AdvRouterAddr on;"
94 print
" AdvAutonomous on;"
100 # Add the DNS configuration.
101 __radvd_config_dns
${zone}
107 function __radvd_config_dns
() {
110 # Do nothing, when this option is not enabled.
111 enabled DNS_ADVERTISE_SERVERS ||
return ${EXIT_OK}
113 # XXX it is kind of difficult to announce our local
117 for server
in $
(dns_server_list_sorted
); do
118 # Filter out non IPv6 addresses.
119 ipv6_is_valid
${server} ||
continue
121 servers
="${servers} ${server}"
124 # Remove whitespaces.
125 servers
=$
(echo ${servers})
127 # If there are no servers to announce, we stop right here.
128 if ! isset servers
; then
129 log DEBUG
"No servers to announce."
133 print
" RDNSS ${servers} {"
134 print
" # Use the defaults here."