php - Convert IPV6 to nibble format for PTR records -
php - Convert IPV6 to nibble format for PTR records -
i need convert ipv6 address nibble format utilize in creating ptr records dynamically. here info got wikipedia:
ipv6 reverse resolution
reverse dns lookups ipv6 addresses utilize special domain ip6.arpa. ipv6 address appears name in domain sequence of nibbles in reverse order, represented hexadecimal digits subdomains. example, pointer domain name corresponding ipv6 address 2001:db8::567:89ab b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
the thing find regarding nibbles in pack function, http://www.php.net/pack. not find solutions examples googling issue.
any help appreciated.
given suitably modern version of php (>= 5.1.0, or 5.3+ on windows), utilize inet_pton
function parse ipv6 address 16 byte array, , utilize standard string ops reverse it.
$ip = '2001:db8::567:89ab'; $addr = inet_pton($ip); $unpack = unpack('h*hex', $addr); $hex = $unpack['hex']; $arpa = implode('.', array_reverse(str_split($hex))) . '.ip6.arpa';
php dns reverse-dns pointers
Comments
Post a Comment