Latest LQ Deal: Latest LQ Deals
Go Back > Blogs > Anybody's business
User Name


Should I log my journey through
Let's go...
Rate this Entry

Keeping /etc/hosts up to date (dhcp)

Posted 02-28-2021 at 04:30 AM by Ninguém
Updated 03-02-2021 at 03:28 AM by Ninguém
Tags incomplete

When you get your IP address using DHCP in a domain your /etc/hosts file, as well as /etc/networks might get out of sync with reality.
If I plug my laptop to the wifi network at the library, for example, my /etc/hosts has a line like the following one:
Code: myhost
Where, in fact, it should be something like:
Code: myhost
The same thing happens to /etc/networks where a line like the following one should be added:
and removed after the DHCP release.
I posted the question to the Linux - Networking forum in this thread: keep /etc/hosts up to date (dhcp) in the hope that someone might have an answer...
zrong suggested to point my hostname to my loopback interface so it could always be found, as well as information about IPv6 networking that I am not prepared to take into consideration just yet, but then tools like domainname or login won't know the correct domain to show.
I know ping would work, but...
computersavvy rightly pointed out that having the local domain name appear on the login screen would be (almost) a magic trick since the laptop would have no communication with that network before the DHCP handshake.
zrong, again, pointed me to the debian wiki network configuration page (side note: Should debian be spelled with a Capital "D", maybe even with both capital "D" and "I"?... Just a provoking thought).
zrong mentioned, as well, that a line with reference to in /etc/hosts is Debian specific. I remember seeing a reference to it stating something like being needed by gnome. I don't have it and haven't seen any negative consequences.
It's, maybe, a good question to pose to the Debian social group.
zrong finally mentions how to completely disable IPv6, which I had already partially done.
Posted in Questions
Views 44 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 11:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration