BIND, dynamic DNS
From FreeBSDwiki
#!/usr/bin/perl # setddns.pl # # Copyright (c) 05-20-2006, JRS System Solutions # All rights reserved under BSD license: http://www.opensource.org/licenses/bsd-license.php # NOTE: This script requires BIND 9.3.1, and CPAN modules LWP::UserAgent, HTTP::Request, and # HTTP::Response. FreeBSD admins may find the CPAN modules under /usr/ports/www/p5-libwww. # # WARNING: FreeBSD admins must make CERTAIN they are calling the BIND9 version # of nsupdate - FreeBSD systems have a nasty habit of leaving a copy # of the BIND8 version higher up in the PATH, even in systems shipped # with BIND9 in the base install! use LWP::UserAgent; use HTTP::Request; use HTTP::Response; $ROUTERURL = "192.168.0.1/status.html"; $ROUTER_USERNAME = "admin"; $ROUTER_PASSWORD = "password"; $NSUPDATE = "/usr/sbin/nsupdate"; $KEYDIR = "/usr/home/ddns"; $KEYFILE = "Kph34r.tehinterweb.net.+157+23266.private"; $NAMESERVER = "tehinterweb.net."; $HOST = "ph34r.tehinterweb.net"; $TYPE = A; $TTL = 10; $router_url_string = 'http://' . $ROUTER_USERNAME . ':' . $ROUTER_PASSWORD . '@' . $ROUTERURL; $ua = LWP::UserAgent->new; $req = HTTP::Request->new('GET',$router_url_string); $testdata = $ua->request($req)->as_string(); $testdata =~ /(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}).*?(\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3})/s; $WAN1 = $2; chdir ("$KEYDIR"); open (NSUPDATE, "| $NSUPDATE -k $KEYFILE"); print NSUPDATE "server $NAMESERVER\n"; print NSUPDATE "update delete $HOST $TYPE\n"; print NSUPDATE "update add $HOST $TTL $TYPE $WAN1\n"; print NSUPDATE "show\n"; print NSUPDATE "send\n"; close (NSUPDATE);