13

What are the fields printed by getent ahosts DOMAIN?

The output for getent hosts is a simple combination of IP and hostname. The getent ahosts has an additional third field that is, in all my test, either STREAM, DGRAM or RAW.

Output for getent hosts example.net

2001:500:88:200::10 example.net

and for 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
gioele
  • 2,139

1 Answers1

12

getent ahosts uses getaddrinfo() and extracts from the addrinfo struct the values of ai_addr, ai_socktype, and ai_canonname and prints them out in order as: IPv4/IPv6 address, socket type, and canonical name (if it has one).

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).
aculich
  • 1,180