Convert ipv6 to Peusdo Ipv4?

Do we have anything like this on netlify ? One of my parterns use only ipv4 and we have a lot of client with ipv6.

Hey @MeWhit,
We do support IPv6, but there is currently no way to toggle whether the site is accessible over IPv4 or IPv6. Let me know if that helps or if you have other questions!

Hi @jen,
My problem is I received ipv6 address from client http header (its perfect) and complety normal.
But i need to call hotelcombined api and pass in parameters only ipv4 address.
That why i need peusdo ipv4 to replace ipv6 like cloudfare do.
If you dont have any features like that or workarround, I’ll enable cloudflare i guess.

Hi, @MeWhit. The phrase “peusdo ipv4” doesn’t mean anything to me so it would help me to answer if I could first better understand what you mean by this.

Are you asking for Netlify to provide you an IPv4 address which will route back to the IPv6 address? If so, our CDN will respond directly to the IPv6 addresses. There is no need to use “peusdo ipv4” for the Netlify hosted site. If your client used IPv4 we will respond with IPv6 (. If your client make the request using IPv6 we will reply using IPv6 (<- edit to fix an error here). In most cases, there will be no need for “peusdo ipv4” for any responses being returned by Netlify.

This is why I’m asking for more information about what is required. It seems like I’m missing something and I’ll need you to fill in those blanks.

Are looking for something to convert between IPv4 and IPv6 for a third-party API? If so, our service doesn’t handle your connection to the API (unless you are proxying to the API using redirects at Netlify). Is that is what is being done here? Are you proxying to the API?

To summarize, if you would please explain in more detail exactly what is required, we will be happy to answer if that is possible at Netlify. If it isn’t possible we will do our best to suggest workarounds or to enter a feature request asking for the requirement to be supported.

If there are other questions for us, please include them at any time.

I’ll do my best to explain and sorry for my english.

I got webapp and some serveless function. The serverless function are some endpoint thats modify request and add api key and api user to a third party API request. One of them demands in parameters the clientIp but the constraints are only IPv4 address. (I know, I know, they need to update their API :slight_smile: )

So I get the client-ip like this.
Sometime the clientIp is ipv6 format. I tried some tool to convert ipv6 to ipv4 but like we knows its not all ipv6 address can be converted to ipv4. But I was talking with someone thats using the same third party api and he said cloudflare has configuration to convert ipv6 address to “pseudo” ipv4.

I dont know how its work behind but they add into header Cf-Pseudo-IPv4 and its return**Pseudo IPv4** uses the [Class E IPv4 address space] to provide as many unique IPv4 addresses corresponding to IPv6 addresses as possible

For now when I receive ipv6 address from client-ip ,I hardcoded random ipv4. Thats very bad because I lost feature from the Third Party Api like tax calculation.

I hope my explain was more clear now.

My apologies.

PS: Translation missing in toolips for block quote

Hi, @MeWhit. I want to see if I understand what is being requested. It sounds like the requirement is this:

  • If the IP address for the client is an IPv6 address, our service should add a header to the request being passed to the function. The added header should include an IPv4 address which returns the same or similar location as the IPv6 address when a GeoIP lookup is performed.

Is that understanding of the requirements correct? Do you want us to add a header which returns an IPv4 address for the same location as the IPv6 address?

If that is the requirement, this is the first time it has been requested (that I know of).

I’m happy to enter a feature request for that but that is a highly specialized request and no one has asked for it before. My point being, if I enter that feature request I’m fairly certain it will never actually be created because you are the only person to have asked for it. If other people start requesting this same feature, it might get created but I wanted to be clear that this is not something I ever have seen requested before.

Also, in my reading of the Cloudflare pseudo IPv4 feature, I also don’t think it does this above. While it does add a header with an IPv4 address, there is no guarantee that the new address will return the same geographic location for a GeoIP lookup. It may return an IP address for a similar location sometimes but I don’t see any guarantee of that expressed anywhere in that documentation. Personally, I would be cautious about assuming the locations would be the same without proof that this actually works. I would test the Cloudflare solution to be sure before committing to that solution.

To summarize, I don’t think either Cloudflare or Netlify have the feature that you require and you will most likely either need to:

  • Write the “reverse GeoIP lookup” into your serverless function yourself.
  • Wait for the feature request (which may never happen).

​Please let me know if I am missing anything or if I have misunderstood the requirement. If you would confirm the requirement above I will enter the feature request but, again, I cannot promise if or when it might be added (if ever). If I’m misunderstanding, please feel free to correct me.