How to operate Network Port in Linux system
Linux system how to operate the network port, in response to this problem, this article details the corresponding analysis and solutions, hoping to help more small partners who want to solve this problem to find a simpler and easier way.
close port
The code is as follows:
iptables -A INPUT -p tcp --dport 111 -j DROP
open ports
The code is as follows:
iptables -A INPUT -p tcp --dport 111 -j ACCEPT
Develop discrete ports (including single):
The code is as follows:
iptables -A INPUT -p tcp -m multiport --dport 21,20 -j ACCEPT
Everything else is closed:
The code is as follows:
iptables -A INPUT -p tcp -j REJECT --reject-with tcp-reset
Open Continuous Ports:
The code is as follows:
iptables -A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 8001:8140 -j ACCEPT
You can also modify/etc/sysconfig/iptables directly. How to write it, refer to the open port, or fill in the command above.
Restart iptables
The code is as follows:
service iptables restart
Linux port occupied solution
Sometimes after closing the software, the background process dies, causing the port to be occupied. Take JBoss port 8083 occupied as an example to list the detailed resolution process.
Solution:
1. Find occupied ports
The code is as follows:
netstat -tln
netstat -tln | grep 8083
netstat -tln View port usage, while netstat -tln| grep 8083 is only used to view port 8083
2. Which program does the port belong to? Which process is the port occupied by?
The code is as follows:
lsof -i :8083
3. Kill the process occupying the port
The code is as follows:
kill -9
process ID
About Linux system how to operate the network port problem answer to share here, hope the above content can have some help to everyone, if you still have a lot of doubts not solved, you can pay attention to the industry information channel to learn more related knowledge.