#!/usr/bin/perl $radvd_conf = "/etc/radvd.conf" ; $radvd_pidfile = "/var/run/radvd/radvd.pid" ; $old_prefix_file = "/var/run/dhcpv6/prefix.dat" ; $resolv_conf="/etc/resolv.conf" ; # code to update resolv.conf is crude; should preseve existing # IPv4 entries but won't purge stale IPv6 ones if (open (IN,$old_prefix_file)) { $old_prefix = () ; chomp($old_prefix) ; close (IN) ; } $date = localtime() ; if ($ENV{new_iapd}) { unless ($old_prefix eq $ENV{new_iapd}) { open (PFX,">$old_prefix_file") ; print PFX "$ENV{new_iapd}\n" ; close (PFX) ; if ($ENV{new_iapd} =~ /([\da-f:]+)\/([\d]+),pltime=([\d]+),vltime=([\d]+)/) { $prefix = $1 ; $width = $2 ; $pltime = $3 ; $vltime = $4 ; unless (open (RDV,">$radvd_conf")) { exit 1 ; } print RDV< ; chomp($radvd_pid) ; kill "HUP", $radvd_pid ; } } } if ($ENV{new_domain_name_servers}) { open (IN,$resolv_conf) ; while () { chomp ; if (/nameserver[\s]+([\da-f:]{8,20})/) { $ns6{$1}++ ; } } close(IN) ; foreach $ns (split(' ',$ENV{new_domain_name_servers})) { unless ($ns6{$ns}) { push (@ns6,$ns) ; } } if (@ns6) { open (NS,">>$resolv_conf") ; foreach $ns (@ns6) { print NS "nameserver $ns\n" ; } close(NS) ; } } exit 0;