Table of Contents
ip2host
Table of Contents
Prototype: ip2host(ip)
Return type: string
The return value is cached.
Description: Returns the primary name-service host name for the IP address
ip
.
Uses whatever configured name service is used by the resolver library to translate an IP address to a hostname. IPv6 addresses will also resolve, if supported by the resolver library.
Note that DNS lookups may take time and thus cause CFEngine agents to wait for responses, slowing their progress significantly.
Arguments:
ip
:string
, in the range:.*
Example:
body common control
{
bundlesequence => { "reverse_lookup" };
}
bundle agent reverse_lookup
{
vars:
"local4" string => ip2host("127.0.0.1");
# this will be localhost on some systems, ip6-localhost on others...
"local6" string => ip2host("::1");
reports:
_cfe_output_testing::
"we got local4" ifvarclass => isvariable("local4");
!_cfe_output_testing::
"local4 is $(local4)";
"local6 is $(local6)";
}
Output:
R: we got local4
See Also: host2ip()
, iprange()
, isipinsubnet()
History: Was introduced in version 3.1.3, Nova 2.0.2 (2010)