Hướng dẫn php get ipv6 address
I have a script which sends a request to another server but problem is that
I use this code to get the
But this function only returns one
squancy 5551 gold badge6 silver badges24 bronze badges asked Jul 9, 2018 at 11:58
Shafiqul IslamShafiqul Islam 5,4552 gold badges34 silver badges42 bronze badges 8 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. answered Jul 9, 2018 at 12:05
6 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. answered Jul 9, 2018 at 12:03
QuentinQuentin 874k121 gold badges1171 silver badges1285 bronze badges 3 There is an API for this available https://ipv6-test.com/api/ however their server has a CORS misconfiguration making it not work at the moment. answered Aug 31 at 22:09
JayJay 1,04611 silver badges22 bronze badges Sau khi tìm kiếm xung quanh một cách kỹ lưỡng, tôi nhận thấy có một chút thiếu các chức năng trong PHP để xử lý IPv6 . Vì sự hài lòng của cá nhân tôi, tôi đã tạo một vài chức năng để trợ giúp quá trình chuyển đổi. Các
Đối với những hàm này, tôi thường triển khai chúng bằng cách gọi hàm này trước:
Ai đó làm ơn cho tôi biết nếu tôi đang phát minh lại bánh xe ở đây hay tôi đã làm sai điều gì đó. Việc triển khai này chuyển đổi IPv4 thành IPv6. Bất kỳ địa chỉ IPv6 nào nó cũng không chạm vào. 32 hữu ích 2 bình luận 49k xem chia sẻ |