Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

hosts(5) [mojave man page]

HOSTS(5)						      BSD File Formats Manual							  HOSTS(5)

NAME
hosts -- host name data base DESCRIPTION
The hosts file contains information regarding the known hosts on the network. For each host a single line should be present with the follow- ing information: Internet address Official host name Aliases Items are separated by any number of blanks and/or tab characters. A ``#'' indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. Network addresses may either be specified for IP version 4 or version 6. IP version 4 addresses are specified in the conventional dotted address notation. IP version 6 addresses are specified using the colon-separated notation described in RFC1924. Host names may contain any printable character other than a field delimiter, newline, or comment character. The hosts file is read by mDNSResponder(8) and used to supply results for calls to getaddrinfo(3), getnameinfo(3), etc. in addition to results obtained from multicast and unicast DNS. FILES
/etc/hosts SEE ALSO
gethostent(3), getipnodebyname(3), getaddrinfo(3), getnameinfo(3) RFC1924: A Compact Representation of IPv6 Addresses. HISTORY
The hosts file format appeared in 4.2BSD. 4.2 Berkeley Distribution December 11, 1993 4.2 Berkeley Distribution

Check Out this Related Man Page

HOSTS(5)						      BSD File Formats Manual							  HOSTS(5)

NAME
hosts -- host name data base DESCRIPTION
The hosts file contains information regarding the known hosts on the network. It can be used in conjunction with DNS, and the NIS maps `hosts.byaddr' and `hosts.byname', as controlled by nsswitch.conf(5). For each host a single line should be present with the following information: Internet address official host name aliases Items are separated by any number of blanks and/or tab characters. A ``#'' indicates the beginning of a comment; characters up to the end of the line are not interpreted by routines which search the file. This file provides a backup used when the name server is not running. For the name server, it is suggested that only a few addresses be included in this file. These include addresses for the local interfaces that ifconfig(8) needs at boot time and a few machines on the local network. This file may be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes may be required to bring it up to date regarding unofficial aliases and/or unknown hosts. As the data base maintained at NIC is incomplete, use of the name server is recommended for sites on the DARPA Internet. Network addresses are specified in the conventional ``.'' (dot) notation using the inet_addr(3) routine from the Internet address manipula- tion library, inet(3). Host names may contain any printable character other than a field delimiter, newline, or comment character. FILES
/etc/hosts The hosts file resides in /etc. SEE ALSO
gethostbyname(3), nsswitch.conf(5), ifconfig(8) Name Server Operations Guide for BIND. HISTORY
The hosts file format appeared in 4.2BSD. BSD
December 25, 2013 BSD
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Can you specify ports in etc/hosts?

Is there a way to specify a port for IP addresses listed in the etc/hosts file, or, does it default to 80 (or something else) and that's what you're stuck with? (3 Replies)
Discussion started by: rado
3 Replies

2. UNIX for Dummies Questions & Answers

pattern matching

Hello all, I'm having a problem and would like to know if anyone has a solution. I would like to search my /etc/hosts file for and ip address say 10.1.1.1. I'm currently have this IP address as a variable, but I only what it to match it. I have grep $IP /etc/hosts. grep `\< $IP>\`... (3 Replies)
Discussion started by: larryase
3 Replies

3. UNIX for Dummies Questions & Answers

HOSTS File

Hi All, I am to the UNIX world and want to know if I can specify a range of IP addresses instead of having to include one by one on the HOSTS file. Can I just say 127.20.1.1 to 127.20.1.156 ? Or the only way is to put one by one along with the machine name next to the IP ? THANKS (4 Replies)
Discussion started by: cymerman
4 Replies

4. Linux

UNIX command for Getting IP addresss of different hosts in WLAN

Is thre any command by which i can get the IP addresses of different machines present in a Wireless Local Network Area. (2 Replies)
Discussion started by: vasurake
2 Replies

5. UNIX for Dummies Questions & Answers

/etc/hosts

Hello, where can I get complete specification for /etc/hosts? I found a lot of snippets but nothing where the format of file is completely written (I'm especially interested in comments in /etc/hosts) Thank you for help! (3 Replies)
Discussion started by: MartyIX
3 Replies

6. Programming

Host to IP Source Code in C - Questions! Please Help

Hello, First of all, i want to say Hi! Glad to join your forum and be your member. I'm a newbie towards C/C++ especially on network programming. What is the definition of getaddrinfo()? int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, ... (4 Replies)
Discussion started by: f.ben.isaac
4 Replies

7. UNIX for Dummies Questions & Answers

netstat error(getnameinfo failed)

# netstat -a > /test/a getnameinfo failed getnameinfo failed getnameinfo failed getnameinfo failed getnameinfo failed command is working fine (as i get output in file /test/a) # dig -x 10.xxx.xxx.xxx ; <<>> DiG 9.3.3rc2 <<>> -x 10.203.xxx.xxx ;; global... (4 Replies)
Discussion started by: crackthehit007
4 Replies

8. Shell Programming and Scripting

search and goto next line then take the output

Hi All, I have a file in which the contents are as shown below: Number of Dynamic Addresses Allocated : 107790 Addresses: 10.3.29.202,10.47.1.145,10.2.4.98,190.1.89.95,.. (many ip addresses separated by comma) ----... (3 Replies)
Discussion started by: imas
3 Replies

9. Programming

get host name by IP address

I'm trying to write a function to get the host name of any given IP address. I'm trying to follow this manual but I'm stuck. I'm using gcc and Linux. Any ideas? getnameinfo() #include <stdio.h> #include <netdb.h> #include <sys/socket.h> #include <arpa/inet.h> char... (6 Replies)
Discussion started by: limmer
6 Replies

10. UNIX for Dummies Questions & Answers

Deleting Multiple Lines in Hosts File

Hello all, I'm using the Bash shell on Solaris 8. Please can someone tell me how I can delete multiple lines in the hosts file? I have a list of hosts that I want to quickly delete in the hosts file, but I'm looking for a quicker way than using VI to delete the lines one by one. Regards,... (4 Replies)
Discussion started by: wthomas
4 Replies

11. UNIX for Dummies Questions & Answers

/etc/hosts

Ive change /etc/hosts many times but it reverts to the previous setting automatically. Ive restarted the server after the edit. Any ideas what im doing wrong Previous /etc/hosts 127.0.0.1 localhost.localdomain localhost # Auto-generated hostname. Please do not remove this... (3 Replies)
Discussion started by: wizecho
3 Replies

12. Shell Programming and Scripting

Adding a character

Hello experts. I trying to achieve 2 things here. I'm trying to convert all of the host names to lower case and add an "m" to each hostname. Can anyone provide some guidance on what I can do? Your input is greatly valued! Here are the desired results: 1. read the host name from a file. 2.... (8 Replies)
Discussion started by: david_tech
8 Replies

13. Shell Programming and Scripting

Bash script to detect nonpingable hosts

I have a script to detect if a host is pingable or not. The problem is that I would like it to put the nonpingable hosts in one file and the pingable hosts in another. I have come up with this so far: for ip in `cat /tmp/testlist2`; do ping -c 3 $ip >/dev/null && echo "$ip is up" || echo "$ip... (5 Replies)
Discussion started by: newbie2010
5 Replies

14. AIX

Howto find the data and management IP address

Can anyone help me to find the data and management IP address on a IBM unix server without looking at the /etc/hosts file. sometimes the hosts file may not make it obvious between the data & mgmt ip addresses. thanks (5 Replies)
Discussion started by: amerjit.jhalley
5 Replies

15. Shell Programming and Scripting

I need to find out disk usage for particular indexes for different hosts

Need disk utilisation script for particular indexes on few hosts (3 Replies)
Discussion started by: Krish5v
3 Replies