Free Hosting Online for WorkStations

< Previous | Contents | Next >

7.5.4. Customizing the /etc/hosts File‌

Decide on the IP address, fully-qualified domain name (FQDN), and possible aliases for use in the /etc/hosts file. The syntax is:


IP_address myhost.example.org aliases

IP_address myhost.example.org aliases

Unless the computer is to be visible to the Internet (i.e., there is a registered domain and a valid block of assigned IP addresses—most users do not have this), make sure that the IP address is in the private network IP address range. Valid ranges are:


Private Network Address Range

Normal Prefix

10.0.0.1 - 10.255.255.254

8

172.x.0.1 - 172.x.255.254

16

192.168.y.1 - 192.168.y.254

24


x can be any number in the range 16-31. y can be any number in the range 0-255.

A valid private IP address could be 192.168.1.1. A valid FQDN for this IP could be lfs.example.org.

Even if not using a network card, a valid FQDN is still required. This is necessary for certain programs to operate correctly.

Create the /etc/hosts file by running:


cat > /etc/hosts << "EOF"

# Begin /etc/hosts


127.0.0.1 localhost

127.0.1.1 <FQDN> <HOSTNAME>

<192.168.1.1> <FQDN> <HOSTNAME> [alias1] [alias2 ...]

::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes

ff02::2 ip6-allrouters


# End /etc/hosts

EOF

cat > /etc/hosts << "EOF"

# Begin /etc/hosts


127.0.0.1 localhost

127.0.1.1 <FQDN> <HOSTNAME>

<192.168.1.1> <FQDN> <HOSTNAME> [alias1] [alias2 ...]

::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes

ff02::2 ip6-allrouters


# End /etc/hosts

EOF


The <192.168.1.1>, <FQDN>, and <HOSTNAME> values need to be changed for specific uses or requirements (if assigned an IP address by a network/system administrator and the machine will be connected to an existing network). The optional alias name(s) can be omitted.


Top OS Cloud Computing at OnWorks: