youtuber

Learning default gateway or modem ip?

8 posts in this topic

#1 ·  Posted

How can I learn my modem ip adres?

MsgBox(0, "Modem IP", _ComputerGetModemIP())

Func _ComputerGetModemIP()
If @OSArch = "x86" Then
    $hklm = "HKLM"
Else
    $hklm = "HKLM64"
EndIf
 $aReadModemIP = RegRead($hklm & '\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\{FB281152-E073-454A-B7A3-0DD078663751}', 'DhcpDefaultGateway')
Return  $aReadModemIP
EndFunc

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Do you want your modem's IP on the internal network? Or your external-facing IP address?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted

External-facing IP address no problem

#include <Inet.au3>
#include <MsgBoxConstants.au3>
Local $sPublicIP = _GetIP()
MsgBox($MB_SYSTEMMODAL, "", "Your external IP address is: " & $sPublicIP)

I just want a modem ip address :)

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

If the modem is your default gateway, you can do this:

#include <Array.au3>

Local $aIPs[1][3] = [["IP Address", "Default Gateway", "DNS"]]
Local $oWMI = ObjGet("winmgmts:\\.\root\CIMV2")
Local $oNics = $oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    For $NIC In $oNics
        _ArrayAdd($aIPs, $NIC.IPAddress(0) & "|" & $NIC.DefaultIPGateway(0) & "|" & $NIC.DNSHostName)
    Next

_ArrayDisplay($aIPs)

If it is not, we'll have to do some sniffing on the network.

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted

Is this correct? Thank you

MsgBox($MB_SYSTEMMODAL, "", "Your Default gateway IP address is: " & $aIPs[1][1])

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

You'll have to try it and see if you get what you're expecting; my main machine is a 2012 server with 4 NICs, so it would not be correct for me.

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted

Understood thanks.
I want to use it as a function I do not want an error when I do not have internet for how to do it?

_GetdefaultGateway()

Func _GetdefaultGateway()
Local $aIPs[1][3] = [["IP Address", "Default Gateway", "DNS"]]
Local $oWMI = ObjGet("winmgmts:\\.\root\CIMV2")
Local $oNics = $oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    For $NIC In $oNics
        _ArrayAdd($aIPs, $NIC.IPAddress(0) & "|" & $NIC.DefaultIPGateway(0) & "|" & $NIC.DNSHostName)
    Next
    Return $aIPs[1][1]
    if @error Then
        Return False
        EndIf
EndFunc

fsdf

Share this post


Link to post
Share on other sites

#8 ·  Posted

Is it right to prevent an error? help please

Func _GetdefaultGateway()
Local $aIPs[1][3] = [["IP Address", "Default Gateway", "DNS"]]
Local $oWMI = ObjGet("winmgmts:\\.\root\CIMV2")
Local $oNics = $oWMI.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
    If IsObj($oNics) Then
    For $NIC In $oNics
        _ArrayAdd($aIPs, $NIC.IPAddress(0) & "|" & $NIC.DefaultIPGateway(0) & "|" & $NIC.DNSHostName)
    Next
Return $aIPs[1][1]
    Else
     MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_NetworkAdapterConfiguration")
    EndIf
EndFunc

 

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