Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 2
    Using the glibc and linux, this is not so straightforward unfortunately. If you call gethostbyname and the system is setup accordingly (default on many systems) then it will instead of reading /etc/host call the nscd. I have no idea if the nscd will cache only hits in the file or try to cache it as a whole. In the later case, you would have a ram limitation for the file size (assuming that the nscd config allows that much entries) Commented Aug 29, 2017 at 12:08
  • 1
    The 4.3BSD version is here. It supported a dbm-hashed version of /etc/hosts. IIRC, dbm imposed some size limits that could cause attempts to create a hashed db to fail. Commented Aug 31, 2017 at 11:53
  • GNU libc also has libnss_db to allow use of Berkeley db files for hosts and other NSS databases (including passwd, group, shadow, services, etc). Also provides the makedb binary and a Makefile to generate .db files from plain text. There are also 3rd-party NSS plugin modules for using postgresql, mysql, sqlite, etc (but i'm not sure if they can be used for any NSS db or are limited to just passwd, group, and shadow). Commented Sep 12, 2022 at 1:01