How can I get both IPv4 and IPv6 address using PHP code?

前端 未结 2 1925
再見小時候
再見小時候 2021-01-14 11:13

I have a script which sends a request to another server but problem is that IPv6 does not supported so if I send IPv6 then give error so i need thi

相关标签:
2条回答
  • 2021-01-14 11:51

    A client will send a request to your server using only one protocol. It doesn't send the request using both IPv4 and IPv6 at the same time, and there's no way to interleave both protocols, and IPv4 addresses also don't translate into equivalent IPv6 addresses. If the client sent the request using IPv4, then you'll get the IPv4 address. If they sent the request using IPv6, you'll get the IPv6 address. Period. End of story.

    If you require an IPv4 address, then you have to disable IPv6 support on your server/DNS entry, so all clients are forced to use IPv4 as the only available protocol. But that would also be a terrible step backwards in this day and age.

    0 讨论(0)
  • 2021-01-14 12:02

    You can't.

    Only the IP address the request came from is available.

    There's no reliable way to identify other IP addresses (my laptop currently has 12 IP addresses) that route to the same computer.

    0 讨论(0)
提交回复
热议问题