home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / doc / HOWTO / mini / Sendmail+UUCP < prev    next >
Text File  |  1997-04-16  |  12KB  |  352 lines

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