Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

whois2 php script

Discussion in 'Domain Tools' started by purg, Apr 4, 2008.

Thread Status:
Not open for further replies.
  1. purg Ireland

    purg Active Member

    Joined:
    Sep 2006
    Posts:
    403
    Likes Received:
    6
    Im hoping someone can help

    Ive written a script that should work but doesnt. Taking a whois lookup on port 43 and changed to 1043 and included host & IP. Using port 43 works fine so cant see what ive missed.

    Code:
    <?php
    $fp = fsockopen('whois.nic.uk', 1043, $errno, $errstr);
    if (!$fp) {
       echo "ERROR: $errno - $errstr<br />\n";
    } else {
       fwrite($fp, "myhome.hostname myhome.ip.address yahoo.co.uk\r\n");
       while (!feof($fp)) {
          echo str_replace("\n", '<br />', fread($fp, 100));
       }
       fclose($fp);
    }
    ?>
    
    Ive got the email which accept I now have access to WHOIS2 from the IP address 65.99.[remove].233.85. The domain is on a VPS so have given the domain its own IP address but the script still times out.

    Code:
    Warning: fsockopen() [function.fsockopen]: unable to connect to whois.nic.uk:1043 in /home/daily/public_html/who.php on line 3
    ERROR: 110 - Connection timed out
    
    Please help.
     
    Last edited: Apr 4, 2008
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
    IWA Meetup
     
  3. tifosi United Kingdom

    tifosi Well-Known Member

    Joined:
    Oct 2004
    Posts:
    3,414
    Likes Received:
    55
    Is the IP you're trying to connect to whois2 from allowed?

    "The service will be available on a subscription only basis. At the point of subscription you will need to provide Nominet with the IP address of your gateway."

    S
     
  4. aquanuke

    aquanuke Well-Known Member

    Joined:
    May 2005
    Posts:
    2,040
    Likes Received:
    42
    Looks ok, I just use something like this with np

    PHP:
    $whois 'whois.nic.uk';
    $hostname gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $ip $_SERVER["REMOTE_ADDR"];
    $domain 'internet.co.uk';

    $fs fsockopen("$whois"1043$errno$errstr60);
    if (!
    $fs) {
       
    fclose($fs);
    } else {

            
    fputs($fs"$hostname $ip $domain\r\n");
            
    $contents stream_get_contents($fs);
            
    fclose($fs);

     
  5. aquanuke

    aquanuke Well-Known Member

    Joined:
    May 2005
    Posts:
    2,040
    Likes Received:
    42
    Maybe make sure your connecting from the domains IP not the servers main IP. Most likely connections would come from the servers IP unless you use bind to bind a specific IP to your script. You should be able to see what outgoing connections are running using netstat.
     
  6. purg Ireland

    purg Active Member

    Joined:
    Sep 2006
    Posts:
    403
    Likes Received:
    6
    tifosi... yes ive been accepted and the IP being shown from the domain/script is the IP whois2 has granted access. I put this towards the bottom of my first post.

    aquanuke...
    Thanks i'll give that a try. From shell im getting the correct address also phpinfo shows the correct IP
    SERVER_ADDR 65.99.233.85
    SERVER_NAME dailydomain.co.uk

    The message from both our scripts seems to suggest im not even getting to nic.uk? let alone not being granted access or not.

    Warning: fsockopen() [function.fsockopen]: unable to connect to whois.nic.uk:1043 in /home/daily/public_html/who2.php on line 7
     
    Last edited: Apr 5, 2008
  7. grantw United Kingdom

    grantw Well-Known Member

    Joined:
    Mar 2005
    Posts:
    4,694
    Likes Received:
    93
    Can you telnet to whois2 from the server? If so it will either let you in or close the connection if its an ip registration problem. Either way it will prove whether your script/server is at fault or not.

    Grant
     
  8. aquanuke

    aquanuke Well-Known Member

    Joined:
    May 2005
    Posts:
    2,040
    Likes Received:
    42
    Probs easier just to bind the IP through the script, try this through a web browser.

    PHP:

    <?
    $sourceip 
    'xx.xxx.xx.xx'// ip you want to bind to
    $whois 'whois.nic.uk';
    $hostname gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $ip $_SERVER["REMOTE_ADDR"];
    $domain 'internet.co.uk';

    $sock socket_create(AF_INETSOCK_STREAMSOL_TCP);
    socket_bind($sock$sourceip);
    socket_connect($sock"$whois"1043);

    socket_write ($sock"$hostname $ip $domain\r\n");
    $line socket_read($sock1024);

    echo 
    $line;
    ?>

     
  9. purg Ireland

    purg Active Member

    Joined:
    Sep 2006
    Posts:
    403
    Likes Received:
    6
    Thanks guys but still nothing.... this is getting annoying so will try phoning Nominet Monday for ideas. Im starting to think they sent the email telling me I have access without really granting access to the IP.

    Ive posted a site im working on (dailydomain.co.uk), but until this is working the public wont be able to update or lookup whois info which is a shame.
     
Thread Status:
Not open for further replies.