How to Open / Allow range of ports on Linux server
How to Open / Allow port range in IPtables firewall
How to Open port range in IPtables Firewall
You can do the below steps to open a range of ports on CentOS, Redhat, Fedora server using iptables firewall.
Example : Do the below steps to open the FTP passive port range 30000 – 50000 in IPtables firewall.
1. Log into your Linux server via SSH as ‘root’ user
2. Run the command “iptables -A INPUT -p tcp –dport 30000:20000 -j ACCEPT” to open the port range
3. You must save the IPtables rules by running the command “service iptables save”
4. Run the command “service iptables restart” to restart the IPtables firewall.
5. Type the command “iptables -nL” to see the rule that you have added
In the above example, you must replace the port number “30000:20000” with the port range you wish to open.
How to Open Multiple ports in IPtables firewall
Example : Follow the below steps if you want to open multiple ports : 25, 465, 110, 143, 993 and 995 on Linux server.
1. Log into your Linux server via SSH as root user
2. Run the command “iptables -A INPUT -p tcp -m multiport –dports 25,465,110,143,993,995 -j ACCEPT” to allow multiple ports
3. You must save the IPtables rules by running the command “service iptables save”
4. Restart the IPtables firewall after saving the rules : service iptables restart”