I have a web page that has a simple HTML form in it, like so:

<form method="POST" action="/something">
  <input type="text" name="something">
  <input type="submit" value="Send">

When the Server this is hosted on is reachable both over IPv4 and over IPv6, is there a way I can force this HTML form POST to be done over IPv4, without changes to the webserver?

If I try as the action, that'll fail as the host header is missing. And if I create a subdomain like v4.example.com that just has the IPv4 address (and then use v4.example.com/something), that'll fail as that subdomain won't be included in the apache config and won't be assigned to that vHost.

Can I somehow, just by modifying the HTML form, make the client send that form over IPv4? Or do I have to make changes to the Apache config to do that?

  • 6
    What is the reason you want to post the form only over IPv4? I cannot imagine any good use case for implementing behaviour like this. To me this sounds like this is to work around some other issue. In that case, the original issue should be fixed. – Tero Kilkanen Nov 16 '19 at 10:36
  • 1
    I'd like to confirm that the user sending this form is behind the same internet connection as another IPv4-only device. with IPv4 only, I just compared the IPv4 addresses. Now with the AAAA record, I get an IPv4 address for the IPv4-only device, and an IPv6 address for the user's web browser connection. – Florian Bach Nov 16 '19 at 10:54
  • 4
    This kind of verification sounds like a complex hack to me, and will have other issues in the future... – Tero Kilkanen Nov 16 '19 at 11:18
  • 5
    Your solution assumes that the client has IPv4 (currently very likely, but going to change in the future) and that the IPv4 address is not shared between multiple networks (life with carrier grade NAT, already very common). Your solution will not be very reliable... – Sander Steffann Nov 16 '19 at 11:29

As a same Internet connection test, this is flawed.

  • Comparing v4 addresses assumes the user agent to be behind the NAT you are expecting. This reduces flexibility when their public address space is restructured.
  • Carrier grade NAT means a v4 address can be shared by who knows how many customers.
  • Multihoming is relatively easy. The same IP can have paths through 3 or 4 different ISPs.
  • Without v6 forces v6 only clients through a NAT64. A shared resource which doesn't improve the accuracy of this test. If anything, it will annoy your users.
  • VPNs exist which can make traffic appear from a different network.

To verify the form submitter is associated with a certain organization or site, use account logins or similar identifiers.

To identify where connections are coming from, look up Internet routing tables, or use geolocation APIs.


The only way to do this is:

Send the form to v4.example.com, which only has A record for the web server you are submitting the form to.

In the web server, setup a virtual host with v4.example.com domain name, or add v4.example.com as an additional domain to the existing virtual host.

Then there can be cross-domain issues you need to take care of.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.