Link to home
Start Free TrialLog in
Avatar of netmach
netmach

asked on

How to Masquerade the Domain

This server is sending email successfully aS user@myserver.mydomain.com. However, I'm trying to masqurade user@myserver.mydomain.com as user@mydomain.com using the MASQUERADE_AS parameter. I have not been successful.

This is the /etc/mail/sendmail.mc as it stands at the moment:

==================================================
divert(-1)
dnl This is the sendmail macro config file. If you make changes to this file,
dnl you need the sendmail-cf rpm installed and then have to generate a
dnl new /etc/sendmail.cf by running the following command:
dnl
dnl        m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
dnl
include(`/usr/share/sendmail-cf/m4/cf.m4')
VERSIONID(`linux setup for Red Hat Linux')dnl
OSTYPE(`linux')
dnl Uncomment and edit the following line if your mail needs to be sent out
dnl through an external mail server:
dnl define(`SMART_HOST',`smtp.your.provider')
define(`confDEF_USER_ID',``8:12'')dnl
undefine(`UUCP_RELAY')dnl
undefine(`BITNET_RELAY')dnl
define(`confAUTO_REBUILD')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
define(`ALIAS_FILE', `/etc/aliases')dnl
dnl define(`STATUS_FILE', `/etc/mail/statistics')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
dnl TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl define(`confTO_QUEUEWARN', `4h')dnl
dnl define(`confTO_QUEUERETURN', `5d')dnl
dnl define(`confQUEUE_LA', `12')dnl
dnl define(`confREFUSE_LA', `18')dnl
dnl FEATURE(delay_checks)dnl
FEATURE(`no_default_msa',`dnl')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
FEATURE(use_cw_file)dnl
FEATURE(use_ct_file)dnl
dnl The '-t' option will retry delivery if e.g. the user runs over his quota.
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
FEATURE(`access_db',`hash -o /etc/mail/access.db')dnl
FEATURE(`blacklist_recipients')dnl
EXPOSED_USER(`root')dnl
dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')
dnl NOTE: binding both IPv4 and IPv6 daemon to the same port requires
dnl       a kernel patch
dnl DAEMON_OPTIONS(`port=smtp,Addr=::1, Name=MTA-v6, Family=inet6')
dnl We strongly recommend to comment this one out if you want to protect
dnl yourself from spam. However, the laptop and users on computers that do
dnl not have 24x7 DNS do need this.
FEATURE(`accept_unresolvable_domains')dnl
dnl FEATURE(`relay_based_on_MX')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
Cwlocalhost.localdomain
FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')
FEATURE(`masquerade_envelope')
GENERICS_DOMAIN(`myserver')
GENERICS_DOMAIN(`myserver.mydomain.com')
GENERICS_DOMAIN(`localhost')
GENERICS_DOMAIN(`localhost.localdomain')
MASQUERADE_AS(`mydomain.com')
MASQUERADE_DOMAIN(`myserver.mydomain.com')
================================================

I have generated the sendmail.cf file using m4 /etc/mail/sendmail.mc > /etc/sendmail.cf.
I have hashed the /etc/mail/genericstable table successfully, repeatedly.
Testing with sendmail -bt, 0 seems to indicate everything is ok.
The only log I know to review for possible errors is /var/log/maillog.
As I said, it's working, but it's really not a valid domain.
Not being a Sendmail expert, I have reconfigured it many times now, and barring a few typos, nothing I configure seems to make the slightest difference in the result. Any help would be greatly appreciated!

Thanks!
Avatar of samri
samri
Flag of Malaysia image

hi netmach,

please check the location of your sendmail.cf, is it in /etc or /etc/mail

Did you restart sendmail after generating a new cf file.

And how about adding dnl at the end of these lines
FEATURE(`genericstable',`hash -  /etc/mail/genericstable.db')dnl
FEATURE(`masquerade_envelope')dnl
GENERICS_DOMAIN(`myserver')dnl
GENERICS_DOMAIN(`myserver.mydomain.com')dnl
GENERICS_DOMAIN(`localhost')dnl
GENERICS_DOMAIN(`localhost.localdomain')dnl
MASQUERADE_AS(`mydomain.com')dnl
MASQUERADE_DOMAIN(`mydomain.com')dnl
ASKER CERTIFIED SOLUTION
Avatar of samri
samri
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of netmach
netmach

ASKER

OHMYGOSH, IT WORKED!!!
I would swear I tried that combination in sendmail.mc 5 times! But Good for you! Thanks!

Now I need to masquerade the user to "resu"...
Avatar of netmach

ASKER

Samri had me double-check my configuration and it paid off. Well done!
no. prob.

There are scenario (personal exp) where sendmail doesn't fully restart.  And sometime, i had to do "pkill -9 sendmail", very rude - but should ensure all are killed.

Anyway, glad to hear that it worked -- auto"magically".

cheers