Home >Operation and Maintenance >Linux Operation and Maintenance >How to open specified port in linux

How to open specified port in linux

王林
王林Original
2019-12-25 16:00:0620731browse

How to open specified port in linux

Method 1: Command line method

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 the service:

/etc/init.d/iptables restart

4. Check whether the port is open:

/sbin/iptables -L -n

Free video tutorial recommendation: linux video tutorial

Method 2: Direct editing/etc/sysconfig/iptablesFile

1. Edit the /etc/sysconfig/iptables file

vi /etc/sysconfig/iptables

Add the following content and save:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

2. Restart the service:

/etc/init.d/iptables restart

3. Check whether the port is open

/sbin/iptables -L -n

To check whether there is a process guarding the port, use the following command, grep the corresponding port, such as 80 is the port number

netstat -nalp|grep 80

related Recommended article tutorials: linux tutorial

The above is the detailed content of How to open specified port in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn