Linux Firewall Open specific ports (iptables)

Source: Internet
Author: User

Iptables is a firewall under Linux and is also the service name. Service iptables Status View firewall stateService iptables start to turn on the firewallservice iptables Stop shutting down the firewallService iptables Restart Restart firewall firewalls Open specific ports:① file/etc/sysconfig/iptables② Add:-A rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 8080-j ACCEPT★ The number 8080 for open 8080 port, can also be changed to other ports ★③ Restart the firewall
================================================================ Save settings for firewall Serivce iptables save View iptables rules and numbers IPTABLES-NL--line-number close all input FORWARD (forwards) output all ports iptables-p input dropiptables-p FORWARD DRO Piptables-p OUTPUT DROP only opens 22 ports iptables-a input-p TCP--dport 22-j acceptiptables-a output-p tcp--sport 22-j AC CEPT parameter explanation: –A parameter is to add a rule –p specify what protocol, we commonly used TCP protocol, of course, there is UDP, for example, 53 port Dns–dport is the target port, when the data from the outside into the server for the destination port –sport data from the server out, Use –J for the data source port is either accept-receive or DROP does not receive prohibit an IP access iptables-a input-p tcp-s 192.168.1.2-j drop–s parameter is the source (that is, 192.168.1.2) after rejecting It's a drop. Delete rule iptables-d Input 2 Delete the rule with input chain number 2

Linux Firewall Open specific ports (iptables)

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.