Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

81%
+7 −0
Q&A What does a minimal /etc/hosts need to contain?

I run an environment that, until recently, did all local name resolution by putting names in /etc/hosts. I'm in the process of replacing that with local DNS. The DNS part works fine, and now I'm tr...

1 answer  ·  posted 2y ago by ajv‭  ·  last activity 2y ago by dsr‭

Question linux hosts
#3: Post edited by user avatar ajv‭ · 2022-05-16T19:08:41Z (about 2 years ago)
#2: Post edited by user avatar ajv‭ · 2022-05-16T17:56:41Z (about 2 years ago)
  • I run an environment that, until recently, did all local name resolution by putting names in /etc/hosts. I'm in the process of replacing that with local DNS. The DNS part works fine, and now I'm trying to clean the old entries out the /etc/hosts files. It seems to me that, rather than try to sed-out bogus entries and hope I didn't miss anything important, it will be simpler to replace each system's /etc/hosts with a clean copy.
  • What does a minimal working /etc/hosts file need to contain? So far I have this:
  • ```conf
  • 127.0.0.1 localhost
  • # some sources suggest 127.0.1.1 for the fqdn and hostname; it seems to
  • # me that the local private IP is a better idea, so the machine sees
  • # the same address for itself that its peers do.
  • 192.168.x.y $HOSTNAME.$DNSDOMAIN $HOSTNAME
  • # These are in a stock ubuntu install; I am unsure of their universality.
  • # All machines in question have an ip6 address, but some are
  • # link-local only.
  • ::1 ip6-localhost ip6-loopback
  • fe00::0 ip6-localnet
  • ff00::0 ip6-mcastprefix
  • ff02::1 ip6-allnodes
  • ff02::2 ip6-allrouters
  • ```
  • I run an environment that, until recently, did all local name resolution by putting names in /etc/hosts. I'm in the process of replacing that with local DNS. The DNS part works fine, and now I'm trying to clean the old entries out of the /etc/hosts files. It seems to me that, rather than try to sed out bogus entries and hope I didn't miss anything important, it will be simpler to replace each system's file with a clean copy.
  • What does a minimal working /etc/hosts file need to contain? So far I have this:
  • ```conf
  • 127.0.0.1 localhost
  • # some sources suggest 127.0.1.1 for the fqdn and hostname; it seems to
  • # me that the local private IP is a better idea, so the machine sees
  • # the same address for itself that its peers do.
  • 192.168.x.y $HOSTNAME.$DNSDOMAIN $HOSTNAME
  • # These are in a stock ubuntu install; I am unsure of their universality.
  • # All machines in question have an ip6 address, but some are
  • # link-local only.
  • ::1 ip6-localhost ip6-loopback
  • fe00::0 ip6-localnet
  • ff00::0 ip6-mcastprefix
  • ff02::1 ip6-allnodes
  • ff02::2 ip6-allrouters
  • ```
#1: Initial revision by user avatar ajv‭ · 2022-05-16T17:55:42Z (about 2 years ago)
What does a minimal /etc/hosts need to contain?
I run an environment that, until recently, did all local name resolution by putting names in /etc/hosts. I'm in the process of replacing that with local DNS. The DNS part works fine, and now I'm trying to clean the old entries out the /etc/hosts files. It seems to me that, rather than try to sed-out bogus entries and hope I didn't miss anything important, it will be simpler to replace each system's /etc/hosts with a clean copy.

What does a minimal working /etc/hosts file need to contain? So far I have this:

```conf
127.0.0.1     localhost
# some sources suggest 127.0.1.1 for the fqdn and hostname; it seems to
# me that the local private IP is a better idea, so the machine sees
# the same address for itself that its peers do.
192.168.x.y   $HOSTNAME.$DNSDOMAIN  $HOSTNAME

# These are in a stock ubuntu install; I am unsure of their universality.
# All machines in question have an ip6 address, but some are
# link-local only.
::1           ip6-localhost ip6-loopback
fe00::0       ip6-localnet
ff00::0       ip6-mcastprefix
ff02::1       ip6-allnodes
ff02::2       ip6-allrouters
```