1
votes

So I have a NGINX web server with php and I need a way to force all clients to connect over IPv4 if they have Dual Stack IPv4+IPv6, and still be able to connect if they support only IPv6 OR only IPv4.

How would I go about this?

If not possible, is there anyway I could use java script to get a client's IPv4 (when connecting through IPv6) and post it to a url?

2

2 Answers

3
votes

You can't control client behaviour and pushing a client to a specific IP address is a bad idea. And clients might even change between protocols during a single session. Either because their mobile device connected to a different network or because how browsers implement the happy eyeballs standard. There are so many different technologies that are used to connect users to the IPv4 and IPv6 internets that second guessing what they choose is going to end in tears.

Just make your service equally accessible over both protocols and implement it so that the protocol doesn't matter. That's the only sustainable solution.

0
votes

To get the user's IPv4 address let an embedded JavaScript script query something that is only accessible by IPv4. The script can check whether this request worked or not.

… But you really should think many times is this is really what you want to do. Why not let your users use IPv6?