Changing hostname 

Newsgroups:  gmane.linux.debian.user
Date:        Tue, 13 Jul 2004 04:00:14 +0300

*Tags*: debian:hostname

> Quick question how to change hostname under debian?
>
> I changed my /etc/hosts
> from
> 127.0.0.1       cxmr                         localhost
> to
> 127.0.0.1       cxmr.dyndns.org                 localhost
>
> but why my hostname is still reporting merely 'cxmr'?
> How to fix it? (Surely I've rebooted).

first thing, you host name is merely cxmr. dyndns.org is your domain name, not part of your hostname. That should appear in the domain directive in your /etc/resolv.conf if you want.

To change your hostname you can edit /etc/hostname or run hostname <new host name>

Micha Feigin

Changing hostname 

> first thing, you host name is merely cxmr.

Nah, if I do it that way, Squid will complain:

Squid Cache (Version 2.5.STABLE14): Terminated abnormally: FATAL: Could not determine fully qualified hostname. Please set 'visible_hostname'

Changing hostname 

Thanks everyone for the reply.

I can say that changing the hostname, though seems simple, is the most convoluted part in Linux. As expressed by Kent West:

,-----
| there may be several places in the /etc directory where it is
| specified in various config files, such as /etc/hosts. There may
| be a squid config file that needs changing also. You might want to
| run something like "grep -r -n cxmr /etc" to find all the
| locations where the filename is used.
`-----

In RedHat, when using linuxconf, all the following files have been changed. I checked *every one of them* before posting my question.

/etc/hosts
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network
/etc/conf.modules
/etc/conf.linuxconf
/etc/HOSTNAME
/etc/networks

Micha Feigin's comment seems to be the most professional to me:

,-----
| first thing, you host name is merely cxmr.  dyndns.org is your
| domain name, not part of your hostname. That should appear in the
| domain directive in your /etc/resolv.conf if you want.
`-----

However, this approach doesn't seem to be necessary to me:

$ cat /etc/hostname
cxmr.dyndns.org
$ cat /etc/resolv.conf
search
nameserver 24....
nameserver 24....
$ hostname
cxmr.dyndns.org
$ hostname --fqdn
cxmr.dyndns.org
$ dnsdomainname
dyndns.org

You see, everything seems to be fine. (!?)

Paul Johnson's comment makes me think that changing the hostname is far from simple:

,-----
| > 127.0.0.1       cxmr.dyndns.org                 localhost
|
| 127.0.0.1    localhost
| <your-ip>    cxmr.dyndns.org    cxmr
`-----

That's actually what I want to do. I.e., I want my FQDN reflects my real IP address, not localhost, but that seems impossible, because I'm getting a new IP every time I reboot.

Any comments? Thanks

Changing hostname 

> Paul Johnson's comment makes me think that changing the hostname
> is far from simple:
>
> ,-----
> | > 127.0.0.1       cxmr.dyndns.org                 localhost
> |
> | 127.0.0.1    localhost
> | <your-ip>    cxmr.dyndns.org    cxmr
> `-----
>
> That's actually what I want to do. I.e., I want my FQDN reflects
> my real IP address, not  localhost, but that seems impossible,
> because I'm getting a new IP every time I reboot.

Personally I'd use the dyndns stuff found in Debian already.

[greg@duke:greg]$ apt-cache search dyndns
ddclient - Update dynamic IP address at DynDNS.org
ddns3-client - Issues dynamic DNS v3 requests
ez-ipupdate - client for most dynamic DNS services
ipcheck - Dyndns.org client to register your dynamic IP address

Some of those can already update you hostname proper and your ipaddr with dyndns.org.

Since I suppose you do not have a Firewall Machine, you should really not need to have anything other than it be you in your localhost line as well.

127.0.0.1 cxmr.dydns.org cxmr localhost.localdomain localhost

As the machine KNOWS it is cxmr, when you resolve it from itself then.

Also, it really isn't any problem when the DHCP Client gets a different address.

Now, if you have a firewall machine with 2+ NICS in it. Assign that name to one of the static ones on it. Since the name points to the same machine from inside and out (just on different interfaces) the DHCP/DYNDNS client will have zero problem when you tell it "eth0" or what ever you call it is the public facing and dynamic interface (otherwise usually called the "untrusted interface")

Really this is quite over done, but sometimes I tend to regurgitate to much info, causing glassy/glazed-eyes on the recipient.

So, the real question of the moment: Is it done yet?

Greg Folkert

Changing hostname 

Run 'hostname —fqdn' and see if you FQDN is what you actually want :-)

Also, I would have modified the line to say the following:

127.0.0.1       cxmr.dyndns.org                 cxmr localhost

Maybe that's unnecessary, I don't know.

Magnus Therning

Changing hostname 

> 127.0.0.1       cxmr.dyndns.org                 localhost
127.0.0.1    localhost
<your-ip>    cxmr.dyndns.org    cxmr

Paul Johnson