Changing sending IP in Postfix/CentOS 8

I am following the guide for building a mail server using CentOS 8 and Postfix.

My host at first didn’t have port 25 open so I contacted them and they gave me a mail-enabled IP to use but it’s not my VPS’s primary IP. How can I continue following the guide using an IP that is not the primary VPS IP?

The simply way is to ask your host to remove the previous IP address, so you will have only one IP address.

You can also use set up a firewall rule.

sudo firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING -p tcp --dport 25 -j SNAT --to-source the.second.ip.address

Reload Firewalld for the changes to take effect.

sudo systemctl reload firewalld

This tell the firewall to always use the second IP address when sending emails out.