Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

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

 
discard

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.