Skip to main content
Share Your Experience: Take the 2024 Developer Survey
59 votes
Accepted

What is the /etc/hosts size limit?

Problematical effects include slow hostname resolution (unless the OS somehow converts the linear list into a faster-to-search structure?) and the potential for surprising interaction with shell tab ...
thrig's user avatar
  • 35k
35 votes
Accepted

How do I modify my hosts file in Nixos?

Modify the nixos config (usually in /etc/nixos/configuration.nix) with: networking.extraHosts = '' 127.0.0.2 other-localhost 10.0.0.1 server ''; This is documented at NixOS Wiki and ...
Chris Stryczynski's user avatar
32 votes
Accepted

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

This is dictated by the NSS (Name Service Switch) configuration i.e. /etc/nsswitch.conf file's hosts directive. For example, on my system: hosts: files mdns4_minimal [NOTFOUND=return] dns Here, ...
heemayl's user avatar
  • 56.5k
23 votes

What is the /etc/hosts size limit?

I don't think it has a size limit in terms of number of lines. Before DNS (which was brought into use in 1985), it was this file that served as the only means for doing host name lookups, so I ...
Kusalananda's user avatar
  • 337k
17 votes
Accepted

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

The main difference between the two is that: You will lose your Public IP when you Stop and Start the instance, while the EIP remains linked to the instance even after the Stop/Start operation (...
Echoes_86's user avatar
  • 752
15 votes

Understand hostname and /etc/hosts

/etc/hostname and /etc/hosts are simple, but also not so simple... How to quickly setup Debian /etc/hostname and /etc/hosts 1) Edit /etc/hostname. There are 2 valid ways to set this up. Either ...
Elliptical view's user avatar
14 votes

What is the /etc/hosts size limit?

How can I determine the size limit of /etc/hosts? It is a regular file, so the limit would correspond to the underlying filesystem's limits (which would itself be capped by the number of disks behind ...
Jeff Schaller's user avatar
  • 67.5k
14 votes
Accepted

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

No. The hosts file doesn't affect any routing. It only affects name lookups. Since 216.58.212.68 is an IP address, the system won't look it up in the hosts table. Read here for more info on the ...
Tim Kennedy's user avatar
  • 19.7k
11 votes

What is the /etc/hosts size limit?

Size limits only apply when allocating static buffers. gethostbyname(3), which parses the entries in /etc/hosts, does not allocate static buffers - and never has. The original 1983 release of BSD 4.3 ...
bishop's user avatar
  • 3,219
10 votes

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

The hosts file format consists of lines, each of which contains the IP address, followed by whitespace, then one or more hostnames, also separated by whitespace. Nothing changes when the address is ...
Michael Hampton's user avatar
9 votes

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

Name resolution, amongst other things, is managed by /etc/nsswitch.conf. Here is an excerpt: passwd: files sss shadow: files sss group: files sss hosts: files dns myhostname (...) ...
dr_'s user avatar
  • 29.9k
9 votes
Accepted

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

Zsh won't offer you host completions until you enable its full completion system. You can do so by adding the following to your .zshrc file: autoload -Uz compinit compinit Once initialized, Zsh's ...
Marlon Richert's user avatar
8 votes

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

I faced the same need, so I tried libnss-userhosts, but it fails at multithreaded applications. Therefore I have written libnss-homehosts. It's very new and tested only by me. You may give a chance ...
bandie's user avatar
  • 383
6 votes

Simple name server alternative a la /etc/hosts

Dnsmasq will serve up the data in your /etc/hosts file as a dns server - authoritative for your lical domain and providing caching for internet lookups. It also provides a dhcp server.
symcbean's user avatar
  • 5,641
6 votes

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

IPv6 addresses have their own formatting system because they represent an 128-bit addressing space: that's 16 octets, which would be extremely unwieldly! As well, at this time there are a lot of runs ...
ErikF's user avatar
  • 4,087
6 votes
Accepted

How to map an IP address to localhost

/etc/hosts can be used if you want to map a specific DNS name to a different IP address than it really has, but if the IP address is already specified by the application, that and any other techniques ...
telcoM's user avatar
  • 98.1k
6 votes
Accepted

Understanding why hostname -i returns strange IP address

Unlike the hostname -I command, which just lists all configured IP addresses on all network interfaces, the hostname -i command performs name resolution (see the hostname man page). Since your newly ...
ozzy's user avatar
  • 845
6 votes
Accepted

/etc/hosts and aliases

From man hosts: 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....
James John's user avatar
6 votes

How can I fix? Systems says "Host is down" and will not boot

RIP systemd. Use service instead. type in # service --status-all and see if it is functional. Then do all of your above commands using service syntax and you should be functional. Once you are ...
SwArMD's user avatar
  • 71
5 votes

Creating alias to domain name with /etc/hosts

As stated, /etc/hosts was not intended to provide alias (CNAME) ability for name to IP lookups. While setting up a proper DNS server and configuring the CNAME there would definitely be an always-...
Nab Eng's user avatar
  • 61
5 votes
Accepted

Set a host name alias in /etc/hosts?

Is there anyway to set a host to url? E.g. something like the following in /etc/hosts That is not a URL. Its a hostname. The point of the /etc/hosts file is that it provides an alternative to DNS for ...
symcbean's user avatar
  • 5,641
5 votes
Accepted

Only use /etc/hosts for resolving hostnames on Linux

Remove dns from hosts field in /etc/nsswitch.conf: hosts: files You might also want to remove the DNS servers from /etc/resolv.conf.
sebasth's user avatar
  • 15k
5 votes
Accepted

/etc/hosts not blocking anything

macOS has a DNS cache, and if the IP addresses of the problem sites are already in your DNS cache, editing /etc/hosts won't have an immediate effect. The procedure for flushing the DNS cache is ...
telcoM's user avatar
  • 98.1k
5 votes

What is the purpose of /etc/hosts?

Using the /etc/hosts file to give a human readable name to a local system within a desktop environment is perfectly reasonable. The hosts file is great to use in a home network or even in a small ...
francois P's user avatar
  • 1,229
5 votes
Accepted

How to ignore hosts file?

I do not know if there is browser based utility to do this. But you can do it for the entire OS. The key file is /etc/nsswitch.conf. To support only DNS records you should have record inside like: ...
Romeo Ninov's user avatar
  • 17.7k
5 votes
Accepted

Is it ok to combine machines with DNS server management and machines that do host lookups through a hosts file?

On one level this is a policy decision and nothing to do with the technology. On another level you should be asking yourselves why you don't want this second cluster properly supported by your ...
Chris Davies's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible