# sendmail masquerading question



## drobison (Apr 4, 2013)

Hiya,

Trying to set up an internal host to masquerade as our parent companies domain.

I think I'm close, but... not quite there.

Here's my info. 

/etc/mail/sendmail.mc:


```
MASQUERADE_AS(NEWDOMAIN.com)
MASQUERADE_DOMAIN(OLDDOMAIN.com)
MASQUERADE_DOMAIN(NEWDOMAIN.com)
LOCAL_DOMAIN(backup.OLDDOMAIN.com)
FEATURE(allmasquerade)
FEATURE(masquerade_entire_domain)
FEATURE(genericstable, `hash -o /etc/mail/genericstable')
```

/etc/mail/genericstable:


```
root            CA_OAK_ITSupport@NEWDOMAIN.com  <mailto:CA_OAK_ITSupport@NEWDOMAIN.com>
bacula          backup@NEWDOMAIN.com            <mailto:backup@NEWDOMAIN.com>
daver           daver@NEWDOMAIN.com             <mailto:daver@NEWDOMAIN.com>
```

Further I do:


```
cd /etc/mail
make all
service sendmail restart
```

But emails I send are not having the ctladdr rewritten from daver@backup.OLDDOMAIN.com to daver@backup.NEWDOMAIN.com

What am I missing?

Dave


----------



## wblock@ (Apr 4, 2013)

I don't know if m4's weird quoting is required, but would use it anyway.

```
MASQUERADE_AS(`example.com')
MASQUERADE_DOMAIN(`example.com')
FEATURE(`masquerade_entire_domain')
FEATURE(`masquerade_envelope')
```


----------



## drobison (Apr 4, 2013)

Put them in, and also added my FQDN to the genericstable file, no go.


----------



## wblock@ (Apr 4, 2013)

Did you add the FEATURE(`masquerade_envelope')?


----------



## drobison (Apr 4, 2013)

Yep, just put it in, with the weird M4 "`" and "'" format. Still no go.


----------



## kpa (Apr 4, 2013)

Don't you need to do

`# make install`

after editing the .mc file?


----------



## wblock@ (Apr 4, 2013)

You're right, all just builds everything.  `# make all install restart` is what I use.


----------



## drobison (Apr 4, 2013)

Thought you guys might have had it; tried this and still the ctladdr is incorrect.


----------



## kpa (Apr 9, 2013)

Have you tried any other sources of information? Sendmail on FreeBSD is like Sendmail on any other system so any advice you find should apply to FreeBSD as well.


----------



## wblock@ (Apr 9, 2013)

Looking back at this, there are not a lot of specifics.

Is the masquerading machine sending direct, or is it relaying through a smarthost?

Is the mail generated on the masquerading machine, or on hosts inside the network?  If it is inside hosts, remember that they have to relay/smarthost through the masquerade machine.


----------



## drobison (Apr 12, 2013)

*ugh*

OK folks, I haven't played with sendmail.cf since the late 90's. Now I see that I am not actually supposed to modify /etc/mail/sendmail.cf, and that when I did my [cmd=]make all install restart[/cmd] my DS line was overwritten as blank. So, my smarthost wasn't being used.

:OOOx(

So, I manually put it back in and things are working at least for my backup mail address. I will twiddle the others later. And I'll try to figure out where I should actually make the change to the DS line to make this change permanent.

Thanks for the pointer. At first I thought "Yes I'm using a smarthost and OF COURSE I modified the DS line!" but then experience has taught me to start from square one and I found that my smarthost line had been removed.


----------



## wblock@ (Apr 12, 2013)

Rule 1: don't edit the .cf, edit _hostname_.mc.  The .cf is built from that.


----------



## ondra_knezour (Apr 12, 2013)

drobison said:
			
		

> And I'll try to figure out where I should actually make the change to the DS line to make this change permanent.



Put 
	
	



```
define(`SMART_HOST',`smtp.example.com')
```
 in your .mc file.


----------



## drobison (Apr 13, 2013)

Thanks folks, it's working. For posterity, the hostname.mc file must be the FQDN of the host, not just the hostname.

Thanks again!


----------



## wblock@ (Apr 13, 2013)

If there is no _hostname_.mc present, `# make` will create it.  See /etc/mail/Makefile.


----------

