Skip to main content

Questions tagged [hosts]

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

Filter by
Sorted by
Tagged with
267 votes
9 answers
166k views

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's user avatar
  • 2,773
51 votes
5 answers
54k views

/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 ...
DogEatDog's user avatar
  • 685
48 votes
3 answers
53k views

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 ...
MikiBelavista's user avatar
45 votes
5 answers
11k views

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's user avatar
  • 1,185
41 votes
4 answers
105k views

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 ...
Oliver Joseph Ash's user avatar
39 votes
3 answers
89k views

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 ...
AlexMA's user avatar
  • 493
36 votes
4 answers
133k views

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 ...
Thomas's user avatar
  • 1,713
35 votes
3 answers
62k views

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 ...
Newb's user avatar
  • 1,092
26 votes
4 answers
106k views

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 ...
Gradient's user avatar
  • 3,669
25 votes
6 answers
16k views

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 ...
Roman Cheplyaka's user avatar
25 votes
2 answers
33k views

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 ...
Martin's user avatar
  • 7,616
22 votes
3 answers
43k views

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 ...
Tim's user avatar
  • 103k
22 votes
2 answers
13k views

How do I modify my hosts file in Nixos?

Seems my hosts file (/etc/hosts) points to /nix/store/gds7bha3bx0a22pnzw93pgf0666anpyr-etc-hosts and is read only. How am I meant to modify this file?
Chris Stryczynski's user avatar
21 votes
2 answers
9k views

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 ...
rudwna's user avatar
  • 313
19 votes
1 answer
16k views

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's user avatar
  • 1,164
18 votes
1 answer
6k views

Why does SSH not consult /etc/hosts?

I'm administrating a networked environment where the users authenticate over NIS. All machines can be used to SSH into the server but one. On the machine in question, I get the message ssh: connect ...
Joseph R.'s user avatar
  • 39.8k
17 votes
3 answers
29k views

How to test /etc/hosts

What's the best way to confirm that your /etc/hosts file is mapping a hostname to the correct IP address? Using a tool like dig queries an external DNS directly, bypassing the hosts file.
Jay's user avatar
  • 273
17 votes
1 answer
26k views

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

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 ...
yves Baumes's user avatar
17 votes
1 answer
21k views

Hostaliases file with an IP address

The HOSTALIASES environment variable allows users to set their own host aliases instead of having to sudoedit /etc/hosts (more details, e.g., at http://blog.tremily.us/posts/HOSTALIASES/) However, ...
Petr Skocik's user avatar
13 votes
2 answers
3k views

Two different /etc/hosts depending upon the time

I am trying to make a productivity suite for myself. My first goal is to block Facebook, Gmail and Stackexchange from 0900 to 1600. As of now, I have edited my /etc/hosts and added 0.0.0.0 www....
user avatar
12 votes
2 answers
16k views

What's the use for the special ipv6 addresses in /etc/hosts?

I have the following block in my /etc/hosts: # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::...
Gaslight Deceive Subvert's user avatar
11 votes
1 answer
3k views

How is an Elastic IP address different from a static IP address?

More of a Amazon Web Services EC2 question, hopefully not too off topic. I have a vanilla Ubuntu instance with them, and powered it off. On reboot couldn't ssh to the FQDN because the external IP ...
Thufir's user avatar
  • 1,910
10 votes
2 answers
74k views

How can I configure /etc/hosts file to point to apache web server?

I have installed apache web server and I need to point 127.1.1.1 with alias (www.someaddress.lan) to local apache. What is the proper way to do it? How to point someaddress.lan to default apache page ...
J.Olufsen's user avatar
  • 201
10 votes
1 answer
4k views

Why does localhost resolve to ::1 but not 127.0.0.1

With getent hosts localhost, I only get ::1, although I expect 127.0.0.1. I have IPv6 disabled, so getting ::1 is even more surprising. To add to the confusion, when I ping localhost, pings are sent ...
jan's user avatar
  • 921
8 votes
2 answers
860 views

What is the reliable way of getting each user's .ssh directory from bash?

I can parse the /etc/passwd with augtool: myuser=bob usershome=`augtool -L -A --transform "Passwd incl /etc/passwd" print "/files/etc/passwd/$myuser/home" | sed -En 's/\/.* = (.*)/\1/p'` ...but it ...
Adam Ryczkowski's user avatar
8 votes
1 answer
5k views

bash like autocompletion for ssh command in zsh shell with /etc/hosts file?

zsh is great so far. I am using zsh-completions but still I am unable to get autocompletion for ssh commands like in bash as shown in below screenshot: How to get hostnames from /etc/hosts for ssh | ...
Akhil's user avatar
  • 1,310
8 votes
4 answers
18k views

Maintaining `/etc/hosts` for hosts on DHCP

On my local DHCP network I have different PC's that I need to access remotely. Problem is that their IP's change. Sometimes I plug my laptop and netbook into other people's DHCP networks. My current ...
Stefan's user avatar
  • 25.4k
7 votes
3 answers
62k views

/etc/hosts for Debian

I was trying to get a perl script that contacts a PostgreSQL database to work on a server. This script was mysteriously failing. I then realised that localhost was not in the /etc/hosts file. The ...
Faheem Mitha's user avatar
  • 35.3k
7 votes
1 answer
2k views

ignore hosts file in ZSH ssh/scp tab-complete

I use a hosts file to block ads/malware domains. When I use ssh or scp in zsh and try to tab-complete, it takes a good 5-10 seconds before anything appears and what does appear is usually a list of 20+...
Charles Duncan's user avatar
7 votes
2 answers
7k views

Can two hosts have the same IP address in /etc/hosts?

can two hosts share the same IP Address without a conflict. This is how my /etc/hosts looks like :- $ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 debian 127.0.1.1 mini Now as can be seen ...
shirish's user avatar
  • 12.5k
7 votes
2 answers
14k views

Postfix email bounced (mail for domain loops back to myself)

I have a problem when I send a mail to [email protected] for [email protected] My emails has bounced for this error: status=bounced (mail for orbialia.es loops back to myself) May 9 09:33:58 ...
50l3r's user avatar
  • 185
6 votes
3 answers
5k views

/etc/hosts file syntax. Is it possible to set one IP for a zone?

I would like to set one IP for a zone (livejournal.com) currently I am having to directly type the subdomains like: 11.11.11.11 sub1.livejournal.com 11.11.11.11 sub2.livejournal.com 11.11.11.11 sub3....
bakytn's user avatar
  • 2,951
6 votes
2 answers
48k views

What is the proper way to display IPv6 Addresses in /etc/hosts

I've been tasked with writing a document on IPv6 for my colleagues to learn how to configure IPv6 addresses on our hosts. We primarily use RHEL6.x/7.x, ESXi, and Ubuntu Server. This only pertains to ...
BinaryData's user avatar
6 votes
2 answers
29k views

How to map an IP address to localhost

So I have an IP Address 5x.2x.2xx.1xx I want to map to localhost. In my hosts file I have: cat /etc/hosts 127.0.1.1 test test 127.0.0.1 localhost # The following lines are desirable for IPv6 capable ...
user1532587's user avatar
6 votes
2 answers
926 views

Understanding hostnames

I was recently setting up an MTA on a VPS, and while configuring it I realized I’m quite confused about the concept and implementation of hostnames in Unix. I have a solid understanding of the DNS, ...
Joó Ádám's user avatar
5 votes
1 answer
1k views

Ubuntu /etc/hosts addresses in the form *.*.*.*

Let's say a website does not have a domain name like www.google.com and the only way to connect to it is to use an IP address like 216.58.212.68. If I add an entry in /etc/hosts that looks likes 0.0.0....
Bjorn's user avatar
  • 123
5 votes
2 answers
1k views

Should /etc/hosts contain the domain name or the FQDN?

If I want to add an entry to /etc/hosts to resolve all traffic for example.com to 1.2.3.4, do I need to add 1.2.3.4 example.com 1.2.3.4 www.example.com 1.2.3.4 smtp.example.com 1.2.3.4 ...
user3841621's user avatar
5 votes
2 answers
18k views

How to edit /etc/hosts without sudo?

I have a machine that I can only access using SSH. I was messing with the hostnames, and now it says: ssh: unable to resolve hostname I know how to fix it in /etc/hosts. Problem is, I need sudo ...
evamvid's user avatar
  • 698
5 votes
2 answers
14k views

how to configure /etc/hosts properly [duplicate]

I'm learning about networking, at home I have two physical machines and a bunch of VMs that I use to test my applications each machine has a different hostname and I map them manually in each /etc/...
juanp_1982's user avatar
5 votes
1 answer
3k views

Why isn't /etc/hosts blocking domains after I add blocked sites via launchd? [closed]

I've been trying to setup Launchd to block several websites from Chrome on osX 10.12.2 from 9AM - 3PM Monday-Friday I set up launchd to cp /etc/hosts_BLOCKED_sites.txt /etc/hosts Launchd seems to be ...
BryanWheelock's user avatar
5 votes
1 answer
4k views

IPv6 link-local address in /etc/hosts

I have an entry like this in /etc/hosts: fe80::XXXX:XXff:feXX:XXXX%enp0s25 test-ipv6 This is a link-local address. I've masked out my MAC address (with the 7th most significant bit flipped) for this ...
Manuel Jacob's user avatar
5 votes
2 answers
568 views

What application can I use to block hosts with regex?

Is there any tool/application that I can use to block hosts from all forms of connection from my computer? Currently I use /etc/hosts and place the absolute host like this: 127.0.0.1 unix....
DisplayName's user avatar
  • 11.7k
4 votes
3 answers
6k views

How does /etc/hosts match work?

I'm curious about how /etc/hosts entries match works in Linux vs others *nix platform (if there is any difference). In particular I would be interested to understand if "match time" is proportional ...
Simone D.'s user avatar
4 votes
3 answers
7k views

/usr/bin/host not picking up changes to /etc/hosts even after reboot

I have a Ubuntu Server 12.04 (amd64) machine on which, when I change /etc/hosts, the changes aren't picked up, even after a reboot. I am using /usr/bin/host to test, but none of the other programs ...
0xC0000022L's user avatar
  • 16.7k
4 votes
2 answers
5k views

How to make my server use the hosts file to resolve names?

I have a computer with Debian at home, acting as a server with two Ethernet cards: eth0 connected to the router in DHCP mode and eth1 to a switch (static address) that holds four more computers. I'm ...
blade's user avatar
  • 177
4 votes
1 answer
5k views

Only use /etc/hosts for resolving hostnames on Linux

I want to disable DNS lookups via DNS server and only resolve host names that are listed in /etc/hosts. I am on Raspbian 9. How would I set this up?
Matthias's user avatar
  • 143
4 votes
2 answers
6k views

/etc/hosts in debian resets itself on reboot

I've been having a problem where when our vps provider decides to restart the server (running Debian 5.0.8), the server fails to remember changes to /etc/hosts. All I need is an database alias that ...
zclark's user avatar
  • 176
4 votes
1 answer
1k views

Can I map an internal IP address to a domain name, when on a particular network?

I have a server at home, with internal IP 192.168.1.100. I use a dynamic DNS service so that I can reach it at http://foo.dynu.com when I am out. When I have my laptop at home, I know that I could ...
Sparhawk's user avatar
  • 20.1k
4 votes
1 answer
2k views

Single source for both .ssh/config and /etc/hosts

I'm looking for a DRY solution that would allow me both ssh server-alias and ping server-alias I know the former is reading .ssh/config, and the latter /etc/hosts, but I'd rather not repeat the ...
dimid's user avatar
  • 637
4 votes
2 answers
4k views

Browsers doesn't see aliases in /etc/hosts

A company I'm working in has a local site, with documentation and etc. where all references are set to "srv-moss" as a domain name, which should be defined in hosts file. I added it there but it doesn'...
Hi-Angel's user avatar
  • 5,162

1
2 3 4 5