cancel
Showing results for 
Search instead for 
Did you mean: 

nslookup not the same on new ccgi server

Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

nslookup not the same on new ccgi server

Can anyone advise me on this matter.

nslookup used to work just fine on the old cgi server (crofters). It now fails when run on the new ccgi server.

Here is the PHP code.

<?php
echo "<html>\n";
echo "<head>\n";
echo "<title>saving data - Martek-net.co.uk</title>\n";
echo "<BODY bgcolor=\"#3300ff\" text=#FFFFFF link=#FFFFFF vlink=#FF6666 alink=#66FF66 scroll=auto>";
$lookingfrom = $_SERVER['REMOTE_ADDR'];
$lookup = `nslookup $lookingfrom`;
$lookup = trim($lookup);
//pulling out the ip address
ereg("[0-9|\.]+$", $lookup, $address);
//pulling out the hostname
ereg("Name: +(.+\.[A-z]+\.[A-z]+)", $lookup, $name);
echo "lookup = $lookup";
echo "<br><br>";
echo "address[0] = $address[0]";
echo "<br><br>";
echo "name[0] = $name[0]";
echo "<br><br>";
echo "</BODY></HTML>";
?>


it return this on the old cgi server.
lookup = Server: ns1.plus.net Address: 212.159.11.150 Name: martek.force9.co.uk Address: 84.92.80.24

address[0] = 84.92.80.24

name[0] = Name: martek.force9.co.uk


But when run on the new ccgi server I just get this.
lookup = Server: 212.159.13.49 Address: 212.159.13.49#53 Non-authoritative answer: 24.80.92.84.in-addr.arpa name = martek.force9.co.uk. Authoritative answers can be found from: 80.92.84.in-addr.arpa nameserver = ns1.force9.net. 80.92.84.in-addr.arpa nameserver = ns2.force9.net. ns1.force9.net internet address = 195.166.128.16 ns2.force9.net internet address = 195.166.128.17

address[0] = 195.166.128.17

name[0] =

I guess that because the lookup string is longer and contains more info it fills the arrays elements with the wrong info. Please note the change of IP address returned, I don't see 84.92.80.24 as was returned by the crofters version, anywhere in the new ccgi version.

I can't work out how to fix this, any ideas ?

Thanks in advance. Peter
4 REPLIES
N/A

nslookup not the same on new ccgi server

I'm assuming the nslookup differences are due to different versions being on the different platforms. I'd try and confirm this, but I can't access the man pages as /tmp seems to have gone AWOL.

However, why do an external shell call to nslookup when:

echo "IP address is: " . $_SERVER['REMOTE_ADDR'] . "<br>";

echo "Hostname is: " . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "<br>";

acheives the same thing?
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

nslookup not the same on new ccgi server

Quote
I'd try and confirm this, but I can't access the man pages as /tmp seems to have gone AWOL.


There are reasons i was using a shell call :
1.
Some IP addresses (a minority) cause problems with gethostbyaddr.

This gives an error "Warning: Address is not in a.b.c.d form" and if you use this, then, naturally, the results are unpleasant on the user's screen.
see http://uk2.php.net/manual/en/function.gethostbyaddr.php

2. This code worked just fine on the old cgi (crofters) server, why change things that have been working fine for months ?

Cry Evil :!:

You say /tmp has gone AWOL that means that yet more of my scripts will not now be working, this is getting bl**dy silly. I asked months ago for a list of changes that were to be made to the server routines and the set-up to enable me to pre-empt most of these issues, nothing the least bit helpful was posted by Force9, I am beginning to think that the only thing they care about is their methods of generating more income with less effort on their part.

In my opinion this is rather short-sighted as where would they be without their loyal customers who has over the last six months put up with a lot of aggravation. I am surprised people who use the hosting and scripting options are not leaving in droves, I for one would be if it was not for the expense of transferring my domains and the loss of high ranking links in the search engines. If these were not in place you wouldn't see me for dust.
N/A

nslookup not the same on new ccgi server

Quote
There are reasons i was using a shell call :
1.
Some IP addresses (a minority) cause problems with gethostbyaddr.

This gives an error "Warning: Address is not in a.b.c.d form" and if you use this, then, naturally, the results are unpleasant on the user's screen.
see http://uk2.php.net/manual/en/function.gethostbyaddr.php


You should be able to use @gethostbyaddr then - which should kill the default error and enable you to catch it yourself.
Marteknet
Grafter
Posts: 577
Registered: 13-10-2007

nslookup not the same on new ccgi server

Nice one Colin, I missed that. If it starts playing up I will stick the "@" in.
Ta Pete.