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"
25 # (Re-)write the configuration file
28 # Reload the radvd service if it is already running
29 if service_is_active radvd
; then
34 # Start the radvd service
38 radvd_clear_config
() {
39 log DEBUG
"Clearing radv daemon configuration file"
41 config_header
"radv daemon configuration file" > ${RADVD_CONFIGFILE}
46 radvd_write_config
() {
49 # Write the configuration for all zones.
51 for zone
in $
(zones_get_local
); do
52 __radvd_config_interface
${zone}
54 done >> ${RADVD_CONFIGFILE}
59 __radvd_config_interface
() {
63 log DEBUG
"Writing radvd configuration for ${zone}."
65 # If the interface does not provide any routing information,
66 # we can skip this whole stuff.
67 if ! db_exists
"${zone}/ipv6"; then
71 # Skip if zone is not active.
72 local active
="$(db_get "${zone}/ipv
6/active
")"
73 [ "${active}" = "0" ] && return ${EXIT_OK}
75 # Skip if there is no prefix or prefix is link-local.
76 local addr
="$(db_get "${zone}/ipv
6/local-ip-address
")"
77 if [ -z "${addr}" ] ||
[ "${addr:0:5}" = "fe80:" ]; then
81 # Check if the subnet is configured by the DHCP server.
83 local prefix
="$(ipv6_get_network "${addr}")"
84 if isset prefix
&& dhcpd_subnet_match ipv6
"${prefix}"; then
88 print
"interface ${zone} {"
89 print
" AdvSendAdvert on;"
90 print
" MinRtrAdvInterval 3;"
91 print
" MaxRtrAdvInterval 10;"
92 print
" IgnoreIfMissing on;"
94 if enabled dhcpd
; then
95 print
" AdvManagedFlag on;"
96 print
" AdvOtherConfigFlag on;"
100 print
" prefix ::/64 {"
101 print
" AdvOnLink on;"
103 if enabled dhcpd
; then
104 print
" AdvRouterAddr off;"
105 print
" AdvAutonomous off;"
107 print
" AdvRouterAddr on;"
108 print
" AdvAutonomous on;"
114 # Add the DNS configuration.
115 __radvd_config_dns
${zone}
121 __radvd_config_dns
() {
124 # Do nothing, when this option is not enabled.
125 enabled DNS_ADVERTISE_SERVERS ||
return ${EXIT_OK}
127 # XXX it is kind of difficult to announce our local
131 for server
in $
(dns_server_list_sorted
); do
132 # Filter out non IPv6 addresses.
133 ipv6_is_valid
${server} ||
continue
135 servers
="${servers} ${server}"
138 # Remove whitespaces.
139 servers
=$
(echo ${servers})
141 # If there are no servers to announce, we stop right here.
142 if ! isset servers
; then
143 log DEBUG
"No servers to announce."
147 print
" RDNSS ${servers} {"
148 print
" # Use the defaults here."