Linux Firewall with iptables and firewalld
Master Linux firewalls using iptables and firewalld.
In this article will be covering details regarding iptables and firewalld which helps in Linux firewall management. We will also be looking at how to enable specific ports (1521 for Oracle) inside iptables.
Read more about Linux iptables vs Linux firewall
Managing Linux Firewall
The Linux firewalld command will let you check Linux firewall status. It will show you the current status Active in case firewall is running
systemctl status firewalld
To disable firewall immediately and stop it starting from the next reboot
service firewalld stop
systemctl disable firewalld
To enable firewall instantly and start is automatically from next reboot
service firewalld start
systemctl enable firewalld
Enable Ports in Linux
On some servers, port 1521 will not be enabled by default because of security reasons. You can enable this specific port inside linux using below commands.
If you are working on Oracle Linux 5 or 6 version, use Linux iptables command to enable specific ports as root user
iptables -I INPUT -p tcp --dport 1521 -j ACCEPT
If you would like to open any specific port in Linux, just replace the port number (1521) with new port number. To open multiple port ranges in Linux, use below command
iptables -A INPUT -p tcp -m multiport --dports 7101:7200,4889:4898,1159,4899:4908,7788:7809,3872,1830:1849 -j ACCEPT
In some Linux versions, below command works fine
firewall-cmd --permanent --add-port=1521/tcp
After opening port 1521, ensure your listener.ora and tnsnames.ora configurations are correct