Minty
AWF VIP
- Local time
- Today, 22:43
- Joined
- Jul 26, 2013
- Messages
- 10,635
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.
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
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