Hosts file change syntax

I am attempting to migrate a website to a ubuntu server but would like to test it first

On windows I have changed my host file to point to the server, so the browser is opening the "new" site. In my terminal , in Ubuntu I have changed the following

127.0.1.1 example example
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

to

127.0.1.1 example example
127.0.0.1 localhost
104.236.247.139
104.236.247.139 example.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Can I confirm that this is correct? I seem to be running into issues with finding http image urls etc, and before trying to debug I want to make the hosts file is correctly set.

Thanks

2

1 Answer

Your /etc/hosts file should look like this:

127.0.1.1 example
127.0.0.1 localhost
104.236.247.139 example.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

For 127.0.1.1 you have put two same hostnames whereas just one will do. For the IP 104.236.247.139 you have used two different lines to express hostname and alias but you should put the hostname and aliases all in a single line separated by whitespaces, for example:

<IP_Address> <hostname> <alias_1> <alias_2> <alias_3>
104.236.247.139 example.com foo.com bar.com
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like