Linux ports open the specified port in two ways __linux

Source: Internet
Author: User
Tags iptables

Reproduced from: https://www.cnblogs.com/jtestroad/p/8031850.html

Important things to say three times, strongly recommend the use of the second method! second!;

Ways to open ports:

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

Method Two: Directly edit/etc/sysconfig/iptables file
1. Edit/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. See if the port is open:/sbin/iptables-l-N

But I have to use the method one has not been saved, check the Internet found that directly modify the file does not need to iptables save, reboot under the iptables reload configuration. Iptables save is to write the current iptables to the/etc/sysconfig/iptables. I do not save direct restart also can not, so still method two bar

Query port has process daemon using the following command grep corresponding port, such as 80 for port number
Example: Netstat-nalp|grep 80

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.