To use the FQDN in /etc/hostname or not? 

Newsgroups:  gmane.linux.debian.user
Date:        Sun, 06 Mar 2005 12:04:07 +0100
> Does /etc/hostname use the fully qualified domain name?
>
> a: www.example.com
> b: www

The recommended way is #2. The canonical host name for the machine is determined by /etc/hosts.

# Primary IP address    # Canonical host name     # aliases
130.28.1.99             www.example.com           www

Thomas Hood

To use the FQDN in /etc/hostname or not? 

> The recommended way is #2...

it should really be done in the dns files itself so that one doesn't need to (re)define it n-times for n-machines and have mis-matches when people change etc/hosts and dont tell nobody and people wonder why innocent-joe's pc work and whacky-bozo's pc fails

use of /etc/hosts should be discouraged unless you are the only one to change it and have just a few boxes to mess round with and do not want to mess around with the whacky dns file formats

Alvin Oga

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

[squid-users] Could not determine fully qualified hostname 

To:   squid-users@squid-cache.org
Date: Tue, 30 Nov 2004

http://www.squid-cache.org/mail-archive/squid-users/200411/0799.html

> Squid Cache (Version 2.5.STABLE5): Terminated abnormally.
> /etc/init.d/squid: line 175: 21702 Abortado
> start-stop-daemon --q uiet --start --pidfile $PIDFILE --exec $DAEMON
> -- $SQUID_ARGS </dev/null

You have two choices. Set a hostname on the box (type "hostname squid.my.domain" at the command prompt, or I'm sure ubuntu has a utility to do so via GUI) or specify a hostname in the squid.conf file using the "visible_hostname" directive. It would probably be best to set the hostname on the box.

Chris Robertson

[squid-users] Could not determine fully qualified hostname 

/etc/init.d/squid start
Starting Squid HTTP proxy: squid
FATAL: Could not determine fully qualified hostname.  Please set 'visible_hostname'
Squid Cache (Version 2.5.STABLE14): Terminated abnormally.
/etc/init.d/squid: line 64:  5813 Aborted                 start-stop-daemon --quiet --start --pidfile $PIDFILE --chuid $CHUID --exec $DAEMON -- $SQUID_ARGS </dev/null
 failed!
$ hostname
cxmr
% hostname cxmr.dyndns.org
$ hostname
cxmr.dyndns.org
% /etc/init.d/squid start
Starting Squid HTTP proxy: squid.
$ cat /etc/hostname
cxmr
% echo cxmr.dyndns.org > /etc/hostname

documented on: 2006.08.13