We help IT Professionals succeed at work.
Get Started

Pinging tunneled IPs always shows as up with PHP?

318 Views
Last Modified: 2012-05-12
On a linux server, the network-scripts has something like this, for example:

IPADDR_START=109.203.120.64
IPADDR_END=109.203.120.79
CLONENUM_START=134
NETMASK=255.255.255.255


And those IPs are pretty much tunneled to the server. However, when I do a simple check to see if the IP is up and pointed to the proper server with PHP:

function check_content($url)
{
      global $timeout;
      $ch = curl_init();

      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_HEADER, 0);
      curl_setopt ($ch, CURLOPT_TIMEOUT, 20);
      curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

      $string = curl_exec($ch);
      curl_close ($ch);

      $pos = strpos($string, "Username:");
      if ($pos === false) {
            return 0;
      }
      $pos = strpos($string, "Password:");
      if ($pos === false) {
            return 0;
      }
      return 1;
}

This always shows as UP, even if the IPs are down. So if I use http://109.203.120.64 on that server that has them linked, it displays as UP and is getting the proper page, almost as if it gave that 'ip' local access lke 127.0.0.1 would.

I'm not sure how to solve this, but I need to make sure the IP is UP and it's going to the right page (with a simple check to see if username/pass is on that page.) Any suggestions?
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 2 Answers and 12 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE