Configure FirewallD for Mail Server in Centos 7 |
A mail server (or email server) is a computer system that sends and receives email. In many cases, web servers and mail servers are combined in a single machine. However, large ISPs and public email services (such as Gmail and Hotmail) may use dedicated hardware for sending and receiving email. In order for a computer system to function as a mail server, it must include mail server software. This software allows the system administrator to create and manage email accounts for any domains hosted on the server
Configure FirewallD for Mail Server
Check if firewalld is installed:
1 2 |
# which firewalld /usr/bin/which: no firewalld in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin |
If not installed, install firewalld:
1 |
# yum install firewalld |
Ensure that firewalld is running:
1 |
# systemctl start firewalld |
List allowed services:
1 2 |
# firewall-cmd --list-service dhcpv6-client ssh |
Check active zone:
1 |
sudo firewall-cmd --get-active-zones |
Add required services: HTTPS, SMTP, IMAP, POP3, DAV, DHCP(May be required in a testing environment).
1 2 |
# firewall-cmd --zone=public --add-service=smtp --add-service=smtps --add-service=imap --add-service=imaps --add-service=pop3 --add-service=pop3s --add-service=https --add-service=dhcp --permanent # firewall-cmd --zone=public --add-port=587/tcp --add-port=8443/tcp --permanent |
Reload firewalld
1 |
# firewall-cmd --reload |
List allowed services and ports. Check for previously added additions firewalld list rules
1 2 3 |
# firewall-cmd --list-all | grep 'services\|ports' | head -n 2 services: dhcpv6-client https imap imaps pop3 pop3s smtp smtps ssh ports: 8443/tcp 587/tcp |