OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: A couple of newbie (but hopefully not numptie) questions

From: Mark Goodge (markgood-stuff.co.uk)
Date: Wed Mar 26 2008 - 14:41:50 CDT


At 17:45 26/03/2008, Sandy Drobic wrote:

>Mark Goodge wrote:
>>For those familiar with Exim, what I'm looking for is the Postfix
>>equivalent of this configuration:
>> redirect_example:
>> driver = redirect
>> domains = example.com
>> data = ${quote:$local_part}example.co.uk
>> no_more
>>Does that make sense? If that's possible with Postfix, what should
>>I be looking for to configure it?
>
>As usual, there are several ways to do this:
>
>- you can use the action REDIRECT in a check:
>
>/etc/postfix/main.cf:
>smtpd_recipient_restrictions =
> permit_mynetworks,
> reject_unauth_destination,
> reject_unlisted_recipient
> check_recipient_access pcre:/etc/postfix/recipient_redirect
>
>/etc/postfix/recipient_redirect:
>/(.+)example\.com$/ redirect $1example.co.uk
>
>- as an alternative you could also use smtp_generic_maps. It is
>applied by the smtp client, so you can use wildcard address rewrite
>without destroying recipient validation.
>
>/etc/postfix/main.cf:
>smtp_generic_maps = pcre:/etc/postfix/generic.pcre
>
>/etc/postfix/generic.pcre:
>(.+)example\.com$/ $1example.co.uk

That's excellent, both of those appear to do precisely what I want, thanks.

>>2. How can I configure Postfix to discard mail from the null sender
>>to a specific recipient? That is, I want <> to be able to send mail
>>to every valid user on my system except johnexample.com, while
>>johnexample.com can receive mail from any valid external sender except <>.
>
>Do not discard mail, REJECT mail you do not wish to receive.

Normally I would reject, but the null sender is a special case as
rejecting it is against the RFCs and doing so can get your server
blacklisted by others which have a more strictly pedantic approach.
Even discarding mail from the null sender is usually a bad idea; it's
only something that should be done under extreme circumstances and,
if such circumstances exist, they're usually sufficient to justify
the use of DISCARD rather than REJECT.

> If you need to check more than one condition you have to use a
> restriction class. It's a bit more complex:
>
>/etc/postfix/main.cf:
>smtpd_recipient_restrictions =
> permit_mynetworks,
> reject_unauth_destination,
> reject_unlisted_recipient
> check_recipient_access hash:/etc/postfix/recipient_reject_nullsender
>smtpd_restriction_classes =
> reject_nullsender
>reject_nullsender =
> check_sender_access hash:/etc/postfix/sender_reject_nullsender
>
>/etc/postfix/recipient_reject_nullsender:
>johnexample.com reject_nullsender
>
>/etc/postfix/sender_reject_nullsender
><> 554 recipient does not accept the nullsender as sender address
>
>Check if smtpd_null_access_lookup_key is indeed the empty address.

Again, thanks, that looks to be the solution I'm seeking. I don't
mind it being a bit complex, so long as it works :-)

Mark