2014-06-13 Fri 08:23
debian/Ubuntuの/etc/hostnameにはFQDNではなくshort nameを書く
Ubuntuのインストール時にFQDNを書いても/etc/hostnameにはshort nameが入るし、Vagrantのconfig.vm.hostnameにFQDNを書いてもドメイン部分落とされるし、どういうことなんだろうと思ったらdebianマニュアルのホスト名の項に書いてありました。
3.2.5. The hostname The kernel maintains the system hostname. The init script in runlevel S which is symlinked to "/etc/init.d/hostname.sh" sets the system hostname at boot time (using the hostname command) to the name stored in "/etc/hostname". This file should contain only the system hostname, not a fully qualified domain name.﹁only﹂を太字にするレベルで守られるべきルールのようです。 serverfaultにSetting the hostname: FQDN or short name?として、CentOS, RHEL, debianの違いがまとまっていました。 自分もCentOSを使ってた時は/etc/sysconfig/networkにFQDNを書いていたのですが、debian系では ●/etc/hostnameにshort nameを書く ●/etc/hostsに書くなど名前解決のレイヤでFQDNを補完する といったルールが敷かれているようです。﹁hostnameだからドメインは関係ないだろ!﹂ってことなんでしょうか。一理ある。 Ubuntuのhostnameコマンドのmanにも、
You can't change the FQDN (as returned by hostname --fqdn) or the DNS domain name (as returned by dnsdomainname) with this command.という記述がありますね。