Subject: Re: Re-reading /etc/hosts or /etc/rc.conf
To: Matthew Theobalds <mtheobalds@mac.com>
From: gabriel rosenkoetter <gr@eclipsed.net>
List: port-mac68k
Date: 04/10/2001 19:20:05
On Tue, Apr 10, 2001 at 10:29:20PM +0100, Matthew Theobalds wrote:
> Firstly I will state what I consider to be true.
> 
> - A network has a domainname let's say mine is oops.com
> - Each machine has a hostname, in my case gellum
> - To the rest of the universe, that machine (assuming everything else is 
> right) should be found at gellum.oops.com
> 
> If that is correct, we can continue.

That's not exactly correct in a couple of ways.

First, hostname is a misnomer here, as any dotted domain name is
just that, a domain name. Domain names, at any point, can refer to a
host. And subdomains of that domain can also point at hosts. The
top-level domains are special cases. (Trying to connect to "net"
won't get you much, trying to connect to eclipsed.net will get you
to 130.58.82.137, trying to connect to uriel.eclipsed.net will get
you to the same place, but trying to connect to rubicon.eclipsed.net
will get you to 130.58.82.109.) A host name is, properly, just that,
a name. (In the examples here, "uriel" or "rubicon" are hostnames.)

Second, you, as the administrator solely of gellum, do not necessarily
have control over what the rest of the world sees. Whatever machine
controls the start of authority (SOA) records for oops.com is the
one who tells the outside world that gellum.oops.com routes to your
host's IP address. You can set hostname all you want, it won't be
propagated unless it's in the authoritive domain name servers (DNS)
for the oops.com domain. I'm presuming you have some kind of control
over the oops.com primary and secondary DNSes and that gellum.oops.com
is already pointed at your IP address, but if that's not the case,
none of the rest of this matters.

> In /etc/rc.conf, basic parameters are set which are read by other 
> programs at boot-up. All of these can be changed, let's say using the 
> commands domainname and hostname as root.

That much is true.

> Setting the domainname to oops.com and the hostname to gellum should 
> ensure that email sent -out- from that machine appears to come from 
> user@gellum.oops.com
> 
> Would this be a foolish assumption?

Yes.

domainname is not involved in DNS resolution at all, it is the
yellow pages/network information system (YP/NIS) domain within which
the machine resides. Unless you're actually using NIS in an
environment with multiple NIS domains, it needn't be set (and
setting it won't change much, especially if you're not running
ypbind, which I'm guessing you're not.)

The way in which email goes out is by whatever your mail user agent
(MUA, such as pine or mutt) thinks is the appropriate thing. If
your hostname is "gellum" and you haven't told your MUA differently,
this will likely be user@gellum. Some MUAs might append your NIS
domainname to this, but they would be wrong. But really, you can
tell your MUA to put whatever you want in the header and the simple
mail transport protocol (SMTP) server through which your mail is
relayed will glad accept it as the envelope From address. Your MUA
needs to be told what your return address is to properly format the
outgoing SMTP message.

> However, in each case, the email has come back saying that it has merely 
> come from user@gellum If, however, I changed the hostname to 
> gellum.oops.com makes it works, and the email indeed appears to come 
> from user@gellum.oops.com

See above.

This kind of misunderstanding has led to misuse of the hostname
setting, but it's really not supposed to be used for that. (This is
true of all Unix-like operating systems. Hell, it's true of all
operating systems, but on ones that don't think too heavily about
their hostname, the MUAs--such as Eudora or Microsoft Outlook--
demand to be told what your return address is for precisely this
reason.)

> This isn't a major problem as such (although it ruins the info posted on 
> logging in) but isn't that wrong? Or have I missed something else?

Really, trust me, set your hostname to "gellum" and change your MUA
settings. It's the Right Way. It is possible to have sendmail (or
whatever you replace it with--Postfix and qmail both provide a
sendmail call-alike function) remap all outgoing email with a
specific return domain name (keeping the username), but I don't
remember how to do that off the top of my head. (Many MUAs just call
the userland sendmail to pass their outgoing mail, which is arguably
the Right Way to go about things. This does NOT run sendmail as a
server, it merely asks it to make the SMTP connection to the next
server down the line on the way to the recipient of the email.)

Presuming DNS is set properly, as discussed above, and presuming
you're running some kind of SMTP server (sendmail, Postfix, qmail,
etcetera) on gellum, you need to tell that SMTP server that it
should accept mail as "gellum.oops.com". Someone else posted (some
of) the instructions on to do this with sendmail. I haven't used
sendmail in years, and I'm a much happier system administrator for
it, so here are the Postfix instructions. We have a very good
(installed by default?) Postfix package in NetBSD, and I'd
personally strongly recommend it over sendmail, but your mileage may
vary.

For Postfix, unless your machine's reverse DNS lookup (that is, do a
nslookup on your IP address) returns gellum.oops.com (that is,
gethostname() returns gellum.oops.com), you will need
to set $myhostname to "gellum.oops.com". $mydomain defaults to
$myhostname minus the first chunk, but setting it to "oops.com" explicitly
couldn't hurt. $myorigin is the important one for locally posted
email. It defaults to $mydomain, but again, setting it to that
explicitly couldn't hurt. If you want to receive mail with
additional names (mail.oops.com, just oops.com), you'll want to
include those in $mydestinations.

Hope this helps...

       ~ g r @ eclipsed.net