Questions tagged [hosts]

/etc/hosts is the configuration file with locally known mappings between domain name and ip address.

/etc/hosts is the configuration file with locally known mappings between domain name and ip address. It can be used to define new or override existing mapping, bypassing the DNS that would normally resolve it.

227 questions
256
votes
8 answers

Can I create a user-specific hosts file to complement /etc/hosts?

Is it possible to add a list of hosts that are only specific to a certain user? Perhaps a user-specific hosts file? This mechanism should also complement the entries in the /etc/hosts file.
redspike
  • 2,663
  • 2
  • 15
  • 5
49
votes
5 answers

/etc/hosts file refer to another configuration file

How can I get the /etc/hosts file to refer to another configuration file for it's list of hosts? Example /etc/hosts: ## My Hosts 127.0.0.1 localhost 255.255.255.255 broadcasthost #Other Configurations
DogEatDog
  • 665
  • 1
  • 9
  • 10
45
votes
5 answers

What is the /etc/hosts size limit?

How can I determine or set the size limit of /etc/hosts? How many lines can it have?
Geremia
  • 1,163
  • 1
  • 13
  • 23
42
votes
3 answers

What is the purpose of /etc/hosts?

As I understand it, the hosts file is one of several system facilities that assists in addressing network nodes in a computer network. But what should be inside it? When I install Ubuntu by default 127.0.0.1 localhost will be there. Why? How…
MikiBelavista
  • 1,473
  • 8
  • 28
  • 38
40
votes
4 answers

Creating alias to domain name with /etc/hosts

I have a domain setup to point to my LAN's external IP using dynamic DNS, because my external IP address changes frequently. However, I want to create an alias to this host, so I can access it with home. So I appended the following to my…
Oliver Joseph Ash
  • 503
  • 1
  • 4
  • 6
38
votes
3 answers

Hosts file: Is it incorrect to have the same IP address on multiple lines?

For a while I have been formatting my hosts file like this. Notice the same ip on two lines: e.f.g.h foo.mydevsite.com e.f.g.h foo.myOtherDevSite.com I read recently that aliases are supposed to be consolidated on one line: e.f.g.h…
AlexMA
  • 483
  • 1
  • 4
  • 8
35
votes
3 answers

Blocking Websites with /etc/hosts

There's a website, www.example.com, that I tried to block myself from accessing because it wastes too much of my time. So I configured my /etc/hosts file. I added the following lines, to block the website on both IPv4 and IPv6: 127.0.0.1…
Newb
  • 1,062
  • 2
  • 12
  • 19
33
votes
4 answers

Format of /etc/hosts on Linux (different from Windows?)

Pasted below this question is a sample of a /etc/hosts file from a Linux (CentOS) and a Windows machine. The Linux file has two tabbed entries after the IP address (that is localhost.localdomain localhost) and Windows has only one. If I want to edit…
Thomas
  • 1,683
  • 5
  • 19
  • 22
26
votes
4 answers

Understand hostname and /etc/hosts

In /etc/hostname, I have myname. In /etc/hosts, I have : 127.0.0.1 localhost.localdomain localhost myname ::1 localhost.localdomain localhost myname I have a vague understanding of what really is a hostname and what it is used for. These…
Gradient
  • 3,579
  • 10
  • 31
  • 37
25
votes
2 answers

practical usage of /etc/networks file

What is the practical usage of /etc/networks file? As I understand, one can give names to networks in this file. For example: root@fw-test:~# cat /etc/networks default 0.0.0.0 loopback 127.0.0.0 link-local 169.254.0.0 google-dns …
Martin
  • 7,284
  • 40
  • 125
  • 208
22
votes
6 answers

Host lookup that respects /etc/hosts

Utilities like host and dig let you see the IP address corresponding to the host name. There is also the getent utility that can be used to query /etc/hosts or other NSS databases. I am looking for a convenient standard utility (which is available…
Roman Cheplyaka
  • 1,184
  • 3
  • 11
  • 25
21
votes
2 answers

Why do changes to /etc/hosts take effect immediately?

Changes to /etc/hosts file seem to take effect immediately. I'm curious about the implementation. What magic is used to achieve this feature? Ask Ubuntu: After modifying /etc/hosts which service needs to be restarted? NetApp Support: How the…
rudwna
  • 313
  • 2
  • 6
21
votes
3 answers

How do `/etc/hosts` and DNS work together to resolve hostnames to IP addresses?

In Linux, how do /etc/hosts and DNS work together to resolve hostnames to IP addresses? if a hostname can be resolved in /etc/hosts, does DNS apply after /etc/hosts to resolve the hostname or treat the resolved IP address by /etc/hosts as a…
Tim
  • 98,580
  • 191
  • 570
  • 977
19
votes
1 answer

Wildcard in /etc/hosts file

It seems that wildcards are not supported in the /etc/hosts file. What is the best solution for me to resolve all *.local domains to localhost?
Peter Smit
  • 1,154
  • 4
  • 18
  • 32
17
votes
1 answer

How can I override the /etc/hosts file at user level?

Possible Duplicate: Can I create a user-specific hosts file to complement /etc/hosts? In short: I would like to know if it is possible to get a ~/hosts file that could override the /etc/hosts file, since I don't have any privileged access. A…
yves Baumes
  • 569
  • 1
  • 4
  • 11
1
2 3
15 16