Linux iptables firewall specifies the port range

Source: Internet
Author: User
Tags iptables

I need a port between 700 and 800 to be able to access TCP

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 dad, will there be a better solution, we look at the following

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 is done, a sentence on it, the following more to say a few iptables firewall some rules.

One, 700:800 means all ports between 700 and 800

Two: 800 means 800 and all of the following ports

Three, 700:700 and above all ports


We can take a look at the example

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.