views:

424

answers:

1

I am attempting to create a UPnP method on an internal PHP server if at all possible. I need it to be mostly platform independent so that it may run on Windows, OSX, or Linux.

I believe I can get my SOAP protocols working for UPnP, but first I must determine the IP address of the gateway/router that the server goes through. Is it possible to retrieve this information with PHP? If not, what about Python or Ruby?

I have done this in C# but am looking for a more platform independent method now.

Thanks!

CLARIFICATION: I am looking for the internal IP address of the gateway, not the external IP.

A: 

You could retrieve it using external services such as whatismyip.com and similar (via cURL).

another option: since most routers allow for telnet connection or have web admin interface, you could login using PHP and just scrape the external IP.

dusoft
Sorry, I'm not looking for the external IP address. I want the internal IP address instead.
jocull
ah, that's much easier: router always have permanent (default set) IP address - usually at 192.168.1.1
dusoft
also, you could scrape it from the admin interface, if the gateway address could change on the network
dusoft
I'm hoping to make this deployable, so gateway IP will be unknown. Not sure but I may be able to use the system() function in PHP and pull it from a "netstat" command? Just an idea.
jocull
yes, but that won't be platform independent probably... but if you can use the `system` command, that would be the easiest way. `netstat -r` is your option.
dusoft