简体   繁体   中英

IPv6 to IPv4 on Google App Engine

We are using a service that require us to provide an IP in V4 format. Our application which resides on GAE reports (using python's os.environ["REMOTE_ADDR"]) for some users the IP in V6 format. Is there away to convert the IP from V6 to V4 on GAE? Does GAE support the 6to4 transition mechanism?

Thanks, Eden


Update: While there is no way to convert IPv6 to IPv4 there is away to limit the access to the application to only those with IPv4. Which is an acceptable solution in my case. See: GAE IPv6 hosting

6to4 is a deprecated method to provide IPv6 to.networks that only have an IPv4 uplink. I don't think it is relevant to your question.

The very short answer: The whole world is slowly starting to enable IPv6, and Google is one of the companies that is actively working on IPv6 support. You will have to deal with IPv6 support.

A bit longer answer: IPv6 is a different protocol than IPv4. You cannot 'convert' IPv6 addresses to IPv4 addresses. IPv4 addresses and IPv6 addresses are unrelated. If your application cannot deal with IPv6 then your best bet is probably to overwrite os.environ["REMOTE_ADDR"] with a 'fake' IPv4 address when you detect an IPv6 address.

If you choose something that is never supposed to show up on the inte.net like 192.0.2.0 then you can later easily see which entries are caused by an IPv6 client. You won't be able to identify the client anymore though, as the 128 bits in an IPv6 address can never be put into a fake IPv4 address. You really should adjust your application to deal properly with IPv6 if IP addresses are important to you...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM