douhao6557 2011-03-18 05:17
浏览 66
已采纳

从apache获取网络IP而不是单个机器IP

When I go to http://www.whatismyip.com/ I get an IP address of 203.39.136.200 but if I use php/apache I get:

HTTP_CLIENT_IP = ""
HTTP_FORWARDED_FOR = ""
REMOTE_ADDR = 10.15.60.84 //IP of my machine

We are introducing geo-sensitive content into one of our sites and have the necessary lookup Web Services ready to go but as you can imagine using the local IP of the machine (10.15.60.84) produces no results so I need to work out a way to retrieve 203.39.136.200.

Cheers Rob

  • 写回答

1条回答 默认 最新

  • doushaju4901 2011-03-18 05:28
    关注

    If you are accessing the server from the local network then you will get the local address, even if you access the server using an address bound to an external interface. You can get around this by adding routing rules to your default gateway to route packets to the remote side of the Internet link your company uses, but this will cause extra traffic on the link since the packets will now have to go across it to get outside and then back in again.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?