Project:
IPFire
Code Location:
git://git.ipfire.org/network.gitmaster
/
functions.radvd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2010 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see <http://www.gnu.org/licenses/>. # # # ############################################################################### RADVD_CONFIGFILE="/etc/radvd.conf" function radvd_update() { # (Re-)write the configuration file radvd_write_config # Reload the radvd service. service_reload radvd } function radvd_write_config() { config_header "radv daemon configuration file" > ${RADVD_CONFIGFILE} # Write the configuration for all zones. local zone for zone in $(zones_get_local); do __radvd_config_interface ${zone} done >> ${RADVD_CONFIGFILE} return ${EXIT_OK} } function __radvd_config_interface() { local zone=${1} assert isset zone log DEBUG "Writing radvd configuration for ${zone}." # If the interface does not provide any routing information, # we can skip this whole stuff. if ! routing_db_exists ${zone} ipv6; then return ${EXIT_OK} fi # Skip if zone is not active. local active=$(routing_db_get ${zone} ipv6 active) [ "${active}" = "0" ] && return ${EXIT_OK} # Skip if there is no prefix or prefix is link-local. local addr=$(routing_db_get ${zone} ipv6 local-ip-address) if [ -z "${addr}" ] || [ "${addr:0:5}" = "fe80:" ]; then return ${EXIT_OK} fi local prefix=$(ipv6_get_network ${addr}) # Check if the subnet is configured by the DHCP server. local dhcpd="false" if dhcpd_subnet_match ipv6 "${prefix}"; then dhcpd="true" fi print "interface ${zone} {" print " AdvSendAdvert on;" print " MinRtrAdvInterval 3;" print " MaxRtrAdvInterval 10;" print " IgnoreIfMissing on;" if enabled dhcpd; then print " AdvManagedFlag on;" print " AdvOtherConfigFlag on;" fi print print " prefix ${prefix} {" print " AdvOnLink on;" if enabled dhcpd; then print " AdvRouterAddr off;" print " AdvAutonomous off;" else print " AdvRouterAddr on;" print " AdvAutonomous on;" fi print " };" print # Add the DNS configuration. __radvd_config_dns ${zone} print "};" print } function __radvd_config_dns() { local zone=${1} # Do nothing, when this option is not enabled. enabled DNS_ADVERTISE_SERVERS || return ${EXIT_OK} # XXX it is kind of difficult to announce our local # resolver. local server servers for server in $(dns_server_list_sorted); do # Filter out non IPv6 addresses. ipv6_is_valid ${server} || continue servers="${servers} ${server}" done # Remove whitespaces. servers=$(echo ${servers}) # If there are no servers to announce, we stop right here. if ! isset servers; then log DEBUG "No servers to announce." return ${EXIT_OK} fi print " RDNSS ${servers} {" print " # Use the defaults here." print " };" print }
