How to close the linux port?

青灯夜游
Release: 2020-05-01 18:22:16
Original
8580 people have browsed it

How to close the Linux port? The following article will introduce to you how to check whether the port is open, close/open the port under Linux. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to close the linux port?

1. Check which ports are open

netstat -anp
Copy after login

(Note: Adding parameter '-n' will convert the application to port display, that is, digital format address, such as: nfs->2049, ftp->21, so you can open two terminals and correspond to the port number corresponding to the program one by one)

2. Close the port number

iptables -A OUTPUT -p tcp --dport 端口号-j DROP
Copy after login

3. Open the port number:

iptables -A INPUT -ptcp --dport  端口号-j ACCEPT
Copy after login

4. Save the settings

service iptables save
Copy after login

5. The following is how to use the Linux open port command.

nc -lp 23 &(打开23端口,即telnet)
netstat -an | grep 23 (查看是否打开23端口)
Copy after login

6. Linux open port command Each open port needs a corresponding listening program

Recommendation: "linux tutorial"

The above is the detailed content of How to close the linux port?. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template