Q: How to open a port range in iptables firewall?
Opening a port range in iptables firewall for example open TCP ports40 to port 50. Run the below commands from terminal as root user.
Open a Port Range in iptables
[root@server~]# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 40:50 -j ACCEPT
[root@server ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@server ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
Test the Opened ports
Check the opened ports by connecting to appropriate ports of the server. And also check all the changes are written to the iptables configuration file located in etc/sysconfig/iptables
[root@server ~]# cat /etc/sysconfig/iptables
Sample output displayed below
Check Related Posts:
0 comments:
Post a Comment