I'm very new to Ubuntu and I want to know: what is the exact use of /etc/hosts
?
Lets say I'm adding this into it :
127.0.x.x mydomain
What does that mean?
I'm very new to Ubuntu and I want to know: what is the exact use of /etc/hosts
?
Lets say I'm adding this into it :
127.0.x.x mydomain
What does that mean?
Wikipedia
This is invalid (?):
Wildcards are
*
so it should be127.0.*.*
but I hardly see anything else than127.0.0.1
;)What this means is that you can use
mydomain
as a name for that IP address. It is easier to usewww.google.com
than to remember the IP address (74.125.132.106
) that Google uses for their searchengine. The same works locally (localhost) on your machine. If you run your own Apache instance you can set a local IP address to a name and use that name in a browser.The
::1
in the example is the IP v6 version for IP addresses.It means that the system will not do a DNS lookup for
mydomain
, it will be automatically redirected to the IP address you specified in your hosts file.On most systems the default entry in the hosts file is:
127.0.0.1
is always the address of the computer you're on. For example, if you run a web server on your pc, you can access it from the web browser via thehttp://localhost:port
instead of typing the whole IP addresshttp://127.0.0.1:port
.