I have a VS running Ubuntu 20.04 with working web server and email server. I connect a CentOS box to it via VPN from home. The CentOS also has a web server and Postfix email server. The web and email servers work on the CentOS box as long as (a) ports 80 and 25 are forwarded from the VS machine, and (b) CentOS is connected to VS machine with VPN. The conundrum is that both web servers (on VS and CentOS) are accessible from public Internet when port 80 is forwarded from VS, but email receiving works only on CentOS. Postfix on the VS rejects incoming mail with Relay access denied. If I remove forwarding port 25 Postfix on VS does receive mail, but CentOS will not. Same situation if I change master.cf on VS from smtp to smtps (not using the forwarded port 25). How can I set up the VS Postfix so it accepts incoming mail while port 25 is forwarded - just as Apache can serve web pages from both machines while port 80 is fowarded from the VS machine? Note: port forwarding and VPN access to the VS machine is necessary otherwise CentOS on home Internet access is restricted by ISP with blocking incoming ports 80 and 25.

1 Answer 1


Added relay_domains = $myhostname $hostname_of_CentOS to the main.cf of the VS machine Postfix configuration, and removed port forwarding. This way both email servers can send and receive messages. $hostname_of_CentOS stands for what it is: the hostname of the CentOS home machine while connected via VPN to the VS machine. It took me asking the question to finally find the solution to this conundrum.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.