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 prefix
=$
(routing_db_get
${zone} ipv6 local-ip-address
)
63 if [ -z "${prefix}" ] ||
[ "${prefix:0:5}" = "fe80:" ]; then
67 print
"interface ${zone} {"
68 print
" AdvSendAdvert on;"
69 print
" MinRtrAdvInterval 3;"
70 print
" MaxRtrAdvInterval 10;"
71 print
" IgnoreIfMissing on;"
73 print
" prefix ${prefix} {"
74 print
" AdvOnLink on;"
75 print
" AdvAutonomous on;"
76 print
" AdvRouterAddr on;"
80 # Add the DNS configuration.
81 __radvd_config_dns
${zone}
87 function __radvd_config_dns
() {
90 # Do nothing, when this option is not enabled.
91 enabled DNS_ADVERTISE_SERVERS ||
return ${EXIT_OK}
93 # XXX it is kind of difficult to announce our local
97 for server
in $
(dns_server_list_no_priority
); do
98 # Filter out non IPv6 addresses.
99 ipv6_is_valid
${server} ||
continue
101 servers
="${servers} ${server}"
104 # Remove whitespaces.
105 servers
=$
(echo ${servers})
107 # If there are no servers to announce, we stop right here.
108 if ! isset servers
; then
109 log DEBUG
"No servers to announce."
113 print
" RDNSS ${servers} {"
114 print
" # Use the defaults here."