Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX LAN Administrator's Guide: HP-UX 11i v2 > Chapter 3 Manually Installing and Configuring HP-UX LAN

Creating the /etc/hosts File

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

You must edit the /etc/hosts file to add an IP address and hostname for the LAN card that you are installing.

NOTE: If you are using a naming service (DNS or NIS), you will need to modify the /etc/hosts file to add the IP address and host name to the appropriate databases on the name server system. Refer to Internet Services Administrator’s Guide and NFS Services Administrator’s Guide for more information on naming services.

The /etc/hosts file associates IP host addresses with mnemonic host names and alias names. It contains the names of other nodes in the network with which your system can communicate. HP-UX LAN diagnostics netstat and ping use /etc/hosts. If you install HP-UX Internet Services or HP-UX NFS, those products also use the /etc/hosts file.

You can create an /etc/hosts file three ways:

  • From scratch, entering the known nodes in the format shown below.

  • By copying the file from another node.

  • By copying the official host database maintained at the Network Information Control Center (NIC) for ARPA Internet networks, if you are installing HP-UX Internet Services.

If you copy an /etc/hosts file from another host, you may need to update the file by adding unofficial aliases or unknown hosts, including your own host.

Network and System Names

A system is known by several names, each with its own purpose:

System name: Used for cluster configuration and UUCP communication.

Host name and aliases: Used for most network communication. This might be a fully qualified domain name including the DNS domain. For example: turtle.bnio.nmt.edu

HP recommends that you try to keep these names as consistent as possible, within their limitations. This will help to minimize confusion.

The examples below show how a system with the name, host3, might be referenced in the /etc/hosts and other system and networking files and commands:

System name in Install screen:

host3

/etc/rc.config.d/netconf file:

HOSTNAME=host3

/etc/hosts file:

192.6.1.1 host3 host3.site2.region4

uname -S host3

hostname host3

NOTE: When you first install a system, the netconf HOSTNAME entry, the /etc/hosts entry, the hostname, and uname -S are set for you automatically.

/etc/hosts

Each node has a one line entry in the /etc/hosts file. Each entry in the file takes the following form:

Syntax

IP_address host_name [alias]...

Parameters

IP_address

The IP address that uniquely identifies the node. IP_address must be in internet “dot” notation. Refer to Chapter 6 “ Network Addressing” for more information on IP addresses.

host_name

Name of the node. Host names can contain any printable character except spaces, newline, or the comment character (#). Naming Convention: the first nine characters should be unique for each network host.

alias

Common name or names for the node. An alias is a substitute for host_name. Alias names are optional. Naming Convention: the first nine characters should be unique for each network host.

/etc/hosts Format

When creating the /etc/hosts file, follow these rules:

  • Lines cannot start with a blank or tab character.

  • Fields can have any number of blanks or tab characters separating them.

  • Comments are allowed and designated by a pound sign (#) preceding the comment text.

  • Trailing blank and tab characters are allowed.

  • Blank line entries are allowed.

  • Only one host entry per line is allowed.

/etc/hosts Permissions

HP recommends that the /etc/hosts file be owned by user root and have 0x444 (-r--r--r--) access permission. For more information on /etc/hosts, refer to the hosts(4) man page in the HP-UX Reference Pages.

NOTE: HP highly recommends that you limit access to the /etc/hosts file by setting the permission to 0x444 (-r-—r-—r--) for read access only.

/etc/hosts Example

The following /etc/hosts entry contains an IP address, hostname, and alias names (host3.site2.region4 and grace).

192.6.1.1     host3      host3.site2.region4    grace
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2003 Hewlett-Packard Development Company, L.P.