MENU
IP Address
checkdnsrr($s1 [,$s2=”MX”]) or dns_check_record($s1 [,$s2=”MX”]) searches DNS for records of type $s2 corresponding to host $s1. $s2 can be A, MX, NS, SOA, PTR, CNAME, AAAA, A6, SRV, NAPTR, TXT or ANY. TRUE is returned if any records are found.
getmxrr($s, &$arr1 [,&$arr2]) or dns_get_mx(
$s, &$arr1 [,&$arr2]) searches DNS for MX records corresponding to host $s and stores them in $arr1. $arr2 stores the weight information.
dns_get_record($s [, $i=DNS_ANY [, &$arr1 [, &$arr2 [, &$b=false]]]]) returns an associative array of DNS Resource Records associated with the host $s. $i specifies the type and can be DNS_A, DNS_CNAME, DNS_HINFO, DNS_MX, DNS_NS, DNS_PTR, DNS_SOA, DNS_TXT, DNS_AAAA, DNS_SRV, DNS_NAPTR, DNS_A6, DNS_ALL or DNS_ANY. $arr1 stores the Resource Records for the Authoritative Name Servers. $arr2 stores Additional Records. $b specifies whether to use raw mode, in which only the requested type is queried, instead of looping type by type before going with the additional information.
<?php
echo "<pre>";
var_dump(checkdnsrr("www.google.com","A"));
var_dump(getmxrr("binarybehemoth.com",$arr));
print_r($arr);
print_r(dns_get_record("binarybehemoth.com"));
echo "</pre>";
?>
bool(true) bool(true) Array ( [0] => mail.binarybehemoth.com ) Array ( [0] => Array ( [host] => binarybehemoth.com [class] => IN [ttl] => 900 [type] => MX [pri] => 5 [target] => mail.binarybehemoth.com ) [1] => Array ( [host] => binarybehemoth.com [class] => IN [ttl] => 899 [type] => NS [target] => ns4.no-ip.com ) [2] => Array ( [host] => binarybehemoth.com [class] => IN [ttl] => 899 [type] => NS [target] => ns5.no-ip.com ) [3] => Array ( [host] => binarybehemoth.com [class] => IN [ttl] => 899 [type] => NS [target] => ns2.no-ip.com ) [4] => Array ( [host] => binarybehemoth.com [class] => IN [ttl] => 899 [type] => NS [target] => ns1.no-ip.com ) [5] => Array ( [host] => binarybehemoth.com [class] => IN [ttl] => 899 [type] => NS [target] => ns3.no-ip.com ) )
<?php
echo "<pre>";
echo gethostname()."\n";
echo gethostbyname('www.google.com')."\n";
print_r(gethostbynamel('www.google.com'));
echo gethostbyaddr('173.194.127.80');
echo "</pre>";
?>
Phang 173.194.127.83 Array ( [0] => 173.194.127.83 [1] => 173.194.127.84 [2] => 173.194.127.80 [3] => 173.194.127.81 [4] => 173.194.127.82 ) hkg03s11-in-f16.1e100.net
getservbyport($i,$s) returns as a string the Internet service associated with port $i and protocol $s. getservbyname($s1, $s2) returns as an integer the port number associated with the Internet service $s1 and protocol $s2.
RESETRUNFULL
<?php
echo "<pre>";
for ($i=0; $i<70; $i++) echo $i."(".getprotobynumber($i).")";
echo "\n".getprotobyname('tcp')."\n";
$services = array('http', 'ftp', 'ssh', 'telnet', 'imap','smtp','nicname', 'gopher', 'finger', 'pop3', 'www');
foreach ($services as $service) {
$port = getservbyname($service, 'tcp');
echo $service . ": " . $port . "\n";
}
echo getservbyport(80,'tcp');
echo "</pre>";
?>
ip2long($s) converts an IP address into an integer.
long2ip($i) converts an integral IP address into a string in Internet-standard dotted format.
RESETRUNFULL
<?php
echo "<pre>";
echo inet_pton('115.135.180.20')."\n";
echo inet_ntop(inet_pton('115.135.180.20'))."\n";
echo ip2long('115.135.180.20')."\n";
echo long2ip(1938273300)."\n";
echo "</pre>";
?>