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