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(4) Kernel Interfaces Manual hosts(4)NAME
hosts - host name data base
DESCRIPTION
The file associates Internet (IP) addresses with official host names and aliases. This allows a user to refer to a host by a symbolic name
instead of an Internet address.
This file contain all addresses for local interfaces that needs at boot time (see ifconfig(1M)). When using the name server (see
named(1M)), or Network Information Service (see ypserv(1M)), this file often serves as a backup when the server is not running. In such
circumstances, it is a common practice for to contain a few addresses of machines on the local network.
should contain a single line for each host with the following information:
internet_address official_host_name aliases
The internet_address can be an IPv4 or IPv6 address specified in the conventional Internet dot notation. See inet(3N) or inet6(3N) for
more information on Internet address manipulation routines.
aliases are other names by which a host is known. They can substitute for the official_host_name in most commands. For example:
In this example, users can use remote login on by using the command:
instead of
If your system is in a domain naming environment, an official host name consists of the full domain extended host name. For example:
(space or tab character). Items are separated by any number or combination of space or tab characters (blanks). A character indicates the
beginning of a comment. Characters from the to the end of the line are not interpreted by routines that search the file. Trailing blanks
are allowed at the end of a line.
For the Internet, this file is normally created from the official host database maintained at the Network Information Control Center (NIC),
although local changes may be required to bring it up to date with respect to unofficial aliases and/or unknown hosts.
Host names can contain any printable character other than a white space, newline, or comment character.
EXAMPLES
See
AUTHOR
was developed by the University of California, Berkeley.
SEE ALSO gethostent(3N), inet(3N), nsswitch.conf(4).
hosts(4)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
Hi Everybody,
I need a help. I have the follow code and I need read the first line of the hosts file. Each line from the file have the format "hostname;IPAddress", on line 4 I just need of the hostname, ok this works! On line 5 I need the hostname before the ipaddr word and the IPAddress after the... (2 Replies)