Sign in to follow this  
Followers 0
Cancer

6to4 tunnel broker

1 post in this topic

#1 ·  Posted (edited)

Hello! I have made a script that creates 6to4 tunnel. Script is based on command given by http://6to4.version6.net/?lang=en_GB site.

I hope it will be useful for someone. Any comments, additions or fixes are most welcome.

Thanks Sugi for the code and also any other contributor that I don't know of.

C

;===============================================================================
; Program Name:  6to4 tunnel broker v 2.0
; Enviroment:     Windows operating system
; Description:    Program will make 6to4 ipv6 tunnel
; Requirement(s):   AutoIT v3.2.2.0
; Return Value(s):  None
; Author(s):        Cancer
; Date:         29.12.2006
; Authors comment:  http://6to4.version6.net/?lang=en_GB
;===============================================================================
#include <Inet.au3>
Opt("RunErrorsFatal",0)
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)

TrayTip("Checking IPv6 tunnel", "one moment...", 1,1)
Sleep(2000)
$ping6 = RunWait("ping6 2001:ad0::1","", @SW_HIDE) ; If ping works, then tunnel is up

$msg = 0
If $msg = $ping6 Then
   TrayTip("Status","IPv6 tunnel is already Online", 1,1)
   Sleep(2000)
   Exit
Else
   TrayTip("Status","Creating IPv6 tunnel", 1,1)
   Sleep(2000)

$IP = StringSplit(_GetIP(), "."); Get IP and split it at "." points
$stringIP = StringFormat("%03d%03d%03d%03d", $IP[1], $IP[2], $IP[3], $IP[4]); Joins splited IP parts and fills in missing 0 (zeros) so string lenght would be 12

   $a = StringLeft($stringIP, 4)
   $b = StringMid($stringIP, 5, 4)
   $c = StringRight($stringIP, 4)

$stringHex = StringFormat("%8x", ($IP[1] * 2^24) + ($IP[2] * 2^16) + ($IP[3] * 2^8) + $IP[4]); First this will convert IP address to decimals and then to Hex. Thanks Sugi

   $d = StringLeft($stringHex, 4)
   $e = StringMid($stringHex, 5, 4)

RunWait("ipv6 rtu 2002::/16 2","", @SW_HIDE); IPv6 Helper service enables routing
RunWait("ipv6 adu 2/2002:"&StringFormat("%04s:%04s", $d, $e)&"::"& StringFormat("%04d:%04d:%04d", $a, $b, $c),"", @SW_HIDE); Adds unicast address assignment
RunWait("ipv6 rtu ::/0 2/::192.88.99.1","", @SW_HIDE); Route is added to routing table

RunWait("netsh interface ipv6 6to4 set relay 192.88.99.1","", @SW_HIDE);  Tunnel to 6to4 gateway is created

EndIf

$ping6 = RunWait("ping6 2001:ad0::1","", @SW_HIDE)

If $msg = $ping6 Then
   TrayTip("Status","IPv6 tunnel is now Online", 1,1)
   Sleep(6000)
   Else
   TrayTip("Error","IPv6 tunnel is still Offline", 1,1)
   Sleep(6000)
EndIf
Exit
Edited by Cancer

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0