1

I am setting up a Postfix mail server, hostname 'letters', to handle mail for the domain 'example.net'. I have tried to set letters' domain name to example.net using nis, but I'm getting inconsistent output from hostname -f ('letters.stuff.comcast.net') and domainname ('example.net') How do I set the domain name so hostname -f command to reports 'example.net'? Just how important is this to proper Postfix function?

The host letters is running Ubuntu and connects to the internet by cable modem to Comcast, through an openwrt router. The nameserver for the domain example.net is on a remote Debian computer, which hasn't yet been configured to create a host or an alias for letters.

I suppose that the domain name in the hostname output reflects the domain name obtained from the comcast server by the box's dhcp client, and reflects the idea that the box is a client on that network. Is the solution to create the 'letters' host on the name server for example.net? Does that further require adding that name server to those listed in letters' resolv.conf file?

4 Answers 4

2

Make sure your /etc/hosts (or NIS) entries are correct.

I was going to attempt to explain it, but the manpage tells the story better:

THE FQDN
    You can't change the FQDN (as returned by hostname --fqdn) or  the  DNS
    domain  name (as returned by dnsdomainname) with this command. The FQDN
    of the system is the name that the resolver(3)  returns  for  the  host
    name.

    [..]

    Therefore  it  depends on the configuration (usually in /etc/host.conf)
    how you can change it. Usually (if the hosts file is parsed before  DNS
    or NIS) you can change it in /etc/hosts.
2
  • This works. I had read the man page, but worried about the "usually". I also wondered if correct configuration and procedure called for setting the domain name in one place, and if setting it in two places reflected some problem with my configuration. Thanks.
    – chernevik
    Jul 16, 2009 at 18:41
  • I should probably add - the qualified address that hostname -f returns would likely be used by Postfix for completing unqualified addresses if you don't specify otherwise in the config.
    – Dan Carley
    Jul 16, 2009 at 18:48
1

I ran into this problem yesterday while working on a server refresh that someone else started... The hostname -f output never had the correct ending domain (missing .org).

# hostname foobar.example.org
# hostname -f
foobar.example
#

# cat /etc/hosts
10.20.11.244    foobar.example foobar

The solution:

The domain portion of hostname -f seems to have come from an /etc/hosts entry for that host. After I fixed the hostname in /etc/hosts, hostname -f was returning the correct domain:

# hostname foobar
# hostname
foobar
# hostname -f
foobar.example.org

YMMV.

1

If you IP is not static, then the /etc/hosts will not work for you (or will only temporarily work until you get a new IP). I am not sure if this will work, but here is something to try:

  1. configure your dhcp client to not request the domain-name from the dhcp server. Or just tell it not to touch resolv.conf at all, which you may have already done if you have custom name servers.
  2. Set your domain name to example.net in /etc/resolv.conf
  3. make sure your nameserver can resolve letters.example.net, I guess you will need to use some kind of dynamic dns service, since this solution is for non-static IPs.

Which might mean that my answer to your question is simply, "yes".

1
  • Thanks. It sounds like the hosts file edit isn't a stable fix, though I guess it will do for now. I'm looking at revising dhclient.conf to "supersede" whatever domain name I get from my dhcp server, but I want to first better understand dhcp. And yeah, I've got figure out how to keep the ip address for the letters host up to date on the name server.
    – chernevik
    Jul 17, 2009 at 2:05
0

This is a commonly misunderstood problem with "domainname". Here's the top of the man page on my Mac OS X system, but yours will be similar:

DOMAINNAME(1)             BSD General Commands Manual            DOMAINNAME(1)

NAME
     domainname -- set or print the name of the current NIS domain

This command is not used for DNS configuration!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .