您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

dynamic_dns_client.pl 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env perl
  2. use LWP::Simple;
  3. use strict;
  4. use warnings;
  5. # change these values
  6. my $login = 'username';
  7. my $password = 'password';
  8. my $domain = 'mydynamicdns.example.com';
  9. my $poweradmin_url = 'http://www.example.com/poweradmin';
  10. my $up_update_url = $poweradmin_url . '/dynamic_update.php';
  11. my $ip_lookup_url = $poweradmin_url . '/addons/clientip.php';
  12. my $verbose = 1;
  13. my $ip_address = LWP::Simple::get($ip_lookup_url)
  14. or die("Error: Could not get your global IP address!\n");
  15. # FIXME: doesn't support IPv6
  16. if ( $ip_address !~/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ )
  17. {
  18. print
  19. "Error: Invalid global IP address! Check if Poweradmin url is correct\n";
  20. exit;
  21. }
  22. print "Updating the IP address ($ip_address) now ... \n" if $verbose;
  23. # insert authentication data to url
  24. $poweradmin_url =~ s/^(http[s]?:\/\/)/$1$login:$password\@/;
  25. my $response =
  26. LWP::Simple::get( "$poweradmin_url/dynamic_update.php"
  27. . "?hostname=$domain&myip=$ip_address&verbose=$verbose" )
  28. or die($!);
  29. if ( !defined $response || $response eq "" ) {
  30. print "Error: Could not contact your poweradmin web server\n";
  31. exit(0);
  32. }
  33. print "Status: $response\n" if $verbose;