Two ways to open a Linux port to a specified port

Source: Internet
Author: User
Tags iptables

Important thing to say three times, it is strongly recommended to use the second Method! Second Method!;

Ways to open ports:

Method One: Command line mode
1. Open port command:/sbin/iptables-i input-p TCP--dport 8080-j ACCEPT
2. Save:/etc/rc.d/init.d/iptables Save
3. Restart Service:/etc/init.d/iptables restart
4. Check if the port is open:/sbin/iptables-l-N

Method Two: Directly edit the/etc/sysconfig/iptables file
1. Edit the/etc/sysconfig/iptables file: vi/etc/sysconfig/iptables
Add content and Save:-a rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 8080-j ACCEPT
2. Restart Service:/etc/init.d/iptables restart
3. Check if the port is open:/sbin/iptables-l-N

But I use method one has been saved, check the online discovery directly modify the file does not need iptables save, restart under Iptables reload under configuration. Iptables save is writing the current iptables to/etc/sysconfig/iptables. I do not save direct restart also not, so the method of two bar

Query port whether there is a process daemon with the following command grep corresponding port, such as 80 for port number
Example: Netstat-nalp|grep 80

Two ways to open a Linux port to a specified port

Related Article

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.