home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 August / PCWorld_1999-08_cd.bin / doc / HOWTO / mini / Sendmail+UUCP < prev    next >
Text File  |  1998-10-17  |  15KB  |  384 lines

  1.  
  2.                              Sendmail + UUCP HOWTO
  3.                                        
  4.    
  5.     Author: Jamal Hadi Salim (jamal@glcom.com or hadi@cyberus.ca)
  6.     
  7.    
  8.    
  9.   History:
  10.   
  11.      Initial edition July/96: works only with non-bind edition of
  12.    sendmail
  13.    
  14.      Oct 01 /96: works with the redhat supplied binary
  15.    
  16.      Oct 07 /96: added/modified a tip on how to compile non-bind sendmail
  17.    
  18.      Oct 25 /96: added/modified a tip on how to keep sendmail
  19.    getHostbyAddr() happy via a dummy /etc/hosts entry
  20.    
  21.      Mar 15 /97: I am amazed at the response/feedback i am receiving so i
  22.    decided to refine this further. Fixed some small errors; added diagram
  23.    + references.
  24.    
  25.      Oct 25/97: Htmlise+ add blurb on DNS capable machines
  26.    ______________________________________________________________________
  27.    
  28.    After finally settling down and properly reading TFM (the Bat Book, to
  29.    be precise) i have solved the Caramilk secret! The steps below have
  30.    been tested with the binary supplied by RedHat. Perhaps i should send
  31.    this tip to the maintainer of the Sendmail FAQ too since there is
  32.    absolutely no mention of UUCP interworking with sendmail there.
  33.    
  34. What this Document tries to show you
  35.  
  36.    How to setup a single machine, reffered to as me.com in the example,
  37.    with no direct access to the internet to route mail for you via
  38.    sendmail and UUCP to a 'smarter host' eg your ISP.
  39.    Optionally you can configure this machine to feed other machines i.e
  40.    you are their 'smart' host or gateway.
  41.    
  42. What this Document does not tell you
  43.  
  44.    I have been receiving incredible number of questions regarding topics
  45.    which are beyond the focus of this HOWTO. The purpose of this document
  46.    is not to describe them so please try not send me any questions on the
  47.    following:
  48.    
  49.    
  50.   a) How to setup UUCP.
  51.   
  52.    Refer to many fine references on this, including:
  53.    
  54.      UUCP HOWTO (Vince Skahan, )
  55.    
  56.      Using and managing UUCP (Ed Ravin et al -- publisher O'reilly) which
  57.    i think is the best authority on UUCP
  58.    
  59.      Linux Network Administrator Guide (Olaf Kirch)
  60.    
  61.    
  62.   b) how to setup DNS.
  63.   
  64.    Refer to the many fine references on this, including:
  65.    
  66.      Caching named mini howto (Nicolai Langfeldt)
  67.    
  68.      The bat book (Sendmail;Costalles, Allman, Rickert;publisher
  69.    O'reilly)
  70.    
  71.      DNS and BIND (Publisher O'reilly)
  72.    
  73.      TCP/IP Network Administration (Hunt, Craig;Publisher O'reilly)
  74.    
  75.      Linux Network Administrator Guide (Olaf Kirch)
  76.    
  77.      sendmail Theory and Practice (Avolio and Vixie; publisher Digital
  78.    press)
  79.    
  80.    
  81.   c) how to setup databases (other than the mailertable) to work with sendmail.
  82.   
  83.    Refer to the many fine references on this, including:
  84.    
  85.      The bat book (Sendmail;Costalles, Allman, Rickert -- publisher
  86.    O'reilly)
  87.    
  88.      TCP/IP administration (Publisher O'reilly)
  89.    
  90.      Sendmail Theory and Practice (Avolio and Vixie; publisher Digital
  91.    press)
  92.    
  93.      Docs bundled with sendmail d) how to write or modify rulesets or
  94.    mailers.
  95.    
  96.      All the above references  in c)
  97.    
  98.    You can also find help on the following newsgroups:
  99.    [1]comp.mail.sendmail
  100.    [2]comp.mail.uucp
  101.    [3]comp.os.linux.networking
  102.    IRC channels
  103.    #linux, #unix
  104.    ______________________________________________________________________
  105.    
  106. THE SETUP
  107.  
  108.    This is for a system, hypothecally named me.com, whose mail is sent
  109.    out only via UUCP. mysmarthost is the ISPs hostname as set up in the
  110.    uucp sys file and me.com is the hostname we use or are known by in the
  111.    MX records on the internet.
  112.    mysmarthost hooks to the internet. We really dont care how it does it,
  113.    we just know it knows how to get us there.
  114.    me.com, whose setup we describe in the example, feeds sites down.com
  115.    and system1.org and their subnodes. me.com connects to down.com via
  116.    TCP/IP and connects to system1.org via raw UUCP using a phone line.
  117.    The setup description is shown below:
  118.    
  119.         ------------------------
  120.         |                       |
  121.         |     Internet          |
  122.         |                       |
  123.         -----------------------
  124.                     |
  125.                     | PPP/dedicated line running TCP-IP
  126.                     |
  127.                 -------------
  128.                 |            |
  129.                 |mysmarthost | Authoritative name server for
  130.                 |            | *.me.com, *.down.com, *.system1.org
  131.                 |            |
  132.                 --------------
  133.                     |
  134.                     | UUCP via a phone line receive for
  135.                     | system1.org, *.system1.org,*.down.com, down.com
  136.                     | as well as me.com and *.me.com
  137.                  ------------
  138.                 | * *****  *  |
  139.    ------------ | * me.com *  | ------
  140.                 | *        *  |      |
  141.    |            | * *****  *  |      |
  142.    |             ------------        |
  143.    |UUCP via phone line              | uucp via TCP/IP
  144.    |                                 |
  145.  -----------                  -----------
  146. |           |                |           |
  147. |system1.org|                | down.com  |-------
  148. |           |                |           |      |
  149.  ----------                  ------------       |
  150.      |                                          |
  151.      |                                          |
  152.      |                                          | LAN: smtp to nodes
  153.      | UUCP phone line
  154.      |                                          |
  155. -----------                             -------------
  156. |         |                             |           |
  157. |system1's|                             | down's    |
  158. |subnodes |                             | LAN       |
  159. |         |                             ------------
  160. ----------
  161.  
  162.  pre-requisites
  163.  
  164.    1) If you are already running DNS or have a pointer to a DNS server
  165.    (in your /etc/resolv.conf) and are on a live connection to the net
  166.    then skip this part. You are safe. You dont have to do any 'smart'
  167.    thing skip to  2)
  168.    If you are on a machine using uucp for mail then you dont really need
  169.    to compile bind/resolv into sendmail;
  170.    
  171.   How to survive name canonicalization on a stand-alone machine with no DNS
  172.   
  173.    PART I
  174.     If you get a pre-compiled sendmail with BIND in it you can still live
  175.    with it (As is the case with Redhat supplied sendmail).
  176.    
  177.    a) Refer to my solution for this based on the m4 file described (my
  178.    favorite). Try to use this option unless you really insist on b) or c)
  179.    below OR
  180.    
  181.    b)If you talk to me i could supply you with a non-BIND compiled
  182.    version (8.8.5). Perhaps RedHat should consider supplying two sendmail
  183.    binaries (like slakware) One with BIND and the other with no BIND. OR
  184.    
  185.    c) The quickest solution to get sendmail with no bind is to edit
  186.    src/conf.h lines below to read as i have shown:
  187.    
  188.    # ifndef NAMED_BIND conf.h:# define NAMED_BIND 0 /* use Berkeley
  189.    Internet Domain Server */
  190.    
  191.    PART II:
  192.    Sendmail would however normally insist on doing name look ups to
  193.    resolve the host part using gethostbyaddr() for each email it sends
  194.    (even if you tell it not to canonify names).
  195.    
  196.    a) use an RFC1597 IP address (10.0.0.0-10.255.255.255,
  197.    172.16.0.0-172.31.255.255, 192.168.0.0-192.168.255.255)
  198.    Edit /etc/hosts and add the following as a sample for the host myhost
  199.    10.0.0.1 myhost.me.com myhost or
  200.    b) If you use NIS (and NIS is compiled into sendmail as seems to be
  201.    the case in Redhat. ) make sure the /etc/nsswitch.conf file contains:
  202.    hosts: files dns and in /etc/hosts and add the following as a sample
  203.    for the host myhost [again using RFC1597 IP addressing scheme]
  204.    10.0.0.1 myhost.me.com myhost
  205.    
  206.    NOTE: ---- In both a) and b) above it is critical that you list the
  207.    long (fully qualified) in the /etc/hosts file used. i.e the line
  208.    should read 10.0.0.1 myhost.me.com myhost and NOT 10.0.0.1 myhost you
  209.    will also need to define the sendmail $w macro to hold myhost.me.com
  210.    add the Following line to your /etc/sendmail.cf after it is generated
  211.    Djmyhost.me.com (or you can use MASQUAREADE_AS(myhost.me.com) in the
  212.    .mc below)
  213.    
  214.    NOTE!!!!! myhost as a domain name is given as an example; you dont
  215.    have to use it as is. Pick your own hostname if you dont have one
  216.    already.
  217.    ______________________________________________________________________
  218.    
  219.    2) Ensure that you have makemap and it is capable of supporting hash
  220.    and or the more common dbm format  or even btree format (The Redhat
  221.    version does not support dbm). Makemap is normaly distributed with
  222.    sendmail.
  223.    
  224.    
  225.   SETUP (the mc file)
  226.   
  227.    I) create your .mc file using your favorite editor; i'll call this
  228.    file my.mc
  229.    
  230.    a) No DNS -- standalone
  231.    ______________________________________________________________________
  232.    
  233.    include(`../m4/cf.m4')
  234.    VERSIONID(`me.com's setup with uucp created by xxxx --no dns ')
  235.    dnl OSTYPE(linux)
  236.    FEATURE(nodns)dnl
  237.    FEATURE(nocanonify)dnl
  238.    FEATURE(always_add_domain)dnl
  239.    FEATURE(mailertable, hash /etc/mailertable)dnl
  240.    MAILER(local)dnl
  241.    MAILER(smtp)dnl
  242.    MAILER(uucp)
  243.    define(`SMART_HOST', uucp-dom:mysmarthost)
  244.    ______________________________________________________________________
  245.    
  246.    Let's dissect this:
  247.    
  248.      include(`../m4/cf.m4') requests for the m4 macro found in
  249.    ../m4/cf.m4 to be include to resolve some things
  250.    
  251.      VERSIONID(`me.com's setup with uucp created by xxxx')dnl  This is
  252.    used to distinguish the different versions of .cf file you might end
  253.    up creating.
  254.    
  255.      OSTYPE(linux) This is used to define/redefine linux specific stuff.
  256.    It is safe to have it here.
  257.    
  258.      FEATURE(nodns)dnl This says we dont have a DNS server (so in effect
  259.    we are using uucp only for mail. Sendmail must be compiled not to use
  260.    bind) This is now obsolete. I will let it stay here just in case you
  261.    use an older version of sendmail.
  262.    
  263.      FEATURE(nocanonify)dnl This says Don't pass addresses to $[ ... $]
  264.    for canonification. Normally if you have BIND compiled in sendmail
  265.    would try and expand the alias/IP address to a canonical name using
  266.    DNS. You dont wanna do this if all you have are feeds which connect to
  267.    you via UUCP i.e you are a stand alone.
  268.    
  269.      FEATURE(always_add_domain)dnl This adds the local domain host name
  270.    even on locally delivered mail Not necessary i just like it; This
  271.    might not be a safe feature since spammers, with proper setup
  272.    conditions, can abuse you.
  273.    me.com is not connected to the net via tcp/ip so it is safe
  274.    
  275.      FEATURE(mailertable, hash /etc/mailertable)dnl the file
  276.    /etc/mailertable is going to be a hash database where we will store
  277.    routing information of certain sites. If you dont have anyone who you
  278.    feed uucp to then you dont need this. More on this later. If you
  279.    wanted to use the dbm format you would have FEATURE(mailertable, dbm
  280.    /etc/mailertable)dnl  If you wanted to use the btree format you would
  281.    have FEATURE(mailertable, btree /etc/mailertable)dnl
  282.    
  283.      MAILER(local)dnl MAILER(smtp)dnl MAILER(uucp) These are the mailers
  284.    we use.
  285.    
  286.      define(`SMART_HOST', uucp-dom:mysmarthost) Our smart host is our ISP
  287.    who is defined in the uucp sys file as system mysmarthost. Any
  288.    messages that we cant handle (i.e ones for domains or mailers we dont
  289.    understand) will be passed on to our smarthost/ISP to figure out. note
  290.    we use  uucp-dom as the uucp mailer. This particular mailer uses smtp
  291.    rewriting rules.
  292.    
  293.    
  294.    b) DNS on
  295.    ______________________________________________________________________
  296.    
  297.    include(`../m4/cf.m4')
  298.    VERSIONID(`me.com's setup with uucp created by xxxx --dns enabled')dnl
  299.    OSTYPE(linux)
  300.    FEATURE(always_add_domain)dnl
  301.    FEATURE(mailertable, hash /etc/mailertable)dnl
  302.    MAILER(local)dnl
  303.    MAILER(smtp)dnl
  304.    MAILER(uucp)
  305.    define(`SMART_HOST', uucp-dom:mysmarthost)
  306.    ______________________________________________________________________
  307.    
  308.    
  309.    
  310.   II) create your sendmail.cf file
  311.   
  312.    a) backup your old /etc/sendmail.cf file
  313.    b) overwrite the sendmail.cf with the new one: m4 my.mc >
  314.    /etc/sendmail.cf
  315.    c) verify that the sendmail.cf file was correctly created based on
  316.    your specifications.
  317.    Some of the gotchas that i came across were: - missing uucp-dom mailer
  318.    This was because i didnt have the smtp mailer entry. Actually, i
  319.    understand it is important to have it defined before the uucp
  320.    
  321.    
  322.   III) create your /etc/mailertable
  323.   
  324.    if you dont have uucp sites feeding off you skip this step
  325.    
  326.    a) create/edit the file /etc/mailertable
  327.    
  328.    sample /etc/mailertable
  329.    ______________________________________________________________________
  330.    
  331.    system1.org uucp-dom:system1
  332.    .system1.org uucp-dom:system1
  333.    down.com uucp-dom:down
  334.    up.down.com  error: Host is unknown at me.com
  335.    .down.com uucp-dom:down
  336.    .me.com error: Host unknown at me.com
  337.    ______________________________________________________________________
  338.    
  339.    This says anything that is addressed to system1.org or to
  340.    *.system1.org that we receive will be sent using the uucp-dom mailer
  341.    and be delivered to system1 (defined in the the uucp sys file) in
  342.    other words we are doing the mail routing for *.system1.org ; similar
  343.    for down.com and its subnodes except for the additional filtering; we
  344.    bounce back any mail for down's subnode up.down.com using sendmail's
  345.    built-in error mailer with the message "Host is unknown at me.com";
  346.    This is because we have been asked to do this by the admin at
  347.    down.com. To bounce unknown subdomains to us we use the last line in
  348.    the mailertable (which is what all unknown nodes default to).
  349.    b) create the database with makemap
  350.    
  351.    if you use hash:
  352.    makemap hash /etc/mailertable < /etc/mailertable
  353.    if you use dbm:
  354.    makemap dbm /etc/mailertable </etc/mailertable
  355.    if you use btree:
  356.    makemap btree /etc/mailertable </etc/mailertable
  357.    
  358.    do this every time you change the file.
  359.    
  360.   IV) restart sendmail
  361.   
  362.   V) test sendmail
  363.   
  364.    i) sendmail -bv user@destination
  365.    ii) using sendmail -bt and enter various addresses using 3,0
  366.    ruleset to see where they end up and the various rulesets and cf walks
  367.    taken.
  368.    
  369.    You are set!
  370.    ______________________________________________________________________
  371.    
  372.   TODO
  373.   
  374.    1) Add info on setting up system down.com (so as to show how to
  375.    take care of those smtp nodes)
  376.    2) Add info on how to setup news to be delivered via UUCP
  377.    (preferably INN). This might require changing the title of the doc.
  378.  
  379. References
  380.  
  381.    1. news:comp.mail.sendmail
  382.    2. news:comp.mail.uucp
  383.    3. news:comp.os.linux.networking
  384.