Linux Firewalls and open ports

Source: Internet
Author: User

I. Open/Close firewall command under Linux

A: Permanent, no recovery after reboot

Open: Chkconfig iptables on

OFF: Chkconfig iptables off

B: Immediate effect, recovery after reboot

Open: Service iptables start

Close: Service iptables stop


When you open a firewall, you can use the following two methods for opening ports:

1: Using commands
1), you can see which ports are opened first NETSTAT-ANP
2), turn off the port number:
Iptables-a input-p TCP--drop port number-j drop
Iptables-a output-p TCP--dport port number-j DROP
3), start the slogan:
Iptables-a input-p TCP--dport port number-j ACCEPT

2: Modify the configuration file
Modify the/etc/sysconfig/iptables file to add the following:

-A input-p tcp-m state--state new-m TCP--dport 9040-j ACCEPT open 9040
-A input-p tcp-m state--state new-m TCP--dport 9041-j ACCEPT open 9041

You can save the configuration Iptables service save after a successful modification

Note: The Linux open port command for each open port requires a corresponding listener to


Two. CentOS Linux firewall configuration and shutdown

Execute the "Setup" command to start the text mode configuration Utility, select "Firewall Configuration" in "Select a tool", and then select the "Run Tool" button, the firewall configuration interface will appear, "Security level

"Set to" Disabled "and select" OK ".

or with a command:
#/sbin/iptables-i input-p tcp–dport 9040-j ACCEPT
#/sbin/iptables-i input-p tcp–dport 9041-j ACCEPT
#/etc/rc.d/init.d/iptables Save
When you restart your computer, the firewall defaults to 9040 and 9041 ports

This article is from the "Tianjin Emirates" blog, please be sure to keep this source http://284397316.blog.51cto.com/10456921/1675905

Linux Firewalls and open ports

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.