++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++ sendmail-dialup-masquerading-FAQ.txt ++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ On Fri, 17 Oct 1997, SI-POER wrote: > Hi, > I have read your HOWTO document about sendmail > (Linux Mail-Queue). I tested it and it worked just fine. > > I am using Slackware linux 2.0.30 on my PC; sipoer.makro.co.id. > > But I still have a little bit of a problem with alising. > We have a domain on the Internet named makro.co.id. > We use dialup connection. > Our ISP have set up their server so that every mail that come to > our domain (makro.co.id) will be sent to 1 mailbox (that are > named mmbox). I use fetchmail+procmail to collect and deliver > mail from the Internet to the local users. I do that also. Maybe you are interested in my .fetchmail and .procmailrc scripts for this? Please say so if you are! > The problem is in the configuration of the email clients. > All email-clients connect to sipoer.makro.co.id, so I have > configured the From-addresses of the clients to > user@sipoer.makro.co.id. > This works OK if we just exchange mail in the local domain. > When we send to the Internet, the receipent could not reply to > our mail, because we were usingh sipoer.makro.co.id and not > makro.co.id. If I set a From-address of: user@makro.co.id, > this will work well for communiction on the Internet, but all > local mail will be sent to the ISP server. > > I am very confused and I'll be very happy if you can help me. I'm not suprised. It is confusing at first. Actually, unless you perform a number of steps that I have included in this mail, it would probably continue to be confusing indefinitely. So I'll help you out, read on... It is actually some parts of the patch mentioned below that makes it all possible. The patch is a patch to sendmail's configuration-tree, not to sendmail itself. > Regard's > > Purwanto Hi SI-POER, Your questions are relevant and intelligent, and show that you know what you are talking about. I think I do understand your situation, especially since it very closely resembles my own. Since your case is such a good example, do you mind if I use your mail in a FAQ on my www site? [He didn't. /Leif] Let me draw a table comparing our two setups, and then you can download some stuff from my www-site that includes my setup and by simply doing some editing and set up a couple of files (more than a couple, actually) you should be able to duplicate my setup so it suits your situation: Your setup: My setup: sipoer.makro.co.id elijah.swip.net makro.co.id lege.com user@sipoer.makro.co.id user@elijah.swip.net user@makro.co.id user@lege.com OK. If you do the above substitutions you should be able to use my examples. (My examples solve some other problems as well, so for this simple problem it may seem as gross overkill. But it is available, and it works. What can I say... :-) It is very likely that there exists a far simpler solution to your problem. I might even have ideas, but nothing as tested as the stuff that follows, that is proven to work and work well on multiple OS and hardware platforms -- though only the Linux specific parts are available on my www site.) Now visit URL http://www.lege.com/proto.html And download Sendmail cf-8.8.7/m4/proto-patch-8.8.7 or whatever version sendmail you have got -- though I recommend installing and using latest sendmail, which as far as I know is 8.8.7. (Run /usr/sbin/sendmail -d | head -1 ^C to find out which version of sendmail you've presently got. Even if you already have 8.8.7 you probably should still get hold of the latest sendmail source -- not available from my site - but try ftp.sendmail.org -- in order to get hold of the cf config source tree, that is found under src/cf in the sendmail source tree.) [Actually, proto-patch-8.8.8 is now available, and even later versions may be available by the time you read this FAQ. Go look for yourself, I will not keep this FAQ updated with the latest version numbers. / Leif Erlingsson [Nov 17 1997]] Also download xaliases-2.0.tar.gz Unpack xaliases-2.0.tar.gz: mkdir -p /usr/local/src cd /usr/local/src tar -zxvf /tmp/xaliases-2.0.tar.gz Note that the file /usr/local/src/xaliases-2.0/INSTALL is completely OK, and valid, but suggests to unpack xalparse-1.4 in a different location than what the following advice advocates. (It doesn't really matter which way you do it as long as you select ONE of the methods! :-) ) You may safely ignore the file /usr/local/src/xaliases-2.0/INSTALL if you follow the below advice... Extract xalparse-1.4.tar.gz from xaliases-2.0.tar.gz: mv /usr/local/src/xaliases-2.0/xalparse-1.4.tar.gz \ /tmp/xalparse-1.4.tar.gz Unpack xalparse-1.4.tar.gz: mkdir -p /usr/src cd /usr/src tar -zxvf /tmp/xalparse-1.4.tar.gz Make and install xalparse-1.4: cd /usr/src/xalparse-1.4/ida/aux make 2>&1 | tee LEGE-make-log.txt make install 2>&1 | tee LEGE-make-install-log.txt This will have installed the ``xalparse'' program. It's man-page describe the format of the /etc/xaliases file. There is also a sample /etc/xaliases file, as well as other sample files, under the /usr/local/src/xaliases-2.0/etc directory. Install xaliases-2.0: cp -p /usr/local/src/xaliases-2.0/xaliases \ /usr/local/bin cd /usr/bin ln -s /usr/local/bin/xaliases xaliases This installs /usr/local/bin/xaliases and makes a soft link to /usr/bin/xaliases. Copy sample files to etc directory: cp -p /usr/local/src/xaliases-2.0/etc/* /etc This will install the files /etc/mailertable, virtuals, xaliases. Study them. You will not need /etc/mailertable for your needs, so you will not need to edit it. Everything is commented out in the sample file. /etc/virtuals is interesting indeed for you, as is /etc/xaliases. Make SURE that you MERGE your present /etc/aliases file with /etc/xaliases BEFORE you run /usr/local/bin/xaliases for the first time - BECAUSE /usr/local/bin/xaliases will GENERATE /etc/aliases FROM /etc/xaliases!!! Remember the table comparing our two setups?.... Your setup: My setup: sipoer.makro.co.id elijah.swip.net makro.co.id lege.com user@sipoer.makro.co.id user@elijah.swip.net user@makro.co.id user@lege.com Now edit /etc/xaliases and /etc/virtuals so my stuff is changed into your stuff: sed -e 's/elijah.swip.net/sipoer.makro.co.id/g' \ < /etc/virtuals \ | sed -e 's/lege.com/makro.co.id/g' \ > /etc/virtuals. \ && mv /etc/virtuals. /etc/virtuals sed -e 's/elijah.swip.net/sipoer.makro.co.id/g' \ < /etc/xaliases \ | sed -e 's/lege.com/makro.co.id/g' \ > /etc/xaliases. \ && mv /etc/xaliases. /etc/xaliases Then hand-edit both /etc/xaliases and /etc/virtuals so usernames etc work for your site. OK. Now you have the tools. And the config files. Except for the most important one; sendmail.cf ... You will also need a /etc/sendmail.cw, that can be empty if you define Cw in the /etc/sendmail.cf, or else, if not, should contain the line sipoer.makro.co.id You do specifically *NOT* need to have makro.co.id in this file!!! That's what /etc/virtuals and /etc/xaliases are for!!! (It is gross overkill using virtual email domains for this, but it does work! And the fun thing is you can use exactly the same config for virtual domain hosting as an Internet Service Provider!!!) So, You need to install a new sendmail.cf. That is what the "Sendmail cf-8.8.7/m4/proto-patch-8.8.7" is for! URL http://www.lege.com/proto.html explains the procedure, but I'll repeat it here (I assume you removed the .bin ending already when downloading, as the www page suggests): Assuming you fetched the 8.8.7 version, here's an example: cd /usr/src/sendmail-8.8.7/cf cp -p ostype/linux.m4 ostype/linux.m4.yourname gzip -dc < /tmp/sendmail-8.8.7-cf-cpio-idcmu.gz | \ cpio -idcmu These files are unpacked... 76068 Aug 16 16:02 README 3013 Aug 16 16:02 README-patch-8.8.7 74739 Jul 6 23:58 README.orig 10570 Aug 16 22:24 cf/elijah.smtp.mc 130 Dec 13 1996 cf/make_elijah 120 Jun 27 10:55 cf/make_ruth 38475 Aug 16 22:34 cf/obj/elijah.smtp.cf 14386 Aug 16 22:35 cf/obj/ruth.smtp.cf 4391 Aug 16 22:30 cf/ruth.smtp.mc 13962 Mar 18 21:00 domain/elijah.m4 4099 Jul 30 01:14 domain/ruth.m4 12176 Aug 16 16:10 m4/proto-patch-8.8.7 38942 Aug 16 16:12 m4/proto.m4 31529 Aug 1 02:26 m4/proto.m4.orig 3484 Aug 16 21:33 ostype/linux.m4 1953 Apr 7 23:39 ostype/linux.m4.orig 2006 Jul 28 01:16 ostype/linux.patch Now I suggest you generate your own files using my files as examples... use handy "sed" to get a head start!!!.... cd /usr/src/sendmail-8.8.7/cf sed -e 's/elijah.swip.net/sipoer.makro.co.id/g' \ < cf/elijah.smtp.mc \ | sed -e 's/lege.com/makro.co.id/g' \ | sed -e 's/swip.net/makro.co.id/g' \ | sed -e 's/swipnet.se/makro.co.id/g' \ | sed -e 's/elijah/sipoer/g' \ > cf/sipoer.smtp.mc sed -e 's/elijah.swip.net/sipoer.makro.co.id/g' \ < domain/elijah.m4 \ | sed -e 's/lege.com/makro.co.id/g' \ | sed -e 's/swip.net/makro.co.id/g' \ | sed -e 's/swipnet.se/makro.co.id/g' \ | sed -e 's/elijah/sipoer/g' \ > domain/sipoer.m4 sed -e 's/elijah.swip.net/sipoer.makro.co.id/g' \ < cf/make_elijah \ | sed -e 's/lege.com/makro.co.id/g' \ | sed -e 's/swip.net/makro.co.id/g' \ | sed -e 's/swipnet.se/makro.co.id/g' \ | sed -e 's/elijah/sipoer/g' \ > cf/make_sipoer chmod 755 cf/make_sipoer cd /usr/src/sendmail-8.8.7/cf/cf Now study cf/sipoer.smtp.mc, domain/sipoer.m4, ostype/linux.m4 and possibly m4/proto-patch-8.8.7. Edit as needed. Since you already are using procmail, ostype/linux.m4 should be just fine for you, it's configured for procmail already. You mustn't forget to edit domain/sipoer.m4 ... define(`PSEUDODOMAINS', `BITNET CSNET UUCP DECNET FAX')dnl dnl # The site that will handle lusers -- that is, apparently dnl # local names that aren't local accounts or aliases: define(`LUSER_RELAY', `relay:rsv.se')dnl This is at my OLD job MASQUERADE_AS(`mailbox.makro.co.id')dnl The above is -- after editing into your domains -- my ISP mailbox computer. It doesn't make much difference what it says here for my setup, because all my users reverse-aliases into the lege.com domain anyway. But if they didn't, they would have been presented as user@mailbox.makro.co.id, or rather, user@mailbox.swipnet.se, as it was before the earlier sed-edits. FEATURE(`masquerade_envelope')dnl The above is vital for being able to reverse-alias into any domain of the users choise. This is how I can ``Masquerade As'' one domain, ``mailbox.makro.co.id'', but still being able to present myself as ``user@makro.co.id'', or in my own case, ``leif@lege.com''. (My case is further complicated by the fact that ``LEGE.COM'' is really not assigned to my home computer but to another computer on the net that I have access to.) These You will need to edit: define(`SMART_HOST', `smtp8:mailbox.makro.co.id')dnl #UGLY#HACK##UGLY#HACK# dnl define(`SMART_HOST', `smtp:mailbox.makro.co.id')dnl This is your ISP mail-host, where you'll send mail you cannot figure out locally what to do with. If your ISP don't want you to do this, you must comment out these lines, put a ``dnl'' in front of both (one is already commented out). You may want to remove the smtp8 version and replace with the plain smtp version unless you know for a fact that your ISP handles 8bit MIME. Finally, a note about this ruth computer. Ruth is a different computer that NFS-mounts just about everything from my other computer. The ruth config is extremely stripped down, and just for sending of mail. No mail is ever delivered on ruth, it is delivered on the other computer and read using NFS-mounted file- systems by ruth. When satisfied, generate /usr/src/sendmail-8.8.7/cf/obj/sipoer.smtp.cf like so: cd /usr/src/sendmail-8.8.7/cf/cf && ./make_sipoer Compare /usr/src/sendmail-8.8.7/cf/obj/sipoer.smtp.cf with your present /etc/sendmail.cf, and when you are satisfied with the changes and that the essentials are still there, make a backup of /etc/sendmail.cf then copy obj/sipoer.smtp.cf over /etc/sendmail.cf: cp -p /etc/sendmail.cf /etc/sendmail.cf.sav cp -p /usr/src/sendmail-8.8.7/cf/obj/sipoer.smtp.cf \ /etc/sendmail.cf \ && chmod 644 /etc/sendmail.cf Kill sendmail, then run xaliases (/usr/local/bin/xaliases) and then re-start sendmail again: kill `ps -aux | grep sendmail | grep -v grep \ | awk '{print $2}' ` xaliases /usr/sbin/sendmail -bd -os Make some tests using sendmail's address test mode; /usr/sbin/sendmail -bt /parse user@sipoer.makro.co.id /parse user@makro.co.id ^D Make sure you are DISCONNECTED from the Internet, then... Make some more authentic tests using: /usr/sbin/sendmail -v -oi user@sipoer.makro.co.id From: testuser@makro.co.id To: user@sipoer.makro.co.id Subject: /usr/sbin/sendmail -v -oi user@sipoer.makro.co.id /usr/sbin/sendmail -v -oi user@sipoer.makro.co.id ^D And: /usr/sbin/sendmail -v -oi user@makro.co.id From: testuser@makro.co.id To: user@makro.co.id Subject: /usr/sbin/sendmail -v -oi user@makro.co.id /usr/sbin/sendmail -v -oi user@makro.co.id ^D Check with "mailq" that these have been delivered already. Then send a testmail to me (still DISCONNECTED from the Internet): /usr/sbin/sendmail -v -oi leif@lege.com From: testuser@makro.co.id To: leif@lege.com Subject: /usr/sbin/sendmail -v -oi leif@lege.com /usr/sbin/sendmail -v -oi leif@lege.com ^D IMPORTANT: When you invoke /usr/sbin/sendmail on the commandline as the above examples show, you don't get a prompt but are feeding your key-input from the keyboard directly into STDIN of sendmail. When I have indicated multiple lines, input multiple lines exactly as I typed them above. When you come to the line with the "^D" on it, that is an indication that you should press CTRL and D keys together to generate the "EOF" character. When sendmail receives this, input on STDIN is terminated, sendmail processes the input and the prompt is returned to you after some verbose output has been printed on the screen. __________________________________________________________________ Leif Erlingsson Tel +46 8 604-0995 DATA LEGE Fax +46 8 605-2551 Glavagatan 33 URL http://www.lege.com 123 71 Farsta, Sweden Email mailto:leif@lege.com __________________________________________________________________ I remember the past. I am not doomed to buy Microsoft products. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++ END OF sendmail-dialup-masquerading-FAQ.txt ++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++