1 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx P
\bPe
\ber
\br-
\b-C
\bCl
\bli
\bie
\ben
\bnt
\bt/
\b/U
\bUs
\bse
\ber
\br/
\b/e
\bet
\btc
\bc.
\b. A
\bAc
\bcc
\bce
\bes
\bss
\bs C
\bCo
\bon
\bnt
\btr
\bro
\bol
\bl
3 -------------------------------------------------------------------------------
5 P
\bPo
\bos
\bst
\btf
\bfi
\bix
\bx r
\bre
\bes
\bst
\btr
\bri
\bic
\bct
\bti
\bio
\bon
\bn c
\bcl
\bla
\bas
\bss
\bse
\bes
\bs
7 The Postfix SMTP server supports access restrictions such as reject_rbl_client
8 or reject_unknown_client_hostname on the right-hand side of SMTP server access
9 (5) tables. This allows you to implement different junk mail restrictions for
10 different clients or users.
12 Having to specify lists of access restrictions for every recipient becomes
13 tedious quickly. Postfix restriction classes allow you to give easy-to-remember
14 names to groups of UCE restrictions (such as "permissive", "restrictive", and
17 The real reason for the existence of Postfix restriction classes is more
18 mundane: you can't specify a lookup table on the right-hand side of a Postfix
19 access table. This is because Postfix needs to open lookup tables ahead of
20 time, but the reader probably does not care about these low-level details.
25 smtpd_restriction_classes = restrictive, permissive
26 # With Postfix < 2.3 specify reject_unknown_client.
27 restrictive = reject_unknown_sender_domain
28 reject_unknown_client_hostname ...
31 smtpd_recipient_restrictions =
33 reject_unauth_destination
34 check_recipient_access hash:/etc/postfix/recipient_access
36 /etc/postfix/recipient_access:
37 joe@my.domain permissive
38 jane@my.domain restrictive
40 With this in place, you can use "restrictive" or "permissive" on the right-hand
41 side of your per-client, helo, sender, or recipient SMTPD access tables.
43 The remainder of this document gives examples of how Postfix access restriction
44 classes can be used to:
46 * Shield an internal mailing list from outside posters,
47 * Prevent external access by internal senders.
49 These questions come up frequently, and the examples hopefully make clear that
50 Postfix restriction classes aren't really the right solution. They should be
51 used for what they were designed to do, different junk mail restrictions for
52 different clients or users.
54 P
\bPr
\bro
\bot
\bte
\bec
\bct
\bti
\bin
\bng
\bg i
\bin
\bnt
\bte
\ber
\brn
\bna
\bal
\bl e
\bem
\bma
\bai
\bil
\bl d
\bdi
\bis
\bst
\btr
\bri
\bib
\bbu
\but
\bti
\bio
\bon
\bn l
\bli
\bis
\bst
\bts
\bs
56 We want to implement an internal email distribution list. Something like
57 all@our.domain.com, which aliases to all employees. My first thought was to
58 use the aliases map, but that would lead to "all" being accessible from the
59 "outside", and this is not desired... :-)
61 Postfix can implement per-address access controls. What follows is based on the
62 SMTP client IP address, and therefore is subject to IP spoofing.
65 smtpd_recipient_restrictions =
66 check_recipient_access hash:/etc/postfix/access
70 all@my.domain permit_mynetworks,reject
71 all@my.hostname permit_mynetworks,reject
73 Specify d
\bdb
\bbm
\bm instead of h
\bha
\bas
\bsh
\bh if your system uses d
\bdb
\bbm
\bm files instead of d
\bdb
\bb files.
74 To find out what map types Postfix supports, use the command p
\bpo
\bos
\bst
\btc
\bco
\bon
\bnf
\bf -
\b-m
\bm.
76 Now, that would be sufficient when your machine receives all Internet mail
77 directly from the Internet. That's unlikely if your network is a bit larger
78 than an office. For example, your backup MX hosts would "launder" the client IP
79 address of mail from the outside so it would appear to come from a trusted
82 In the general case you need two lookup tables: one table that lists
83 destinations that need to be protected, and one table that lists domains that
84 are allowed to send to the protected destinations.
86 What follows is based on the sender SMTP envelope address, and therefore is
87 subject to SMTP sender spoofing.
90 smtpd_recipient_restrictions =
91 check_recipient_access hash:/etc/postfix/protected_destinations
94 smtpd_restriction_classes = insiders_only
95 insiders_only = check_sender_access hash:/etc/postfix/insiders, reject
97 /etc/postfix/protected_destinations:
98 all@my.domain insiders_only
99 all@my.hostname insiders_only
101 /etc/postfix/insiders:
102 my.domain OK matches my.domain and subdomains
103 another.domain OK matches another.domain and subdomains
105 Getting past this scheme is relatively easy, because all one has to do is to
106 spoof the SMTP sender address.
108 If the internal list is a low-volume one, perhaps it makes more sense to make
111 R
\bRe
\bes
\bst
\btr
\bri
\bic
\bct
\bti
\bin
\bng
\bg w
\bwh
\bha
\bat
\bt u
\bus
\bse
\ber
\brs
\bs c
\bca
\ban
\bn s
\bse
\ben
\bnd
\bd m
\bma
\bai
\bil
\bl t
\bto
\bo o
\bof
\bff
\bf-
\b-s
\bsi
\bit
\bte
\be d
\bde
\bes
\bst
\bti
\bin
\bna
\bat
\bti
\bio
\bon
\bns
\bs
113 How can I configure Postfix in a way that some users can send mail to the
114 internet and other users not. The users with no access should receive a
115 generic bounce message. Please don't discuss whether such access
116 restrictions are necessary, it was not my decision.
118 Postfix has support for per-user restrictions. The restrictions are implemented
119 by the SMTP server. Thus, users that violate the policy have their mail
120 rejected by the SMTP server. Like this:
122 554 <user@remote>: Access denied
124 The implementation uses two lookup tables. One table defines what users are
125 restricted in where they can send mail, and the other table defines what
126 destinations are local. It is left as an exercise for the reader to change this
127 into a scheme where only some users have permission to send mail to off-site
128 destinations, and where most users are restricted.
130 The example assumes DB/DBM files, but this could also be done with LDAP or SQL.
132 /etc/postfix/main.cf:
133 smtpd_recipient_restrictions =
134 check_sender_access hash:/etc/postfix/restricted_senders
137 smtpd_restriction_classes = local_only
139 check_recipient_access hash:/etc/postfix/local_domains, reject
141 /etc/postfix/restricted_senders:
142 foo@domain local_only
143 bar@domain local_only
145 /etc/postfix/local_domains:
146 this.domain OK matches this.domain and subdomains
147 that.domain OK matches that.domain and subdomains
149 Specify d
\bdb
\bbm
\bm instead of h
\bha
\bas
\bsh
\bh if your system uses d
\bdb
\bbm
\bm files instead of d
\bdb
\bb files.
150 To find out what map types Postfix supports, use the command p
\bpo
\bos
\bst
\btc
\bco
\bon
\bnf
\bf -
\b-m
\bm.
152 Note: this scheme does not authenticate the user, and therefore it can be
153 bypassed in several ways:
155 * By sending mail via a less restrictive mail relay host.
157 * By sending mail as someone else who does have permission to send mail to
158 off-site destinations.