Talk:TIP Setup Your FQDN
From Gentoo Linux Wiki
So /etc/hosts should become something like this:
127.0.0.1 hostname.domainname localhost hostname
192.168.0.1 hostname.domainname hostname
or if you get your IP address by DHCP use the following:
127.0.0.1 localhost
127.0.0.2 hostname.domainname hostname
For example:
127.0.0.1 localhost
127.0.0.2 ulysses.smellydomain.lan ulysses
'localhost' should always be listed first after '127.0.0.1'
From 'man hosts' the format of /etc/hosts is:
IP_address canonical_hostname aliases
and the canonical name for 127.0.0.1 is 'localhost'
If you do not have this, other programs may give unexpected behaviour. For example: xinetd by default is configured to accept connections only from 'localhost'; when it gets a connection it does a reverse lookup of the IP address and if that resolves to 'localhost' the connection is accepted. The name obtained from a reverse lookup of 127.0.0.1 is that which is listed first in /etc/hosts so if that is not 'localhost' then a connection from the local host is rejected.
Paul
/etc/dnsdomainname and /etc/hostname are now deprecated.
Modify /etc/conf.d/domainname and /etc/conf.d/hostname intead.
Angela
I edited /etc/conf.d/domainname and /etc/conf.d/hostname but the files don't seem to be getting read on startup. What do you have to do activate them?
You need to make sure domainname is run on startup.
rc-update add domainname default
Jason
Hi all, this is driving me nuts. I decided to try gentoo 2005.0, nice and everything except DNS in the LAN. I have set up a stage3 on x86_64 from the Net.
The thing is I've set up everything as written above, except I DON'T have a domainname on the LAN- the computers use hosts files and the DNS from the router to find each other, and are behind NAT.
I thought this might have been the problem, so I set a domainname on the router(DI-604). Set up that in gentoo. Domainname is run. ".unknown_domain" stays(WTF?!). I CAN MAKE NO LOOKUPS in my LAN whatsoever. I can't resolve even localhost. The /etc/hosts seems ok(has worked on Fedora and Debian), formed like described above, but anyway, when I try a ping, a hostx or anything, a.root-servers.net gives a not found.
The hosts file is there, the routers internal IP is set in resolv.conf, the router is running a DNS server(that has worked with everything else), but as it seems is not queried at all, nor is /etc/hosts. I can't resolve even localhost. Same error. Is this a bug, or have I messed up/missed something? External addresses work fine.
Thanks, Jacint Toth
I have the same problem as Jacint. Any one have a resolution?
I also encountered this problem for my 22nd July 2005 gentoo installation. After few minutes of fiddling around I noticed that my freshly new installed gentoo _doesn't_ have /etc/nsswitch.conf . A quick copy from another gentoo machine resolved this. :)
regards,
linuxlah from mygentoo.cjb.net
What makes configuration of this thing on Gentoo so fundamentally problematic?
Jason, what about running "hostname" at startup? And shouldn't both "hostname" and "domainname" be run not in runlevel "default" but rather runlevel "boot"?
Hi, when I set my hostname to "pulsar00" (in /etc/hosts and /etc/conf.d/hostename) then I've got the ".unknown_domain" error. BUT when I set it to "pulsar", It's works... It's crazy...
[edit] problems with dnsmasq
if you are using dnsmasq on your gateway for name resolving do not add a alias of the wanted hostname to 127.0.0.1
your lan clients will resolve "gateway.somedomain" always to 127.0.0.1.
so you should use seperate host entries: 127.0.0.1 localhost 10.0.0.1 gateway
---
[edit] Out of date
There is a different way of doing this now
rc-update add domainname boot * rc-update: '/etc/init.d/domainname' not found; aborting
Don't know what it is though
--- I also noticed the rc-update doesn't fuction. If you add the entry to /etc/hosts in the format: xxx.xxx.xxx.xxx fqdn system
it loads the domainname properly.
[edit] DNSMasq resolving FQDN to 127.0.0.1 for external clients - a solution
To avoid dnsmasq resolving queries for your fqdn to 127.0.0.1, feed dnsmasq an alternate /etc/hosts (void of 127.0.0.1) at startup. Ugly, but it works. Unfortunately it seems that DNSMasq has a bug: it shows different behaviour when started with and without '-d'. Anyway, behold the relevant portions my /etc/init.d/dnsmasq:
start() {
ebegin "Starting dnsmasq"
cp /etc/hosts /etc/hosts.dnsmasq
grep -v 127.0.0.1 /etc/hosts.dnsmasq > /etc/hosts
/usr/sbin/dnsmasq -x /var/run/dnsmasq.pid -d -z > /dev/null 2>&1 &
mv /etc/hosts.dnsmasq /etc/hosts
eend $?
}
reload() {
ebegin "Reloading dnsmasq"
cp /etc/hosts /etc/hosts.dnsmasq
grep -v 127.0.0.1 /etc/hosts.dnsmasq > /etc/hosts
kill -HUP $(< /var/run/dnsmasq.pid)
mv /etc/hosts.dnsmasq /etc/hosts
eend $?
}
And the matching /etc/hosts:
11.11.11.1 yourfqdn 127.0.0.1 yourfqdn yourhostname localhost localhost.localdomain 192.168.0.1 someinternalhost 192.168.0.8 someotherinternalhost
You'll need your DHCP server to tell the clients using dnsmasq to construct an /etc/resolv.conf like this:
domain yourfqdn nameserver ip-of-your-nameserver
On the dnsmasq host, configure /etc/conf.d/net to construct an /etc/resolv like this:
domain yourdomain search yourfqdn nameserver 127.0.0.1
Set up a special /etc/resolv.conf.dnsmasq just for dnsmasq as well:
search yourfqdn nameserver ip-of-upstream-isp-dns nameserver ip-of-upstream-isp-dns
and in dnsmasq.conf (listening on both 127.0.0.1 and some class A/B/C interface reachable by the clients) be sure to set:
resolv-file=/etc/resolv.conf.dnsmasq local=/yourfqdn/ expand-hosts domain=yourfqdn
