*sigh* finding internet IP of local machine

yeah... I saw this already. Not exactly what I wanted. But I have decided that for the present time I am going to use a similar trick but put the IP reporting webpage on my own server.

I still invite anyone that can come up with a better way to let me know on this thread or by PM.
 
Almost found a solution.

Found some code for performing a tracert in VB.Net. The first IP returned is the internet IP. All I had to do is have it point to microsoft.com to start the tracert. It comes close to my actual IP... only the last octet is different. Anyone know enough about ICMP to know if this might hold a key to getting this done?

For anyone interested the source for doing tracert in VB.Net is here
 
Last edited by a moderator:
It will probably be your side of the router its reporting rather than the internet side of the router. Unfortunately there is probably no reliable non-hardware specific way of interrogating the router to find out the external address.
 
Last edited by a moderator:
add a reference to System.Management ( project , add reference )
then at the very top of your code window put Imports System.Management
then try this .....
Code:
        Try
            Dim sQ As New SelectQuery("select * from Win32_NetworkAdapter")
            Dim objSearch As New ManagementObjectSearcher(sQ)
            Dim netCard As ManagementObject
            Dim netIp As ManagementObject
            For Each netCard In objSearch.Get
                For Each netIp In netCard.GetRelated("Win32_NetworkAdapterConfiguration")
                    If netIp("IPEnabled") Then
                        Dim s As String() = netIp("IPAddress")
                        Dim ipString As String
                        For Each ipString In s
                            MessageBox.Show(ipString)
                        Next
                    End If
                Next
            Next
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
hope it helps, was a fiddle to get it right:)
 
I had this problem, and someone mentioned this solution...

Have you tried to ping it with a TTL = 1?

TraceRoute does this. Then it will die at the first router hop, and the packet will be returned to you.
 
Thanks everyone for all the replies. Unfortunately I had to cheat a bit. I made a page in PHP that only has the function of outputting the IP addy of the visitor... I then had my program surf to that page and parse out the IP addy.

dynamic_sysop: I gave your solution a try but unfortunately all it did for me was return my local IPs.

MicroMan: I may fool around with this a bit but part of the problem is that you need to know the external IP of the local network router and it seems that this would just make the packet die when it hits the router and return the packet with the local addy. Could be wrong though... we shall see.
 
Back
Top