Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- #
- # Perl script for tunnelbroker.net (hurricane electric)
- # to update client ipv4 address of your ipv6 tunnel
- # and configure ipv6 interface using linux-route2
- #
- # Developed by Roberto Tacconelli 28 Jan 2012 (01/28/2012)
- # http://www.st4ck.com
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- #
- use WWW::Mechanize;
- # Config
- $username = "YOUR_USERNAME";
- $password = "a123456789abcdef1234567890abcdef"; #md5 of your password
- $tid = 12345; #your tunnel id from http://tunnelbroker.net/tunnel_detail.php?tid=YOUR_ID
- $cipv6 = "2001:470:12:34::2/64"; #client ipv6 address
- $sipv4 = "216.66.123.45"; #server ipv4 address
- ########
- my $mech = WWW::Mechanize->new();
- print "Retrieving external ip...\n";
- $mech->get( "http://www.whatismyip.org" );
- $ip = $mech->content;
- print "Ok.\n";
- print "\nConfiguring new ip: ".$ip." ...\n";
- $url = "http://www.tunnelbroker.net";
- $mech->get( $url );
- $mech->submit_form(
- form_number => 0,
- fields => {
- f_user => $username,
- clearpass => '',
- f_pass => $password,
- redir => '',
- }
- );
- $mech->post( "http://www.tunnelbroker.net/tunnel_detail.php?ajax=true&tid=".$tid, ["ipv4z" => $ip]);
- print "Ok.\n";
- print "\nSetting up network interface...\n";
- `sudo modprobe ipv6`;
- `sudo ip tunnel del he-ipv6`;
- `sudo ip tunnel add he-ipv6 mode sit remote $sipv4 local $ip ttl 255`;
- `sudo ip link set he-ipv6 up`;
- `sudo ip addr add $cipv6 dev he-ipv6`;
- `sudo ip route add ::/0 dev he-ipv6`;
- print "Ok.\n";
- print "\nSetting up dns...\n";
- `cp /etc/resolv.conf /tmp/resolv.conf`;
- `echo "nameserver 2620:0:ccc::2" >> /tmp/resolv.conf`;
- `sudo cp /tmp/resolv.conf /etc/resolv.conf`;
- print "Ok.\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement