php include - dns issue?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Arden Stevensonn

    php include - dns issue?


    On 'sub1.othercomp any.com' there is a simple php file with an include that
    calls a script on my company's server 'sub2.mycompany .com'

    The script on my company's server seems to work fine when I test it alone in
    the browser(it generates some xml) but when I attempt to call it from the
    other companies server as an include, I cannot access it. I *can* get to it
    from the include when I use the IP address.

    According to my company's IT guy there are no issues with our DNS. According
    to the other company they are not restricting outbound access to
    'sub2.mycompany .com'.

    Testing something along the lines of:
    $socket = fsockopen ($Connection, $Port, $errno, $errstr, $Timeout);
    print "Error $errno: $errstr";

    gives:

    Warning: fsockopen() [function.fsocko pen]: php_network_get addresses:
    getaddrinfo failed: No address associated with hostname in
    /usr/local/www/sub1.othercompa ny.com/xml/socket_test.php on line 25

    Warning: fsockopen() [function.fsocko pen]: unable to connect to
    sub2.mycompany. com:80 (Unknown error) in
    /usr/local/www/sub1.othercompa ny.com/xml/socket_test.php on line 25

    Any thoughts on the issue? Are there any diagnostic methods I can use to
    troubleshoot what the issue is?

    TIA
    David


  • Gordon Burditt

    #2
    Re: php include - dns issue?

    >On 'sub1.othercomp any.com' there is a simple php file with an include that[color=blue]
    >calls a script on my company's server 'sub2.mycompany .com'[/color]

    Why do people do this? It seems terribly risky.
    [color=blue]
    >The script on my company's server seems to work fine when I test it alone in
    >the browser(it generates some xml) but when I attempt to call it from the
    >other companies server as an include, I cannot access it. I *can* get to it
    >from the include when I use the IP address.[/color]

    If the include works with an IP address and not with a hostname,
    all other things being equal, including the PHP running on the same
    server both times, you have a DNS problem of some sort.
    You've also eliminated a number of issues regarding allowing
    remote urls and safe mode.

    One possibility to consider is that the host name and the IP address
    do not point to the same place. Another possibility is that if the
    DNS for the host name just changed, it might be out of date on the
    servers the PHP host is running on. (Allow at least 4 days for changes
    to take - and no, I really don't care that YOU always observe changes
    to mycompany.com DNS take in under 60 seconds. The rest of the world
    doesn't use your DNS servers to do all their queries.)
    [color=blue]
    >According to my company's IT guy there are no issues with our DNS. According
    >to the other company they are not restricting outbound access to
    >'sub2.mycompan y.com'.[/color]

    If you can get to it by IP address, the other company's guy is right.
    [color=blue]
    > Testing something along the lines of:
    >$socket = fsockopen ($Connection, $Port, $errno, $errstr, $Timeout);
    >print "Error $errno: $errstr";
    >
    >gives:
    >
    >Warning: fsockopen() [function.fsocko pen]: php_network_get addresses:
    >getaddrinfo failed: No address associated with hostname in
    >/usr/local/www/sub1.othercompa ny.com/xml/socket_test.php on line 25[/color]


    1. Find out what's in /etc/resolv.conf on the PHP server - which
    DNS servers it's using.
    2. Ask *THOSE* servers for the IP address of sub2.mycompany. com.
    dig @hosting.compan y.dns.server sub2.mycompany. com
    Do you get the correct answer from all of them?

    It sounds like the complaint is (a) the domain doesn't exist, or
    (b) the host doesn't exist (has no A record or CNAME record, or
    the CNAME record points to someplace nonexistent), or (c) the
    PHP host has broken DNS configuration and can't resolve *any*
    hostnames (unlikely, as the web server would likely complain).

    Another thing to do is to trace the DNS all the way from the root.
    If the registration for mycompany.com expired and Network Solutions
    turned it off, and you host your own DNS locally, you might not
    notice the problem, since it works for you, but not for the rest
    of the world. The same thing happens if the officially registered
    servers for the domain point at the wrong place.
    [color=blue]
    >Warning: fsockopen() [function.fsocko pen]: unable to connect to
    >sub2.mycompany .com:80 (Unknown error) in
    >/usr/local/www/sub1.othercompa ny.com/xml/socket_test.php on line 25
    >
    >Any thoughts on the issue? Are there any diagnostic methods I can use to
    >troubleshoot what the issue is?[/color]

    Gordon L. Burditt

    Comment

    • Jerry Stuckle

      #3
      Re: php include - dns issue?

      David Arden Stevensonn wrote:[color=blue]
      > On 'sub1.othercomp any.com' there is a simple php file with an include that
      > calls a script on my company's server 'sub2.mycompany .com'
      >
      > The script on my company's server seems to work fine when I test it alone in
      > the browser(it generates some xml) but when I attempt to call it from the
      > other companies server as an include, I cannot access it. I *can* get to it
      > from the include when I use the IP address.
      >
      > According to my company's IT guy there are no issues with our DNS. According
      > to the other company they are not restricting outbound access to
      > 'sub2.mycompany .com'.
      >
      > Testing something along the lines of:
      > $socket = fsockopen ($Connection, $Port, $errno, $errstr, $Timeout);
      > print "Error $errno: $errstr";
      >
      > gives:
      >
      > Warning: fsockopen() [function.fsocko pen]: php_network_get addresses:
      > getaddrinfo failed: No address associated with hostname in
      > /usr/local/www/sub1.othercompa ny.com/xml/socket_test.php on line 25
      >
      > Warning: fsockopen() [function.fsocko pen]: unable to connect to
      > sub2.mycompany. com:80 (Unknown error) in
      > /usr/local/www/sub1.othercompa ny.com/xml/socket_test.php on line 25
      >
      > Any thoughts on the issue? Are there any diagnostic methods I can use to
      > troubleshoot what the issue is?
      >
      > TIA
      > David
      >
      >[/color]

      include() on a file only works if you are on the same server (or have a
      shared disk between servers).

      When you include from an ip address, the request goes to the web server
      which then processes it like it would any other PHP file.

      If you change the extension to something not parsed by the server, you
      will get the source code and be able to use it - but you'll be operating
      on the remote machine and only have the resources (database, etc.) the
      other machine has available to it.


      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      Working...