Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

127.0.0.1 should reference localhost, not the hostname #6210

Open
intereglementet opened this issue Feb 16, 2024 · 1 comment
Open

127.0.0.1 should reference localhost, not the hostname #6210

intereglementet opened this issue Feb 16, 2024 · 1 comment
Labels
networking Issues related to networking features (--net=, etc)

Comments

@intereglementet
Copy link

/etc/hosts files typically contain something like this:

127.0.1.1 my-hostname
127.0.0.1 localhost

This makes the following feature typically do away with the localhost entry, and you end up with two hostname entries.

if (strstr(buf, "127.0.0.1") && done == 0) {

This causes problems for applications referencing localhost. The above line should, I think, instead look for 127.0.1.1.

A workaround is to have two localhost entries in the original file, as only one 127.0.0.1 entry is processed.

@intereglementet
Copy link
Author

I did some additional googling. The conclusion is that having 127.0.0.1 alterered and set to anything other than "localhost" is, unfortunately, plain wrong.
The thing with 127.0.1.1 being set to whatever /etc/hostname contains appears to be a de facto standard introduced into debian almost 20 years ago.

@kmk3 kmk3 added the networking Issues related to networking features (--net=, etc) label Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
networking Issues related to networking features (--net=, etc)
Projects
None yet
Development

No branches or pull requests

2 participants