Advertisement
st4ck

Tunnelbroker.net ipv4 updater / ipv6 configurator

Jan 28th, 2012
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.32 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. #
  3. # Perl script for tunnelbroker.net (hurricane electric)
  4. # to update client ipv4 address of your ipv6 tunnel
  5. # and configure ipv6 interface using linux-route2
  6. #
  7. # Developed by Roberto Tacconelli 28 Jan 2012 (01/28/2012)
  8. # http://www.st4ck.com
  9. #
  10. # This program is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation, either version 3 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. #
  24.  
  25. use WWW::Mechanize;
  26.  
  27. # Config
  28. $username = "YOUR_USERNAME";
  29. $password = "a123456789abcdef1234567890abcdef"; #md5 of your password
  30. $tid = 12345; #your tunnel id from http://tunnelbroker.net/tunnel_detail.php?tid=YOUR_ID
  31. $cipv6 = "2001:470:12:34::2/64"; #client ipv6 address
  32. $sipv4 = "216.66.123.45"; #server ipv4 address
  33. ########
  34.  
  35. my $mech = WWW::Mechanize->new();
  36.  
  37. print "Retrieving external ip...\n";
  38. $mech->get( "http://www.whatismyip.org" );
  39. $ip = $mech->content;
  40. print "Ok.\n";
  41.  
  42. print "\nConfiguring new ip: ".$ip." ...\n";
  43.  
  44. $url = "http://www.tunnelbroker.net";
  45. $mech->get( $url );
  46.  
  47. $mech->submit_form(
  48.         form_number => 0,
  49.         fields      => {
  50.             f_user    => $username,
  51.             clearpass => '',
  52.             f_pass    => $password,
  53.         redir     => '',
  54.         }
  55.     );
  56.  
  57. $mech->post( "http://www.tunnelbroker.net/tunnel_detail.php?ajax=true&tid=".$tid, ["ipv4z" => $ip]);
  58.  
  59. print "Ok.\n";
  60.  
  61. print "\nSetting up network interface...\n";
  62.  
  63. `sudo modprobe ipv6`;
  64. `sudo ip tunnel del he-ipv6`;
  65. `sudo ip tunnel add he-ipv6 mode sit remote $sipv4 local $ip ttl 255`;
  66. `sudo ip link set he-ipv6 up`;
  67. `sudo ip addr add $cipv6 dev he-ipv6`;
  68. `sudo ip route add ::/0 dev he-ipv6`;
  69.  
  70. print "Ok.\n";
  71.  
  72. print "\nSetting up dns...\n";
  73. `cp /etc/resolv.conf /tmp/resolv.conf`;
  74. `echo "nameserver 2620:0:ccc::2" >> /tmp/resolv.conf`;
  75. `sudo cp /tmp/resolv.conf /etc/resolv.conf`;
  76. print "Ok.\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement