Linux Open firewall port and view, turn on related port number

Source: Internet
Author: User

firewall on and off (effective immediately, fail after reboot):

$ sudo service iptables start #开启 $ sudo service iptables stop #关闭

firewall on and off (takes effect after reboot):

$ sudo chkconfig iptables on$ sudo chkconfig iptables off

To open the relevant port :

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

-A input-p tcp-m state--state new-m TCP--dport 22-j ACCEPT

After modifying the iptables, restart the firewall to take effect:

$ sudo service iptables restart

-A: Add a rule to the rule chain input

INPUT: Rule Chain

-P: Represents the Packet usage protocol followed by TCP, which indicates the use of the TCP protocol

-M: Indicates an explicit match extension followed by state, indicating that the state module is explicitly loaded and used. New represents the state value of the status. The next-m TCP--dport 22 means explicitly loading the TCP module and specifying a matching condition of 22 for the target port.

-j ACCEPT: Specifies the target (action), which means to continue processing the grouping.

to view UDP-type ports :

$ NETSTAT-NUPL #UDP类型的端口

to view a port of type TCP :

$ NETSTAT-NTPL #TCP类型的端口

Use the lsof command to see if a port is open :

$ lsof-i:80

Take Port 80 as an example, if a display description is already open, it will not open if no instructions are displayed.

Linux Open firewall port and view, turn on related port number

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.