MikeL's FreeBSD howto - add new domain
This is basically a checklist of how to add a new domain. The intent
is not to cover everything in detail, merely to point you to each of
the tasks that must be performed.
(last update 02-Mar-2005)
Note: Although you can dork with sendmail.cf as I've described below,
you're probably better off using m4. Poke around the web,
http://www.sendmail.org/ is a
good place to start for info. Start with the sample /etc/freebsd.mc.
(You'll find other sample .mc files in your /usr/share/sendmail/cf and
First time only
First time and all additional times:
- Edit /etc/mail/sendmail.cf:
- Fw-o /etc/mail/local-host-names -- comment in if not already
- Kvirtuser hash /etc/mail/virtusertable -- comment in if not already
- search for "virtual users" -- down near end of file comment in rules
- Create empty /etc/mail/local-host-names -- format below
- Create empty /etc/mail/virtusertable -- format below
- Create generic /etc/namedb/generic.hosts -- format below
By the way, I recommend making a set of scripts to do this,
eg. 'sendmail-restart', 'named-restart', and most importantly
'apache-restart'. See my apache hints page (link above) for reasons.
- /etc/mail/local-host-names -- add new domain name all by itself on one line (# in leftmost column works as comment)
- /etc/mail/virtusertable -- add any new mail forwarding rules:
- "user1@domaina user2@domainb" -- redirects mail for given user to another place
- "@domainc user3@domaind" -- redirects ALL mail for domainc to other user
- /etc/namedb/named.conf -- Add "
primary newdomainname generic.hosts"
adduser. I'm using group "customer" for customers,
and "staff" for more empowered.
- I'm adding the user to the "customer" group in
/etc/group, I don't remember if this is necessary or even
appropriate. (Note 10-Nov-2001: no need to do this.)
/usr/local/etc/apache/http.conf. Jump down to
the end, and copy a virtualhost block of an existing domain. (If you
have multiple virtualhost blocks for a given domain, you're doing it
wrong -- see my apache hints page.)
- mkdir /web/domain. In that dir make 'data', 'html' and
'logs' dirs. In the html dir, you may wish to add a hard link to
central cgi-bin (Note 10-Nov-2001: don't do this).
- Make their new home/web dir. Be sure to set the permissions --
copy an existing domain. Basically 755 for dirs, 644 for files.
Optionally, make them the owner and set the group (I use "customer").
You may not want to do this as if they delete either of these dirs,
apache will refuse to re/start. Obviously however, they do need
add/write access in at least the html dir.
- Add their new directory to the backup script list.
- Add them to main vintners.net index list.
/etc/mail/local-host-names over to your email
secondary(s). wrong! don't do this! (12-Jul-04)
- Add new domain to
/etc/mail/mailertable on mail
secondary. wrong! don't do this! (20-Sep-2006)
- FYI: Don't add new domain to
/etc/mail/local-host-names on mail secondary. (20-Sep-2006)
- Add new domain to
/etc/mail/virtuser-domains on mail
(If you forget this, dnsreport will show everything fine except
that abuse and postmaster will not be accepted as they
should.) wrong! don't do this! use MAIL_HUB decl instead (20-Sep-2006)
- Add new domain name to
/etc/namedb/named.conf on your
- email friends to add secondarying for them on their boxes.
- Add their webmaster email addr to your customer list.
- Go to http://www.DNSsy.com/ to check your work.
- Do a
tail /var/log/messages and check for any errors.
- Update mail deamon
- newaliases -- if you've changed anything in the aliases file (probably not necessary here)
- makemap -v hash /etc/mail/virtusertable</etc/mail/virtusertable -- update virtuser db
- kill -HUP `head -1 /var/run/sendmail.pid` -- restart sendmail deamon
- kill -HUP `cat /var/run/named.pid`
- apachectl restart
- In older FreeBSD flavors (pre-3.0?), the "local-host-names" file was
named "sendmail.cw" by default.
- In older FreeBSD flavors (pre-3.0?), the "named.conf" file was
- In older FreeBSD flavors (pre-3.0?), the "http.conf" file was
(IP addresses and non-Vintners.Net domains are faked)
; generic.hosts - created 13-Jul-2003
; use this for all "generic" customer domains.
@ IN SOA ns2.vintners.net. hostmaster.vintners.net. (
200312190 ; Serial yyyymmddx
21600 ; Refresh 6hrs
900 ; Retry 15min
3600000 ; Expire
43200 ) ; Minimum
IN NS ns2.vintners.net.
IN NS ns1.example.com.
IN MX 10 mail.vintners.net.
IN MX 20 ns1.example.com.
IN A 0.0.0.4
ftp IN A 0.0.0.4
www IN A 0.0.0.4
smtp IN A 0.0.0.4
pop3 IN A 0.0.0.4
mail IN A 0.0.0.4
imap IN A 0.0.0.4
brix IN A 0.0.0.4
oechsle IN A 0.0.0.5
ns2 IN A 0.0.0.4
ns1 IN A 0.0.0.5
Copyright © 1995-2018