Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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     STREAM     DGRAM     RAW
share|improve this question
up vote 4 down vote accepted

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).
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.