Software X-INetConnect

Dieses Script sucht sich die nächste Einwahlmöglichkeit ins Internet und stellt diese Ressource einem Team zur Verfügung.
Download X-INetConnect 2.0
Forum

 
Inhalt

 
Was macht die X-INetConnect 2.0 Box?
Die Box wählt sich automatisch ins Internet ein. Sie sucht sich die beste Einwahlmöglichkeit, egal ob Wireless, DFÜ, Satellite über Bluetooth oder HSDPA/Edge. Die Box findet stets den richtigen und schnellsten Anschluss.
Abbildung, Übersicht

 

Wer braucht eine X-INetConnect 2.0 Box?

Die Box wurde für OLPC / Ondalivre Roadwarrier Teams entwickelt. Mitarbeiter wollen schnell und unkomplizierten Internetzugang haben. Im weiteren wird die Box eingesetzt in a) Ski- und Sommerlager b) als mobile Internetstation, z.B. im Auto c) Spitäler

Demo, Screenshots

Vorbereitung
  1. Hardware zusammenbauen
  2. Betriebssystem installieren (Bsp: WinXP)
  3. USB Stick Treiber für Bluetooth-, Wireless- und HSDPA installieren
  4. X-INetConnect 2.0 Files runterladen
    Download
  5. Archivfile in Standardverzeichnis c:\script\*.* entpacken. Scripte wurden aus Gründen der besseren Lesbarkeit nicht parametrisiert. Die Codezeilen können einfach angepasst und auf eigene Plattformen portiert werden
  6. Zusatzprogramme gemäss iInfofile.cmd runterladen/installieren (devcon, instsrv, srvany, vDHCP, ..)
    iInfo.cmd
  7. Damit die Scripts funktionieren, müssen die LAN/WAN Interfaces entsprechend in iBluetooth, iHSDPA, iWireless, iLAN etc umbenannt werden
  8. DFÜ für Orange, Swisscom, Oi und weitere einrichten. Verbindung zu den Provider gemäss iInfofile.cmd File manuell testen
  9. DHCP konfigurieren (vDHCP)
  10. Alle Files in c:\script\*.cmd mit einem Textprogramm öffnen und ggfs. bearbeiten. Um die Funktionsweise der cmd-Files zu testen, sollte jedes Script vorgängig manuell ausgeführt und reviewt werden
    Files – iBluetooth_Start.cmd | iBluetooth_Stop.cmd | iCheckUplink.cmd | iCheckUplinkPrio1.cmd | ics.vbs | iHSDPA_Start.cmd | iHSDPA_Stop.cmd | iInfo.cmd | iWireless_Start.cmd | iWireless_Stop.cmd | X-INetConnect.cmd
Script- und Konfigurationsfiles
vDHCP Server konfigurieren. File c:\programme\dhcp\dhcpsrv.ini

 

[General]
SUBNETMASK=255.255.0.0
NODETYPE=8             ; Hybrid
LEASETIME=86400        ; lease time of 1 day

[Settings]
Trace=0
IPPOOL_1=172.44.0.2-20
IPBIND_1=172.44.0.1
IgnoreUnknownClients=0

[00-1F-1F-3B-1C-99]
;OLPC 1
IPADDR=172.44.0.2
AutoConfig=08/18/2009 23:15:35
Hostname=OLPC_1
LeaseEnd=1251328445

[00-1A-89-ED-99-1C]
;OLPC 2
IPADDR=172.44.0.3
AutoConfig=08/18/2009 23:19:58
Hostname=OLPC_2
LeaseEnd=1251324827

 

Hauptscript. File c:\script\X-INetConnect.cmd

 

echo off
cls
echo ---------------------------

echo X-INetConnect (Multiline, DFU, WLAN, Mesh, HSDPA)

echo Download: xinetconnect.sourceforge.net
echo.
echo a) program will check uplink 24h
echo b) if line broken, then program
echo will search next available line
echo.
echo Author Stefan Rovetto
echo Version 2.0 (2009-08-25)
echo Translation Onlinetranslator.ch
echo Published under CC license
echo.
echo ---------------------------
echo.
echo X-INetConnect is starting-up now

:Initial
set currentline=iWireless
set nextinetline=iBluetooth
set isonline=false
set isavailable=false
call "C:\script\iHSDPA_Stop.cmd"
call "C:\script\iBluetooth_Stop.cmd"
call "C:\script\iWireless_Start.cmd"

:CheckUplink
call "C:\script\iCheckUplink.cmd"
if %isonline%==false (
goto :%nextinetline%
)

:CheckUplinkPrio
if NOT %currentline%==iWireless (
call "C:\script\iCheckUplinkPrio1.cmd"
if %isavailable%==true (
set isonline=false
goto :iWireless
)
)
goto :CheckUplink

:iwireless
set currentline=iWireless
if %isonline%==false (
call "C:\script\iBluetooth_Stop.cmd"
call "C:\script\iHSDPA_Stop.cmd"
call "C:\script\iWireless_Start.cmd"
if NOT %isonline%==false (
goto :CheckUplink
) else (
set nextinetline=iBluetooth
)
)
goto :CheckUplink

:iBluetooth
set currentline=iBluetooth
if %isonline%==false (
call "C:\script\iWireless_Stop.cmd"
call "C:\script\iBluetooth_Start.cmd"
if NOT %isonline%==false (
goto :CheckUplink
) else (
set nextinetline=iHSDPA
)
)
goto :CheckUplink

:iHSDPA
set currentline=iHSDPA
if %isonline%==false (
call "C:\script\iBluetooth_Stop.cmd"
call "C:\script\iHSDPA_Start.cmd"
if NOT %isonline%==false (
goto :CheckUplink
) else (
set nextinetline=iwireless
)
)
goto :CheckUplink

:Exit

 

Internet über Bluetooth > Handy > aufbauen. File c:\script\iBluetooth_Start.cmd

 

:: echo Infos und Variabeln
call iInfo.cmd
::
echo Connect next available INetLine
echo Blueooth einschalten

devcon /enable *vid_0A12*
::
:: echo NAT ausschalten

netsh routing ip nat uninstall >nul
sc config remoteaccess start= disabled
net stop remoteaccess
::
echo ICS einschalten

sc config sharedaccess start= auto
net start sharedaccess
::
echo Drahtlos Netzwerk Service einschalten

sc config wzcsvc start= auto
net start wzcsvc
::
echo ICS (iHSDPA) deaktivieren (falls noch aktiv)

call ics.vbs 0 "iHSDPA"
::
echo ICS auf Interface (iBluetooth) aktivieren

call ics.vbs 1 "iBluetooth"
::
echo Verbindung mit Orange aufbauen (iBluetooth)

ping 1.1.1.1 /n 5 /w 1000 >nul
::
rasdial "iBluetooth"

 

Bluetooth deaktivieren. File c:\script\iBluetooth_Stop.cmd

 

:: echo Infos und Variabeln
call iInfo.cmd
::
:: echo NAT deaktivieren

netsh routing ip nat uninstall >nul
sc config remoteaccess start= disabled
net stop remoteaccess
::
echo DNS Reset

netsh interface ip delete arpcache
::
echo WAN Gateway "iBluetooth", Verbindung unterbrechen

rasdial /disconnect
::
echo ICS (iBluetooth) deaktivieren

call ics.vbs 0 "iBluetooth"
::
echo Blueooth ausschalten

devcon /disable *vid_0A12*

 

Ist Internet verfügbar? Ja/Nein? File c:\script\iCheckUplink.cmd

 

:: CheckUplink
:: Return set isonline=true/false
::

set isonline=false

for /f "tokens=2,3" %%d in ('ping tel.search.ch -n¬
    12 -l 4 -w 400^|find "Minimum"') do set isonline=%%e

if %isonline%==false (
    echo Line broken
    date /t
    time /t
    echo.
) else (
    echo Established
    set isonline=true
)

 

Ist der schnelle wireless Uplink (wieder) verfügbar? File c:\script\iCheckUplinkPrio1.cmd

 

:: CheckLine with Priority 1
:: Return set isavailable=true/false
::

set isavailable=false
::
:: echo WAN Gateway "iWireless" einschalten
:: devcon /enable *pid_2573*
::

for /f "tokens=3,4" %%d in ('netsh diag ping¬
    gateway RT73*^|find "Minimum"') do set isavailable=%%e

if %isavailable%==false (
    echo Best Uplink not available
) else (
    echo Best Uplink is available
    set isavailable=true
)

 

Internet Connection Sharing (ICS) ein- oder ausschalten. File c:\script\ics.vbs

 

  ' Enable or disable ICS on specified interface
Dim CONNECTION_ALL, KEYSEC, NetSharingManager
Dim EveryConnectionCollection
Dim EveryConnection, Arguments, Interface, ParamX

 ' Const
CONNECTION_ALL = 2

Set ParamX = WScript.Arguments

 ' 0 = disable only
 ' 1 = enable only
 ' 2 = random

If cint(ParamX(0)) >=0 OR cint(ParamX(0)) <=2  Then
    KEYSEC = ParamX(0)
Else
     ' Gueltiger Eintrag, sofern Script ohne
     ' Parameter aufgerufen wird.
     ' ### Modify Section, Start ###

    KEYSEC = 1
     ' ### Modify Section, End   ###  
End If

If cstr(ParamX(1)) <> "" Then
    Interface = ParamX(1)
Else
     ' Gueltiger Interfase Name, sofern Script ohne
     ' Parameter aufgerufen wird.
     ' Internal Interface Name with ip 192.168.0.1
     ' ### Modify Section, Start ###

    Interface = "iBluetooth"
     ' ### Modify Section, End   ###  
End If

set WshShell = WScript.CreateObject("WScript.Shell" )

if initialize() then
    if GetConnectionObjects() then
        if FirewallTestByName(Interface) then
            ChangeSharing()
        end if
    end If
    
     ' clear
    Set EveryConnection = Nothing
    Set Properties = Nothing
    Set NetSharingManager = Nothing
    Set Connection = Nothing
end if

function FirewallTestByName(InterfaceName)
    on error resume next
    dim Item
    dim Properties
    dim InterfaceExist

    InterfaceExist = FALSE
    for each Item in EveryConnectionCollection
        set EveryConnection = NetSharingManager.INetSharing¬
                               ConfigurationForINetConnection(Item)
        set Properties = NetSharingManager.NetConnectionProps(Item)
        if (ucase(InterfaceName) = ucase(Properties.Name)) then
            InterfaceExist = TRUE
            exit for     
        end if
    next
    FirewallTestByName = InterfaceExist
end function

function ChangeSharing()
    on error resume next
    if EveryConnection.SharingEnabled then
        If KEYSEC = 0 Or KEYSEC = 2 Then
            EveryConnection.DisableSharing
        End If
    else
        If KEYSEC = 1 Or KEYSEC = 2 Then
            EveryConnection.EnableSharing(ICSSHARINGTYPE_PUBLIC)
        end if
    end if
end function

function Initialize()
     'output TRUE or FALSE
    on error resume next

    dim Return
    Return = FALSE
    set NetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1" )
    if (IsObject(NetSharingManager)) = FALSE then
        Wscript.Echo("The Internet Sharing Manager cannot be¬
           contacted.  Internet Connection Firewall may not be¬
           available on this interface." )
    else
        if (IsNull(NetSharingManager.SharingInstalled) = TRUE) then
            Wscript.Echo("Internet Connection Firewall may not¬
                be available on this interface." )
        else
            Return = TRUE
        end if
    end if
    Initialize = Return   
end function

function GetConnectionObjects()
    on error resume next
    dim Return
    dim Item

    Return = TRUE

    if GetConnection(CONNECTION_ALL) = FALSE then
        Return = FALSE
    end if

    GetConnectionObjects = Return
end function

 function GetConnection(CONNECTION_TYPE)
    on error resume next

    dim Return   
    dim Connection
    dim Item
    Return = TRUE

    if (CONNECTION_ALL = CONNECTION_TYPE) then
        set Connection = NetSharingManager.EnumEveryConnection
        if (Connection.Count > 0) then
            set EveryConnectionCollection = Connection
        else
            Return = FALSE
        end if
    else
        Return = FALSE
    end if

    GetConnection = Return   
end function

 

Verbindung über Edge/HSDPA aufbauen. File c:\script\iHSDPA_Start.cmd

 

:: echo Infos und Variabeln
call iinfo.cmd
::
echo Connect next available line

:: echo NAT ausschalten
netsh routing ip nat uninstall
sc config remoteaccess start= disabled
net stop remoteaccess
::
echo ICS einschalten

sc config sharedaccess start= auto
net start sharedaccess
::
echo Drahtlos Netzwerk Service einschalten

sc config wzcsvc start= auto
net start wzcsvc
::
echo ICS (iBluetooth) deaktivieren (falls noch aktiv)

call ics.vbs 0 "iBluetooth"
::
echo ICS auf Interface (iHSDPA) aktivieren

call ics.vbs 1 "iHSDPA"
::
echo Verbindung mit Swisscom aufbauen (iHSDPA)

ping 1.1.1.1 /n 5 /w 1000 >nul
rasdial "iHSDPA"

 

Edge/HSDPA Verbindung stoppen. File c:\script\iHSDPA_Stop.cmd

 

:: echo Infos und Variabeln
call iInfo.cmd
::
:: echo NAT deaktivieren (optional)

netsh routing ip nat uninstall
sc config remoteaccess start= disabled
net stop remoteaccess
::
echo DNS Reset

netsh interface ip delete arpcache
::
echo WAN Gateway "iHSDPA", Verbindung unterbrechen

rasdial /disconnect
::
echo ICS (iHSDPA) deaktivieren

call ics.vbs 0 "iHSDPA"

 

Infofile. File c:\script\iInfo.cmd

 

:: Files
:: echo devcon support.microsoft.com/kb/311272
:: echo instsrv tinyurl.com/mrcpep
:: echo srvany tinyurl.com/mrcpep
:: echo DHCP Service, vDHCP tinyurl.com/nstuhk
:: echo Wi-Fi Scanner netstumbler.com
::
::
::
:: echo Verbindungsangaben zu Orange (iBluetooth)
:: echo Rufnummer  *99#
:: echo Initial    +CGDCONT=1,,"internet"
:: echo User       "" (leer)
:: echo Pswd       "" (leer)
:: echo Sicherheit Optional
::
:: echo Verbindungsangaben zu Swisscom (iHSDPA)
:: echo Rufnummer  *99***1#
:: echo Initial    AT+CGDCONT=1,"IP","gprs.swisscom.ch"
:: echo User       "" (leer)
:: echo Pswd       "" (leer)
:: echo Sicherheit Optional
::
::
::
:: echo Beispiel - NAT manuell ausschalten
::         netsh routing ip nat uninstall
::         sc config remoteaccess start= disabled
::         net stop remoteaccess
:: echo    Modify Registry Entry, SET IPEnableRouter=0
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\¬
    
Parameters /v IPEnableRouter /t REG_DWORD /d 00000000 /f
::
::
::
:: echo Run Script as Service. How-to tinyurl.com/lrn2wk
:: echo Modify Registry Entry, SET IPEnableRouter=1
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\¬
     Parameters /v IPEnableRouter /t REG_DWORD /d 00000001 /f
:: instsrv "X-INetConnect" "C:\Programme\Windows Resource Kits\Tools\srvany.exe"
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Services\X-INetConnect\¬
     Parameters /v Application /t REG_SZ /d "%comspec%" /f
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Services\X-INetConnect\¬
     Parameters /v AppParameters /t REG_SZ /d "/c c:\script\X-INetConnect.cmd" /f
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Services\X-INetConnect\¬
     Parameters /v AppDirectory /t REG_SZ /d "c:\script" /f
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Services\X-INetConnect /v Description¬
     /t REG_SZ /d "X-INetConnect (Multiline, DFÜ, WLAN, Mesh, HSDPA)" /f
:: sc config X-INetConnect start= auto
:: net start "X-INetConnect"
::
::
::
:: echo Deinstall Service
:: net stop "X-INetConnect"
:: instsrv X-INetConnect remove
:: echo Modify Registry Entry, SET IPEnableRouter=0
:: REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\¬
     Parameters /v IPEnableRouter /t REG_DWORD /d 00000000 /f

 

Internetzugang über einen Wireless Access Point aufbauen. File c:\script\iWireless_Start.cmd

 

:: echo Infos und Variabeln
call iInfo.cmd
::
echo Connect next available line
echo Echtes NAT unter XP einschalten
echo.
::
echo ICS (iBluetooth, iHSDPA) deaktivieren (falls noch aktiv)

call ics.vbs 0 "iBluetooth"
call ics.vbs 0 "iHSDPA"
::
echo Blueooth ausschalten (falls noch aktiv)

devcon /disable *vid_0A12*
::
echo ICS Service ausschalten

sc config sharedaccess start= disabled
net stop sharedaccess
::
echo WAN Gateway "iWireless" einschalten

devcon /enable *pid_2573*
::
echo Drahtlos Netzwerk Service einschalten

sc config wzcsvc start= auto
net start wzcsvc
::
echo Installing RAS

net stop remoteaccess
netsh routing ip nat install
::
echo LAN Interface IP 192.168.0.1 zuweisen

netsh interface ip set address name="iLAN" static 192.168.0.1 255.255.255.0
::
echo WAN, neue IP holen (iWireless)

ipconfig /renew "iWireless" >nul
::
echo NAT mit Firewall
echo WAN Interface

netsh routing ip nat add interface "iWireless" fullfirewall
::
echo LAN Interface (private)

netsh routing ip nat add interface "iLAN" private
::
echo Weitere Interfaces freischalten

netsh routing ip nat add interface "iAdminLAN" private
::
echo Start NAT as Service

sc config remoteaccess start= auto
net start remoteaccess
::
echo DNS Forwarder einrichten

netsh routing ip dnsproxy install
::
:: echo Router Neustart (manchmal noetig)
:: shutdown -r -f -t 1

 

Wireless Internetzugang unterbrechen. File c:\script\iWireless_Stop.cmd

 

:: echo Infos und Variabeln
call iInfo.cmd
::
echo NAT deaktivieren

netsh routing ip nat uninstall
sc config remoteaccess start= disabled
net stop remoteaccess
::
echo DNS Reset

netsh interface ip delete arpcache
::
:: echo WAN "iWireless" ausschalten
:: devcon /disable *pid_2573*
::
echo LAN, Set IP = 192.168.0.1 (iLAN)

netsh interface ip set address name="iLAN" source=static¬
    addr=192.168.0.1 mask=255.255.255.0
netsh interface ip set dns name="iLAN" source=static¬
    addr=none register=PRIMARY