[RESOLVED] Getting WAN IP address without connecting to whatismyip.com
Hi, this question has been asked before, but I can't find the solution I'm looking for.
I'm creating an app to upload text messages to a server. I'd like to add the IP address of the user (encrypted) to the header of the message, so action can be taken when the user does something inappropriate.
Many people are behind a router and Winsock1.LocalIP will then show the LAN IP address, like 192.168.1.100 and not the WAN address.
Code:
Private Sub Command1_Click()
MsgBox Winsock1.LocalIP
End Sub
Then I thought, I might get the IP address when connecting to the server first, but then Winsock1.LocalIP returns 127.0.0.1 (local host).
Code:
Private Sub Command1_Click()
Winsock1.Connect "123.123.123.123", 80
End Sub
Private Sub Winsock1_Connect()
MsgBox Winsock1.LocalIP
End Sub
The only solution I know, is to connect to whatismyip.com or a similar site and read the IP address. Generally it works fine, but it might seem a little bit suspicious when people have a firewall installed and a message pops up that the app is trying to connect to whatismyip.com.
Is there any way to get the WAN address without getting it from an external source.
Re: Getting WAN IP address without connecting to whatismyip.com
Surely the server knows the IP that it is receiving data from, so why not store the IP in the server code?
Re: Getting WAN IP address without connecting to whatismyip.com
you can read the appropriate page from their router /gateway
or possibly use a php script on the server to upload the file and append the ip address
this php script would echo the wan ip back to a webbrowser
Code:
<?php
echo $_SERVER['REMOTE_ADDR']
?>
at least if it is on the same server as the file is being uploaded to it should not arouse suspicion
Re: Getting WAN IP address without connecting to whatismyip.com
The problem is that I don't have any control over the server, it are Usenet newsservers.
Members from a Usenet community use my app to post messages, but many of them use a premium newsserver. Premium newsservers never put the IP address of the user in the header (ISP newsservers usually do) and those people can do whatever they want anonymously. Certain parts of the header can be filled in by the client and by manually adding the users IP address to the header, they can be dealt with if they don't behave.
I guess it's not possible then :(
Thank you for your replies.
Re: Getting WAN IP address without connecting to whatismyip.com
Anything's possible, but rather than IP why don't you do some other uniquely identifiable and easily available information from the user's PC...if you give each user a custom key for their PC (search for security on the site, or under the deployment section) you could store an encrypted version of the key in the outgoing data and you'd instantly know who it was and could disable access to that person :-)
See, the more information people give is, the more we can do with it...we only go on what we get told :-P
Re: Getting WAN IP address without connecting to whatismyip.com
Thanks smUX, that's a possible solution.
The reason I don't give all that information at first, is that many people can't be bothered to read large posts. If you ask a simple question, then people tend to help you quicker. Large posts often stay unanswered.