Jump to content

Question about getting IP address


Recommended Posts

Hi,

To get an IP address I used the following script:

 

echo $ip = getenv("REMOTE_ADDR");

 

This works fine when my friends access my website, but when it comes to my main computer and the three sub  computers connected to a router, it returns an internal IP address like 192.168.0.1.  My web site is not local; although I run my webserver on my own, everyone in the world can access my web site.

 

Then, I think the IP address should be external one that http://whatismyip.com shows but why does it return an internal IP address? Is there any way to fix that problem?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/201058-question-about-getting-ip-address/
Share on other sites

Because the local boxes are internal, any box from outside will show the IP assigned by the ISP to the cable/dls router. If the local computers did not use an internal address it would present a problem when each box accessed the net as how would your local network know what box gets what packets? Its working as it should. You could however see if your ISP would let you buy enough IP's for each computer. If you got a business plan and paid like $80 or so a month you could probably get them for $2 monthly. If its really a big deal that you have "real" IP's for internal use.

 

Even though you "run" your own webserver, if its within your home network its "local", no matter if you open up port 80 to outside traffic or not.

 

 

HTH

Teamatomic

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.