Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8538969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:15:00+00:00 2026-06-11T11:15:00+00:00

I am facing an issue with $_SERVER[‘REMOTE_ADDR’] in PHP It is giving a IPv6

  • 0

I am facing an issue with $_SERVER[‘REMOTE_ADDR’] in PHP
It is giving a IPv6 like value even though the server is using IPv4.

Can anyone help me to resolve this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:15:01+00:00Added an answer on June 11, 2026 at 11:15 am

    The server is then accepting connections on an IPv6 socket. Some operating systems can do both IPv4 and IPv6 on an IPv6 socket. When that happens the IPv6 address will look like ::ffff:192.0.2.123 or ::ffff:c000:027b which is the same address but written in hexadecimal.

    If you see IPv6 addresses like 2a00:8640:1::224:36ff:feef:1d89 then your webserver really is reachable over IPv6 🙂

    Anyway, to convert everything back to a canonical form you can use something like:

    // Known prefix
    $v4mapped_prefix_hex = '00000000000000000000ffff';
    
    $v4mapped_prefix_bin = hex2bin($v4mapped_prefix_hex); 
    
    // Parse
    $addr = $_SERVER['REMOTE_ADDR'];
    $addr_bin = inet_pton($addr);
    if( $addr_bin === FALSE ) {
      // Unparsable? How did they connect?!?
      die('Invalid IP address');
    }
    
    // Check prefix
    if( substr($addr_bin, 0, strlen($v4mapped_prefix_bin)) == $v4mapped_prefix_bin) {
      // Strip prefix
      $addr_bin = substr($addr_bin, strlen($v4mapped_prefix_bin));
    }
    
    // Convert back to printable address in canonical form
    $addr = inet_ntop($addr_bin);
    

    Using this code, when you input one of the following:

    ::ffff:192.000.002.123
    ::ffff:192.0.2.123
    0000:0000:0000:0000:0000:ffff:c000:027b
    ::ffff:c000:027b
    ::ffff:c000:27b
    192.000.002.123
    192.0.2.123
    

    you always get the canonical IPv4 address 192.0.2.123 as output.

    And of course IPv6 addresses get returned as canonical IPv6 addresses: 2a00:8640:0001:0000:0224:36ff:feef:1d89 becomes 2a00:8640:1::224:36ff:feef:1d89 etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Appweb server (mini http server) and facing an issue while opening
Please help me with this issue that I am facing on production server. I
issue facing while loading the messages in to mq channel, recieving an error like
I am facing issue of the WCF Services on staging server. The same service
I am facing a serious issue in my production server where the temp DB
Im facing a strange issue trying to move from sql server to oracle. in
I am facing issue while trying into insert special symbols like pound character (£
After installing the new server, I am facing an issue. I have lot of
I'm facing a crazy issue with in localhost vs production server. Basically the issue
Help Needed Issue facing : Getting refreshed automatically without submitting anything.. in php while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.