In Linux we commonly used firewall is iptables, but many friends do not know how to quickly iptables firewall to specify the port range, below I give you introduce.
I need a port between 700 and 800 to have TCP access
The code is as follows |
Copy Code |
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 700-j ACCEPT -A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 701-j ACCEPT -A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 702-j ACCEPT ... -A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 800-j ACCEPT |
This is very pit father Ah, will there be a better solution, below we look
The code is as follows |
Copy Code |
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 700:800-j ACCEPT |
This will be done, a sentence on it, the following a few more words iptables firewall some rules.
One, 700:800 represents all ports between 700 and 800
Ii.: 800 means all ports 800 and below
Three, 700: Indicates 700 and above all ports
We can take a look at the examples
The code is as follows |
Copy Code |
One,-a rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 7979:9898-j ACCEPT |
Access 9898 Normal
iptables firewall specified port range in Linux