Revision 092462dc
Added by Seth Mos over 13 years ago
etc/inc/services.inc | ||
---|---|---|
264 | 264 |
fwrite($fd, "cp /lib/libc.so.* {$g['dhcpd_chroot_path']}/lib/\n"); |
265 | 265 |
fwrite($fd, "cp /usr/local/sbin/dhcpd {$g['dhcpd_chroot_path']}/usr/local/sbin/\n"); |
266 | 266 |
fwrite($fd, "chmod a+rx {$g['dhcpd_chroot_path']}/usr/local/sbin/dhcpd\n"); |
267 |
|
|
267 | 268 |
if(!trim($status)) |
268 | 269 |
fwrite($fd, "mount -t devfs devfs {$g['dhcpd_chroot_path']}/dev\n"); |
269 | 270 |
fclose($fd); |
... | ... | |
1005 | 1006 |
if(count($dhcpdv6ifs) > 0) { |
1006 | 1007 |
mwexec("/usr/local/sbin/dhcpd -6 -user dhcpd -group _dhcp -chroot {$g['dhcpd_chroot_path']} -cf /etc/dhcpdv6.conf -pf {$g['varrun_path']}/dhcpdv6.pid " . |
1007 | 1008 |
join(" ", $dhcpdv6ifs)); |
1009 |
mwexec("/usr/local/sbin/dhcpleases -c "/usr/local/bin/php -f /usr/local/sbin/prefixes.php|/bin/sh" -p {$g['dhcpd_chroot_path']}/var/run/dhcpd6.pid -l {$g['dhcpd_chroot_path']}/var/db/dhcpd6.leases"); |
|
1008 | 1010 |
} |
1009 | 1011 |
|
1010 | 1012 |
if ($g['booting']) { |
usr/local/sbin/prefixes.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
$leases_file = "/var/dhcpd/var/db/dhcpd6.leases"; |
|
4 |
$leasefile = file($leases_file); |
|
5 |
|
|
6 |
foreach($leasefile as $line) { |
|
7 |
// echo "$line"; |
|
8 |
if(preg_match("/^(ia-[np][ad])[ ]+\"(.*?)\"/i ", $line, $duidmatch)) { |
|
9 |
$type = $duidmatch[1]; |
|
10 |
$duid = $duidmatch[2]; |
|
11 |
continue; |
|
12 |
} |
|
13 |
|
|
14 |
/* is it active? otherwise just discard */ |
|
15 |
if(preg_match("/binding state active/i", $line, $activematch)) { |
|
16 |
$active = true; |
|
17 |
continue; |
|
18 |
} |
|
19 |
|
|
20 |
if(preg_match("/iaaddr[ ]+([0-9a-f:]+)[ ]+/i", $line, $addressmatch)) { |
|
21 |
$ia_na = $addressmatch[1]; |
|
22 |
continue; |
|
23 |
} |
|
24 |
|
|
25 |
if(preg_match("/iaprefix[ ]+([0-9a-f:\/]+)[ ]+/i", $line, $prefixmatch)) { |
|
26 |
$ia_pd = $prefixmatch[1]; |
|
27 |
continue; |
|
28 |
} |
|
29 |
|
|
30 |
/* closing bracket */ |
|
31 |
if(preg_match("/^}/i ", $line)) { |
|
32 |
switch($type) { |
|
33 |
case "ia-na": |
|
34 |
$duid_arr[$duid][$type] = $ia_na; |
|
35 |
break; |
|
36 |
case "ia-pd": |
|
37 |
$duid_arr[$duid][$type] = $ia_pd; |
|
38 |
break; |
|
39 |
} |
|
40 |
unset($type); |
|
41 |
unset($duid); |
|
42 |
unset($active); |
|
43 |
unset($ia_na); |
|
44 |
unset($ia_pd); |
|
45 |
continue; |
|
46 |
} |
|
47 |
array_shift($leasefile); |
|
48 |
} |
|
49 |
|
|
50 |
$routes = array(); |
|
51 |
foreach ($duid_arr as $entry) { |
|
52 |
if($entry['ia-pd'] <> "") { |
|
53 |
$routes[$entry['ia-na']] = $entry['ia-pd']; |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
// echo "add routes\n"; |
|
58 |
foreach ($routes as $address => $prefix) { |
|
59 |
echo "/sbin/route change -inet6 {$prefix} {$address}\n"; |
|
60 |
} |
|
61 |
|
|
62 |
/* get clog from dhcpd */ |
|
63 |
$dhcpdlogfile = "/var/log/dhcpd.log"; |
|
64 |
$clog = array(); |
|
65 |
exec("clog $dhcpdlogfile", $clog, $ret); |
|
66 |
|
|
67 |
if($ret > 0) |
|
68 |
$clog = array(); |
|
69 |
|
|
70 |
$expires = array(); |
|
71 |
foreach($clog as $line) { |
|
72 |
if(preg_match("/releases[ ]+prefix[ ]+([0-9a-f:]+\/[0-9]+)/i", $line, $expire)) { |
|
73 |
if(in_array($expire[1], $routes)) |
|
74 |
continue; |
|
75 |
$expires[$expire[1]] = $expire[1]; |
|
76 |
} |
|
77 |
array_shift($clog); |
|
78 |
} |
|
79 |
|
|
80 |
// echo "remove routes\n"; |
|
81 |
foreach ($expires as $prefix) { |
|
82 |
echo "/sbin/route delete -inet6 {$prefix['prefix']}\n"; |
|
83 |
} |
|
84 |
|
|
85 |
?> |
Also available in: Unified diff
Add a dhcpleases monitor to the DHCPv6 server which will trigger automatic creation of routes into the routing table so that prefix delegation will just work.
Redmine ticket #2347