Summary of basic network port operation commands in CentOS

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.