Summary of basic network port operation commands in CentOS
This article mainly introduces the basic network port operation commands of Linux system, including solutions for port conflict. For more information, see
Close the port
Iptables-a input-p tcp-dport 111-j DROP
Open Port
Iptables-a input-p tcp-dport 111-j ACCEPT
Developing discontinuous ports (including a single port ):
Iptables-a input-p tcp-m multiport-dport 21,20-j ACCEPT
Close all others:
Iptables-a input-p tcp-j REJECT-reject-with tcp-reset
Open continuous Port:
Iptables-A RH-Firewall-1-INPUT-m state-state NEW-m udp-p udp-dport 8001: 8140-j ACCEPT
You can also directly modify/etc/sysconfig/iptables. For details about how to write, refer to opened ports or follow the preceding command to enter
Restart iptables
Service iptables restart
Solve the Problem of port occupation in Linux
Sometimes, when the software is disabled, the background process will die, causing the port to be occupied. The following uses JBoss port 8083 as an example to describe the detailed solution process.
Solution:
1. Find the occupied port
Netstat-tln
Netstat-tln | grep 8083
Netstat-tln is used to view port usage, while netstat-tln | grep 8083 is used to view port 8083 only.
2. Check which program the port belongs? Which process occupies the port?
Lsof-I: 8083
3. Kill the process that occupies the port
Kill-9
Process id