如何在unix中获取完全限定的域名

时间:2022-09-07 20:25:18

Is there any function(C or C++) which returns FQDN(Fully qualified domain name) in UNIX platforms?

是否有任何函数(C或C ++)在UNIX平台中返回FQDN(完全限定的域名)?

1 个解决方案

#1


Use getifaddrs() to get the interfaces for the box in question, then use the "resolver interface" (man resolver) to query the FQDNs for the ip-addresses return by the former call to getifaddrs().

使用getifaddrs()来获取相关框的接口,然后使用“解析器接口”(man resolver)查询FQDN,以便通过以前调用getifaddrs()返回ip-addresses。

Do not use gethostname() or the command line tool hostname in this context, as an IXish box's "hostname" does not necessarily correlate with the FQDN's returned by a query issued for the box's interface-addresses via the "resolver interface".

不要在此上下文中使用gethostname()或命令行工具主机名,因为IXish框的“主机名”不一定与通过“解析程序接口”为框的接口地址发出的查询返回的FQDN相关联。

#1


Use getifaddrs() to get the interfaces for the box in question, then use the "resolver interface" (man resolver) to query the FQDNs for the ip-addresses return by the former call to getifaddrs().

使用getifaddrs()来获取相关框的接口,然后使用“解析器接口”(man resolver)查询FQDN,以便通过以前调用getifaddrs()返回ip-addresses。

Do not use gethostname() or the command line tool hostname in this context, as an IXish box's "hostname" does not necessarily correlate with the FQDN's returned by a query issued for the box's interface-addresses via the "resolver interface".

不要在此上下文中使用gethostname()或命令行工具主机名,因为IXish框的“主机名”不一定与通过“解析程序接口”为框的接口地址发出的查询返回的FQDN相关联。