How to find your own IP adresses?

BlitzMax Forums/BlitzMax Programming/How to find your own IP adresses?

Placekeeper(Posted 2004) [#1]
How can I find my own IP addresses (like CountHostIPs/HostIP in the other blitz versions)?

(sorry probably wrong area.. why can't i delete my post? agh ;/ )


Jeroen(Posted 2004) [#2]
There is a difference between your internal and external IP address. The LAN (internal) one, is the one that other people use to find you in a router based setup. The external is the Internet IP address.

Blitz has no way finding out your external one, as far as I know. There is a technique with sockets, but I did this:

PHP *does* know your external IP.
Write a script that runs a PHP script on the server. That PHP script simply outputs your IP address. Catch the value with Blitz by reading the text that PHP generates (the IP address).


skn3(Posted 2004) [#3]
Btw, you should never trust an ip that has been taken by reading the header in php. Alot of ISPs will tunnel all web page traffic through a cache server, so alot of the time you may be getting the ip to the cache server instead of the users ip.


bradford6(Posted 2004) [#4]
I think you are referring to NAT'ed addresses. a Network Address Translator (sometimes a firewall, sometimes another device) takes a PRIVATE ipaddress (example :192.169.x.x) and translates it to a PUBLIC ip address. (the address given to a company/person by their ISP ex. 69.1.1.1).

When people refer to NAT they usually mean PAT (port address translation) which does the same thing as well as opens an arbitrary port to keep track of the different connections. this way you can have a single EXTERNAL PUBLIC address and several INTERNAL PRIVATE addresses.

ex.

pc1 = 192.168.10.1
pc2 = 192.168.10.5
\
Firewall.NAT (69.1.1.1)
\
translates 192.168.10.1 to 69.1.1.1-port 11234
translates 192.168.10.5 to 69.1.1.1-port 11235

since most modern NAT/FW do this transparently, you should be able to use your inside address.