Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting my ip address

I have a computer on a small network, so my ip is 192.168.2.100.

I am trying to get my real ip. I download the no-ip client but that just seems like a lot of trouble for such a simple thing.

I created this php script that got http://www.ip-adress.com/ page and retrieved the ip it gave me.

Is there a simpler way? Either using C, WSH or something. Or if there is an easier way in php please tell me.

When I get the ip I'll uploaded it to my ftp site so that I can see the ip from work.

like image 780
AntonioCS Avatar asked May 27 '09 18:05

AntonioCS


2 Answers

No, there's not really an easier way. Your computer really doesn't know the public IP it's behind -- there could any number of layers of NAT between it and the public internet. All it knows is that it receives messages at 192.168.2.100, and sends outgoing messages through the gateway at 192.168.2.1. It has no idea what happens after the packet hits the gateway.

like image 169
Frank Farmer Avatar answered Nov 17 '22 13:11

Frank Farmer


Do note reinvent the wheel, there is a standard protocol, STUN (with already existing implementations), just for that. See also Discovering public IP programatically.

like image 6
bortzmeyer Avatar answered Nov 17 '22 12:11

bortzmeyer