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 the 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:
address hostname [alias ...]
These are:
address Internet address
hostname Official host name
alias Alias host name
Items are separated by any number of blanks and/or tab characters. A hash sign (``#'') indicates the beginning of a comment; characters up
to the end of the line are not interpreted by routines which search the file.
When using the name server named(8), or ypserv(8), this file provides a backup 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 address 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.
As network addresses, both IPv4 and IPv6 addresses are allowed. IPv4 addresses are specified in the conventional dot (``.'') notation using
the inet_pton(3) routine from the Internet address manipulation library, inet(3). IPv6 addresses are specified in the standard hex-and-colon
notation. 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), named(8)
Name Server Operations Guide for BIND.
HISTORY
The hosts file format appeared in 4.2BSD.
BSD November 17, 2000 BSD
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)