Where is the computer network name set and stored ?

Tim ignored_mailbox at yahoo.com.au
Thu Sep 22 10:49:40 UTC 2011


On Wed, 2011-09-21 at 23:51 -0600, linux guy wrote:
> It appears to me that the only way to truly change the hostname of a
> machine is to edit /etc/sysconfig/network. But I might be wrong.

Not the only way.  As others will say, you can set it in a file.

Or, the computer can work it out for itself, when it brings the network
interface up.  

When assigned an IP, or bringing up an interface using an IP that you've
preconfigured it with, it does a name lookup to find the name associated
with that IP.  This lookup can be answered by your hosts file, or a DNS
server.

e.g. Up comes eth0.
     eth0 is 192.168.1.2  (by whatever method that address is assigned)
     get the named address for that IP.
     finds out it's mailserver.example.com
     works out that its hostname is mailserver,
     and its domain name is example.com

So, the hosts file (or DNS server) doesn't so much "set" the hostname,
but answers the "Who am I?" question.  (Almost the same thing, but not
quite, to be pedantic.)

-- 
[tim at localhost ~]$ uname -r
2.6.27.25-78.2.56.fc9.i686

Don't send private replies to my address, the mailbox is ignored.  I
read messages from the public lists.





More information about the users mailing list