I run a small (centOS 7) mail server at home and I would like to attach ports to a domain name instead of opening up for every incoming connection of the server-IP. Currently, when I open up port 25/993/587 in FirewallD, it opens up to everyone. So when I point a domain name to my server IP, all ports will be opened up. I currently use mail.example.com, but what I would like to achieve is:
smtp.mail.example.com -> 25
imaps.mail.example.com -> 993
... And so on. I have no idea if or how this is possible and I know that it is not necessary for the functioning of my mail server, but it's interesting from a sanity perspective and can be useful for other situations when you combine webhosting and mail hosting on the same server since a mail server doesn't need port 80/443 and a web server doesn't need 25/993 and so on.
I am aware of SRV records, but that still leaves all ports open when you use the same IP.