I've come to a confusion regarding the /etc/hosts
file. Both of these version work:
1
192.168.2.1 example.com example
2
192.168.2.1 example.com
Which one is the correct one?
I've come to a confusion regarding the /etc/hosts
file. Both of these version work:
1
192.168.2.1 example.com example
2
192.168.2.1 example.com
Which one is the correct one?
They are both correct (for the syntax) but it depends on what you want.
The second one add an alias to 192.168.2.1 with the name example
meaning both example.com and example will resolve to that IP.
This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP address. For each host a single line should be present with the following information:
IP_address canonical_hostname [aliases...]