3 ways to turn off Linux system ports

Source: Internet
Author: User
Tags auth

Here's a summary of three ways to turn off Linux system ports

1. Close the port by killing the process

Each port has a daemon, kill the daemon.

Each port is a process occupied,

The first step, use the following command

NETSTAT-ANP |grep Port

Find the process that occupies this port.

The second step, use the following command

Kill PID

Just kill it.


2. Turn on/off the port by turning off the service

Because each port has a corresponding service, it is possible to close the port as long as the corresponding service is turned off.

Linux boot auto-start services are generally stored in two places:

services under the/etc/init.d/folder:
The services under this folder can be started or closed by running the appropriate script.
Example: Start the SendMail service:./sendmail Start (TCP 25 port is turned on)
Close SendMail service:./sendmail Stop (TCP 25 port off)

View the current status of the SendMail service:./sendmail? Status (see if the service is running)

services under the/etc/xinetd.d/folder:
The service under this folder needs to be changed by changing the service configuration file and restarting xinetd.

For example: To start the Auth service, open the/etc/xinetd.d/auth profile, change the "Disable=no", and save the exit.

Run/etc/rc.d/init.d/xinetd restart

To stop the Auth service, open the/etc/xinetd.d/auth configuration file, change the "Disable=yes", and save the exit.

Run/etc/rc.d/init.d/xinetd restart


3. Restricting ports through firewalls

The methods described below are used under Linux commands and are easy to use.
Opening ports are:

Iptables-a input-p $port-j ACCEPT

Switch the Accept to drop, i.e.:

Iptables-a input-p $port-j DROP
Where $port is the port number


This article from "Write a blog Money" blog, please be sure to keep this source http://dadonggg.blog.51cto.com/12672150/1948626

3 ways to turn off Linux system ports

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.