How to open specified port in linux

王林
Release: 2019-12-25 16:00:06
Original
20537 people have browsed it

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
Copy after login

2. Save:

/etc/rc.d/init.d/iptables save
Copy after login

3. Restart the service:

/etc/init.d/iptables restart
Copy after login
Copy after login

4. Check whether the port is open:

/sbin/iptables -L -n
Copy after login
Copy after login

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
Copy after login

Add the following content and save:

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

2. Restart the service:

/etc/init.d/iptables restart
Copy after login
Copy after login

3. Check whether the port is open

/sbin/iptables -L -n
Copy after login
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!