Hostname and server with multiple domains

This is a back to basics question, I guess, for things I've long forgotten. If I set up a server for four web sites, each with their own unique domain name, what should the hostname be in /etc/rc.conf?

Note that this same server is going to be handling email for them in their own domains, too. A lot of my reading talks about setting the hostname, then, to but, since it's also a web site server, I'm not sure what I should put there.

And to complicate things a bit more, this is a VPS with two static IPv4 addresses. The plan is to put one of the sites on one IP by itself.
AFAIK you can set it to what you like. I do not know of any need to have the same hostnames for the internal and external nets.

You set up the domain and subdomains that your servers listen to in their respective .conf files.
E.g. httpd.conf and squid.conf (if you use squid as reverse proxy) for the virtual hosts. The same with yourmailserverprogram.conf.
Yes you can use whatever you like in hostname as long as the name resolves to an address during the system startup. The usual trick is to match hostname to an entry in /etc/hosts:


Code: myhost.mydomain.tld

If you have multiple domains you then have to tell Sendmail in /etc/mail/local-host-names which ones are accepted as the destination domains for incoming mail.
kpa Yeah, that's what I'm having trouble with in my tinkering so far. I have the four names in local-host-names, and that works. Someone else set the hostname to "www" and left it that way but, when it worked, it just added to my confusion.

So I'm thinking of doing:


and then in /etc/hosts

Code: localhost
... etc.

Would that be right if they wanted naked domains? I don't think I can leave the www off the hostname. I'm having trouble with email spf and dmarc complaining about host names not matching up due to mail from but sender is (using sendmail). Now that I type that, I think I realized that I was using somewhere.

Like I said, I just started tinkering with this and I'm doing so much reading and testing I think I'm getting myself turned around.
If you want to be a valid address the domain has to be in /etc/mail/local-host-names, same for any other "naked" domain. You don't need the entry for the naked domain in /etc/hosts because that's never looked up by Sendmail. Anyone sending mail to would look up the MX records for and connect to whatever host(s) is set there for mail delivery and Sendmail doesn't then care if the naked domain then resolves to an address or not when processing the message.
That clears up some things, thanks. What about the www names? Leave those in the localhost line? What about the actual address lines? Do I need those?

I'm thinking about what happens when I'm ssh'ed in and want to send an email which, again, probably doesn't matter to sendmail but other applications might care?

I've read in a couple of places where some people think such a setup should just have localhost on the line and nothing else.
The names that you need in /etc/hosts are the ones that a service might try to use on system startup when DNS is not yet available, basically the name you have set as hostname in rc.conf(5) . Otherwise you can trust that DNS resolves the names for the services that run on your server.

Since you have a static IP address for your server I would do this instead:




...leave everything else untouched...

107.x.x.x www
By "everything else" do you mean as I show it on the localhost line earlier?

I notice that in the raw mail it shows mail to as coming through
I meant leave everything else as it would be on a freshly installed FreeBSD.

That is from the fact that now reverse lookup probably returns the name Another reason not to add too many extra entries in /etc/hosts, only the bare minimum.
I'm thinking that my problem(s) lie with trying to handle mail from two IP addresses with one instance of sendmail. I'm trying to add SPF and DMARC. They work when I send email from the server itself but not when someone else sends me an email. Then I get a "soft fail" though the email goes through.

Related, every email continues to be sent by This is why I think my SPF issue doesn't work, at least in part.
What about the www names? Leave those in the localhost line? What about the actual address lines? Do I need those?
Just FYI:
man 5 nsswitch.conf
Default setting: /etc/hosts overrides DNS. Including hostnames there is useful for local testing of servers that are not yet in DNS. Otherwise bad if there are DNS problems and you do not notice because of entries in /etc/hosts.

The www names are resolved by DNS. The client connects that IP. It sends the actual site it requests in the HTTP header. The reverse proxy and/or the web server evaluates the HTTP header and redirects to the appropriate virtual host. What you have in /etc/hosts is thus irrelevant.

I've read in a couple of places where some people think such a setup should just have localhost on the line and nothing else.
A reason for this: see above.
The only thing in /etc/hosts is this right now:

Code:       localhost

107.x.x.1 www
107.x.x.2 www

Sendmail handles mail for four web sites properly except I can't get the hostnames to match with the mail server. The mail server is just, so However, when I send mail from Yahoo to, the raw email shows it being served by but the mail goes through. SPF doesn't like that, though.

I've tried pointing the MX records at each site individually, and, and tried just with no apparent change.

Now, I know I've been fooled waiting for propagation changes and I have probably lost track of what I've tried so, if something doesn't make sense, feel free to point things out.