[PHP] Reverse DNS testing

2012-07-12 Thread Al
I want to do a rDNS check on a admin entered host name to insure in-coming mail 
servers don't reject mail, sent by my app, because the rDNS doesn't exist or 
doesn't match.


Here is the fundamental code:

$host = $_SERVER['SERVER_NAME']; //site name shared or not
$ip = gethostbyname($host);

$hostName = gethostbyaddr($ip); //May be different on a shared host
$ip2 = gethostbyname($hostName);

The $ip works fine.

However, one of the shared hosts I'm working with returns this instead of the 
original $host


gethostbyaddr($ip)= 93.247.128.148-static.foo.com [foo is subs for actual]

gethostbyname($hostName)= 93.247.128.148-static.foo.com  It appears
gethostbyname() is just returning $hostName because it is not legit.
Using just the foo.com in gethostbyname() returns the host's server IP.

Thus, the typical rDNS check fails for this site. Several online checks also 
report rDNS fails.


Any suggestions how I can handle this?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reverse DNS testing

2012-07-12 Thread Jim Lucas

On 07/12/2012 11:17 AM, Al wrote:

I want to do a rDNS check on a admin entered host name to insure
in-coming mail servers don't reject mail, sent by my app, because the
rDNS doesn't exist or doesn't match.

Here is the fundamental code:

$host = $_SERVER['SERVER_NAME']; //site name shared or not
$ip = gethostbyname($host);




$hostName = gethostbyaddr($ip); //May be different on a shared host
$ip2 = gethostbyname($hostName);


Throw in a filter_var() check with the FILTER_VALIDATE_IP flag?

if ( filter_var($hostName, FILTER_VALIDATE_IP) === TRUE ) {
# This is an IP
# do something
}

Or do a conditional check

if ( $hostName === $ip2 ) {
# no change...
# handle no resolution issue.
}



The $ip works fine.

However, one of the shared hosts I'm working with returns this instead
of the original $host

gethostbyaddr($ip)= 93.247.128.148-static.foo.com [foo is subs for actual]

gethostbyname($hostName)= 93.247.128.148-static.foo.com It appears
gethostbyname() is just returning $hostName because it is not legit.
Using just the foo.com in gethostbyname() returns the host's server IP.

Thus, the typical rDNS check fails for this site. Several online checks
also report rDNS fails.

Any suggestions how I can handle this?





--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
http://www.bendsource.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reverse DNS testing

2012-07-12 Thread David OBrien

On Jul 12, 2012, at 2:17 PM, Al wrote:

 I want to do a rDNS check on a admin entered host name to insure in-coming 
 mail servers don't reject mail, sent by my app, because the rDNS doesn't 
 exist or doesn't match.
 
 Here is the fundamental code:
 
 $host = $_SERVER['SERVER_NAME']; //site name shared or not
 $ip = gethostbyname($host);
 
 $hostName = gethostbyaddr($ip); //May be different on a shared host
 $ip2 = gethostbyname($hostName);
 
 The $ip works fine.
 
 However, one of the shared hosts I'm working with returns this instead of the 
 original $host
 
 gethostbyaddr($ip)= 93.247.128.148-static.foo.com [foo is subs for actual]
 
 gethostbyname($hostName)= 93.247.128.148-static.foo.com  It appears
 gethostbyname() is just returning $hostName because it is not legit.
 Using just the foo.com in gethostbyname() returns the host's server IP.
 
 Thus, the typical rDNS check fails for this site. Several online checks also 
 report rDNS fails.
 
 Any suggestions how I can handle this?
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

It appears the RDNS for that ip has not been mapped to the server name

do you have control of the DNS servers?

can you check the dns config?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reverse DNS testing

2012-07-12 Thread Al



On 7/12/2012 3:09 PM, Jim Lucas wrote:

On 07/12/2012 11:17 AM, Al wrote:

I want to do a rDNS check on a admin entered host name to insure
in-coming mail servers don't reject mail, sent by my app, because the
rDNS doesn't exist or doesn't match.

Here is the fundamental code:

$host = $_SERVER['SERVER_NAME']; //site name shared or not
$ip = gethostbyname($host);




$hostName = gethostbyaddr($ip); //May be different on a shared host
$ip2 = gethostbyname($hostName);


Throw in a filter_var() check with the FILTER_VALIDATE_IP flag?

if ( filter_var($hostName, FILTER_VALIDATE_IP) === TRUE ) {
 # This is an IP
 # do something
}

Or do a conditional check

if ( $hostName === $ip2 ) {
 # no change...
 # handle no resolution issue.
}



The $ip works fine.

However, one of the shared hosts I'm working with returns this instead
of the original $host

gethostbyaddr($ip)= 93.247.128.148-static.foo.com [foo is subs for actual]

gethostbyname($hostName)= 93.247.128.148-static.foo.com It appears
gethostbyname() is just returning $hostName because it is not legit.
Using just the foo.com in gethostbyname() returns the host's server IP.

Thus, the typical rDNS check fails for this site. Several online checks
also report rDNS fails.

Any suggestions how I can handle this?







I have some additional tests already.  Left them out of this dialog to just 
focus on the essential problem. I check the syntax and stuff before it gets to 
this code


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Reverse DNS testing

2012-07-12 Thread Al



On 7/12/2012 3:58 PM, David OBrien wrote:


On Jul 12, 2012, at 2:17 PM, Al wrote:


I want to do a rDNS check on a admin entered host name to insure in-coming mail 
servers don't reject mail, sent by my app, because the rDNS doesn't exist or 
doesn't match.

Here is the fundamental code:

$host = $_SERVER['SERVER_NAME']; //site name shared or not
$ip = gethostbyname($host);

$hostName = gethostbyaddr($ip); //May be different on a shared host
$ip2 = gethostbyname($hostName);

The $ip works fine.

However, one of the shared hosts I'm working with returns this instead of the 
original $host

gethostbyaddr($ip)= 93.247.128.148-static.foo.com [foo is subs for actual]

gethostbyname($hostName)= 93.247.128.148-static.foo.com  It appears
gethostbyname() is just returning $hostName because it is not legit.
Using just the foo.com in gethostbyname() returns the host's server IP.

Thus, the typical rDNS check fails for this site. Several online checks also 
report rDNS fails.

Any suggestions how I can handle this?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



It appears the RDNS for that ip has not been mapped to the server name

do you have control of the DNS servers?

can you check the dns config?



Unfortunately, the website is on a typical shared, low cost host.  So, I can't 
get to the DNS record and the outfit's tech support won't help.  So, I'm trying 
to do a reasonable work around in case I run into this issue again on another 
shared host.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php