打印的字段是什么getent ahosts DOMAIN
?
的输出getent hosts
是 IP 和主机名的简单组合。有getent ahosts
一个额外的第三个字段,在我的所有测试中,要么是STREAM
,DGRAM
要么是RAW
。
输出为getent hosts example.net
2001:500:88:200::10 example.net
并为getent ahosts example.net
2001:500:88:200::10 STREAM example.net
2001:500:88:200::10 DGRAM
2001:500:88:200::10 RAW
192.0.43.10 STREAM
192.0.43.10 DGRAM
192.0.43.10 RAW
答案1
getent ahosts
用途getaddrinfo()
并从结构中提取、和addrinfo
的值,并按顺序打印它们:ai_addr
ai_socktype
ai_canonname
IPv4/IPv6 地址,插座类型, 和规范名称(如果有的话)。
SOCK_STREAM (reliable stream-oriented service or Stream Sockets)
SOCK_DGRAM (datagram service or Datagram Sockets)
SOCK_SEQPACKET (reliable sequenced packet service), or
SOCK_RAW (raw protocols atop the network layer).