「getent ahosts」の結果は何ですか?

「getent ahosts」の結果は何ですか?

どのフィールドが印刷されますかgetent ahosts DOMAIN

の出力はgetent hostsIPとホスト名の簡単な組み合わせです。追加の3番目のフィールドがあり、getent ahostsすべてのテストでtrueSTREAMまたはDGRAMfalseです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_addrai_socktypeai_canonnameIPv4/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).

おすすめ記事