IP Address Lookup returning IPv6 instead of IPv4 Address (1 Viewer)

Minty

AWF VIP
Local time
Today, 06:51
Joined
Jul 26, 2013
Messages
10,371
This is happening to a number of users but not all, which makes fixing it rather troublesome.

I use the code below to return an IPv4 External IP address, so that we can automatically update an Azure SQL firewall, via some clever HTTP encryption.
It's loosely based on a number of similar codes on the interwebs.
Code:
Function GetMyPublicIP() As String

    Dim HttpRequest As Object

    On Error Resume Next
    'Create the XMLHttpRequest object.
    Set HttpRequest = CreateObject("MSXML2.XMLHTTP")

    'Check if the object was created.
    If Err.Number <> 0 Then
        'Return error message.
        GetMyPublicIP = "Could not create the XMLHttpRequest object!"
        'Release the object and exit.
        Set HttpRequest = Nothing
        Exit Function
    End If
    On Error GoTo 0

    'Create the request - no special parameters required.
    'HttpRequest.Open "GET", "http://myip.dnsomatic.com", False - ''  This site rejects me after a few uses.
    HttpRequest.Open "GET", "https://myexternalip.com/raw", False
    'Send the request to the site.
    HttpRequest.sEnd

    'Return the result of the request (the IP string).
    GetMyPublicIP = HttpRequest.responseText

End Function

The problem as stated above is that it is returning an IPv6 address, on some end users' machines. It works fine for my colleagues and other people in the same organisation. But not all of them.

I'm at a bit of a loss, we have checked and there is no common thread, majority are Windows 10 some are Win 11, some have been connected to a VPN some never connect to a VPN.

If they go to any of the websites directly via a browser, they always get the correct IPv4 address.
Confused.com
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:51
Joined
Sep 21, 2011
Messages
14,310
Sorry been away!

It's the WAN IP address that's required, and what is returned 99.9% of the time by sites like What's My IP.
We use it for home workers, and I suspect it's stopped working due to a configuration change rolled out by a corporate IT.

It has been working for about 2 years, and has suddenly started giving strange results.
Well the router my part time bosses have just aquired appears to have an IPv6 option?
 

cheekybuddha

AWF VIP
Local time
Today, 06:51
Joined
Jul 21, 2014
Messages
2,280
Well the router my part time bosses have just aquired appears to have an IPv6 option?
I have a IPv6 capable router, but Virgin don't support it so my home internet will always be over IPv4, except when I use a VPN that can connect using IPv6 (though my connection to the VPN will be over IPv4)
 

Users who are viewing this thread

Top Bottom