dtpt75860 2018-09-27 11:55
浏览 51
已采纳

gethostbyaddr是否显示我服务器的IP地址?

I use CloudFlare, so my server's IP address is hidden, and I want to keep it that way. When I make an HTTP request obviously my IP will be revealed. But does gethostbyaddr reveals my IP address? I want to get the user's IP host, so I do:

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

Will the user be able to find out my server's IP address by this?

  • 写回答

1条回答 默认 最新

  • doufan9395 2018-09-27 12:02
    关注

    gethostbyaddr does a reverse DNS lookup. It does not contact the host directly. However, it may contact DNS servers to do the reverse lookup.

    Typically PHP will ask the system's DNS service for the reverse lookup, and if the answer doesn't happen to be cached, the service will contact its closest DNS server to get the answer. If that doesn't have the answer, it will go out and contact its closest upstream server etc. etc. until the answer comes back.

    So, rarely if ever should the server reach out further than its closest DNS server. It's certainly not impossible though, and if your server happens to contact a DNS server which your user happens to have control over, that user could see the incoming DNS resolution request.

    That will be extremely rare, and again, typically the only DNS server your server will have contact with is its closest DNS server, but cannot be entirely ruled out.

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

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。