Score:-1

Postfix / How to allow sending only to one IP

bi flag

I have a postfix server that is on a public IPV4 address. I want to allow postfix to send emails ONLY to this IPV4 address (the same). Tried many things but no success...

Any idea ? Thanks in advance.

++EDIT01 : there are several domains on this server, and I want ONLY ONE domain to send emails to itself.

HBruijn avatar
in flag
Does this answer your question? [how can i disable outbound mail in postfix?](https://serverfault.com/questions/271260/how-can-i-disable-outbound-mail-in-postfix)
HBruijn avatar
in flag
The alternative, block egress port 25 in your firewall rules and/or security groups or https://serverfault.com/a/106447/37681
us flag
if @HBruijn's comments do not answer your question please explain why you want to use the public IP address
bv4nuf avatar
bi flag
@jasen there are several domains on this server, and I want ONLY ONE domain to send emails to itself
us flag
so use localhost, you don't need the public address involved at all.
Score:0
do flag

You can use the Postfix transport map to configure the delivery behavior for the specific domain.

Create a new file called /etc/postfix/transport

example.com smtp:[1.2.3.4]

Replace example.com with the domain that you want to restrict, and 1.2.3.4 with the IPv4 address of your Postfix server.

Create a new file called /etc/postfix/restrictions

/^example\.com$/     OK
/^example\..*/       REJECT
/.*@example\.com$/   OK
/.*@example\..*/     REJECT

Replace example.com with the domain you want to restrict. This file will help you restrict the domain to send emails only to itself.

Add the following lines to your /etc/postfix/main.cf file:

transport_maps = hash:/etc/postfix/transport
smtpd_sender_restrictions = check_sender_access pcre:/etc/postfix/restrictions

Run the following commands to compile the transport map and reload Postfix:

sudo postmap /etc/postfix/transport
sudo systemctl reload postfix

Now, the specified domain should only be able to send emails to the same IPv4 address, and other domains should continue to operate as before.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.