weird IP getting problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news@celticbear.com

    weird IP getting problems

    I have two IP Web pages, both on the same server, and both I am
    accessing with the same browser.
    On both pages I have this code:

    if(getenv("HTTP _CLIENT_IP")) {
    $ip = getenv("HTTP_CL IENT_IP");
    } elseif(getenv(" HTTP_X_FORWARDE D_FOR")) {
    $ip = getenv("HTTP_X_ FORWARDED_FOR") ;
    } else {
    $ip = getenv("REMOTE_ ADDR");
    }

    Here's the weird part. When I echo $ip on one page I get my actual
    public IP address, which I can verify as accurate by looking at my
    router settings and using other people's Web pages that display IP
    addresses like grc.com.
    But on the other page, I get a COMPLETELY different IP address that
    also keeps changing the last octet every so few times I refresh the
    page. I can't even ping this IP address.

    Same code, both pages. Viewing with same browser on same PC.
    How is this even possible??
    Any suggestions?
    Liam

  • R. Rajesh Jeba Anbiah

    #2
    Re: weird IP getting problems

    news@celticbear .com wrote:
    <snip>[color=blue]
    > if(getenv("HTTP _CLIENT_IP")) {
    > $ip = getenv("HTTP_CL IENT_IP");
    > } elseif(getenv(" HTTP_X_FORWARDE D_FOR")) {
    > $ip = getenv("HTTP_X_ FORWARDED_FOR") ;
    > } else {
    > $ip = getenv("REMOTE_ ADDR");
    > }[/color]
    <snip>[color=blue]
    > Same code, both pages. Viewing with same browser on same PC.
    > How is this even possible??[/color]

    Your code might be the culprit. Try print_r($_SERVE R) and see what is
    been thrown.

    --
    <?php echo 'Just another PHP saint'; ?>
    Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

    Comment

    • news@celticbear.com

      #3
      Re: weird IP getting problems


      R. Rajesh Jeba Anbiah wrote:[color=blue]
      > news@celticbear .com wrote:
      > <snip>[color=green]
      > > if(getenv("HTTP _CLIENT_IP")) {
      > > $ip = getenv("HTTP_CL IENT_IP");
      > > } elseif(getenv(" HTTP_X_FORWARDE D_FOR")) {
      > > $ip = getenv("HTTP_X_ FORWARDED_FOR") ;
      > > } else {
      > > $ip = getenv("REMOTE_ ADDR");
      > > }[/color]
      > <snip>[color=green]
      > > Same code, both pages. Viewing with same browser on same PC.
      > > How is this even possible??[/color]
      >
      > Your code might be the culprit. Try print_r($_SERVE R) and see what[/color]
      is[color=blue]
      > been thrown.
      >[/color]

      That's a lot of stuff. Not sure what to make of it.
      Of the two IP addresses in it, [SERVER_ADDR] is correctly display the
      IP of the server. The other, [REMOTE_ADDR], is showing that unknown IP
      address that I can't seem to even ping.
      Is there something here in particular I need to look at?
      Thanks for the reply!

      Comment

      • R. Rajesh Jeba Anbiah

        #4
        Re: weird IP getting problems

        n...@celticbear .com wrote:[color=blue]
        > R. Rajesh Jeba Anbiah wrote:[color=green]
        > > news@celticbear .com wrote:[/color][/color]
        <snip>[color=blue][color=green]
        > > Your code might be the culprit. Try print_r($_SERVE R) and see[/color][/color]
        what[color=blue][color=green]
        > > is been thrown.[/color]
        >
        > That's a lot of stuff. Not sure what to make of it.
        > Of the two IP addresses in it, [SERVER_ADDR] is correctly display the
        > IP of the server. The other, [REMOTE_ADDR], is showing that unknown[/color]
        IP[color=blue]
        > address that I can't seem to even ping.[/color]

        [SERVER_ADDR] -- Server IP
        [REMOTE_ADDR] -- Client machine's (your) IP

        --
        <?php echo 'Just another PHP saint'; ?>
        Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

        Comment

        • Micha³ Wo¼niak

          #5
          Re: weird IP getting problems

          One quick glance of an experienced eye allowed to understand the blurred
          and almost unreadable news@celticbear .com's handwriting:
          [color=blue]
          >
          > R. Rajesh Jeba Anbiah wrote:[color=green]
          >> news@celticbear .com wrote:
          >> <snip>[color=darkred]
          >> > if(getenv("HTTP _CLIENT_IP")) {
          >> > $ip = getenv("HTTP_CL IENT_IP");
          >> > } elseif(getenv(" HTTP_X_FORWARDE D_FOR")) {
          >> > $ip = getenv("HTTP_X_ FORWARDED_FOR") ;
          >> > } else {
          >> > $ip = getenv("REMOTE_ ADDR");
          >> > }[/color]
          >> <snip>[color=darkred]
          >> > Same code, both pages. Viewing with same browser on same PC.
          >> > How is this even possible??[/color]
          >>
          >> Your code might be the culprit. Try print_r($_SERVE R) and see what[/color]
          > is[color=green]
          >> been thrown.
          >>[/color]
          >
          > That's a lot of stuff. Not sure what to make of it.
          > Of the two IP addresses in it, [SERVER_ADDR] is correctly display the
          > IP of the server. The other, [REMOTE_ADDR], is showing that unknown IP
          > address that I can't seem to even ping.
          > Is there something here in particular I need to look at?
          > Thanks for the reply![/color]

          Could you post the strange IP? :)

          Comment

          Working...