CentOS关闭系统不必要的端口
注:以下所有操作均在CentOS 7.2 x86_64位系统下完成。
1)首先查看当前系统开放的端口号:
# netstat -tlnup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 127.0.0.1: 0.0.0.0:* LISTEN /php-fpm: mast
tcp 0.0.0.0: 0.0.0.0:* LISTEN /systemd
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master
tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
可以看到目前系统监听的端口有四个,分别是:
- 9000端口:php-fpm使用中;
- 111端口:系统使用中;
- 80端口:Nginx使用中;
- 22端口:sshd服务使用中;
我们决定关闭111端口。
2)查看111端口正在被哪个服务在使用中:
# cat /etc/services | grep -w
sunrpc /tcp portmapper rpcbind # RPC 4.0 portmapper TCP
sunrpc /udp portmapper rpcbind # RPC 4.0 portmapper UDP
3)继续查看使用111端口的服务的详细状态信息:
# systemctl list-unit-files --all |grep portmapper
# systemctl list-unit-files --all |grep rpcbind
rpcbind.service enabled
rpcbind.socket enabled
rpcbind.target static
可以看到这两个服务名称分别是rpcbind.service和rpcbind.socket,并且设置了自启动。
4)接下来我们关闭这两个服务:
# systemctl stop rpcbind.service
Warning: Stopping rpcbind.service, but it can still be activated by:
rpcbind.socket
# systemctl stop rpcbind.socket
这个时候可以再查看下系统开放端口信息:
# netstat -tlnup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 127.0.0.1: 0.0.0.0:* LISTEN /php-fpm: mast
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx: master
tcp 0.0.0.0: 0.0.0.0:* LISTEN /sshd
可以看到111端口已经没有被使用。
5)由于前面看到这两个服务都被设置了开机自启动,所以还要将其设置为开机不自启动:
# systemctl disable rpcbind.service
Removed symlink /etc/systemd/system/multi-user.target.wants/rpcbind.service.
# systemctl disable rpcbind.socket
Removed symlink /etc/systemd/system/sockets.target.wants/rpcbind.socket.
这个时候再来查看下服务的详细状态信息:
# systemctl list-unit-files --all |grep rpcbind
rpcbind.service disabled
rpcbind.socket disabled
rpcbind.target static
这两个服务的自启动项已经被设置为禁用。
至此,本次工作完成。
CentOS关闭系统不必要的端口的更多相关文章
- Centos 7防火墙firewalld开放80端口(转)
开启80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent 出现success表明添加成功 命令含义: --zone #作用域 -- ...
- centos查看系统/硬件信息及运维常用命令
[root@yan-001 ~] # uname -a # 查看内核/操作系统/CPU信息的linux系统信息命令 [root@yan-001 ~] # head -n 1 /etc/issue # ...
- centos linux系统日常管理复习 CPU物理数逻辑核数,iftop ,iotop ,sar ,ps,netstat ,一网卡多IP,mii-tool 连接,ethtool速率,一个网卡配置多个IP,mii-tool 连接,ethtool速率 ,crontab备份, 第十八节课
centos linux系统日常管理复习 物理CPU和每颗CPU的逻辑核数,uptime ,w,vmstat,iftop ,iotop ,sar ,ps,netstat ,一个网卡配置多个IP,mii ...
- centos linux 系统日常管理4 scp,rsync,md5sum,sha1sum,strace ,find Rsync 常见错误及解决方法 第十七节课
centos linux 系统日常管理4 scp,rsync,md5sum,sha1sum,strace ,find Rsync 常见错误及解决方法 第十七节课 rsync可以增量同步,scp不行 ...
- centos linux系统日常管理3 服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,curl,ping ,telnet,traceroute ,dig ,nc,nmap,host,nethogs 第十六节课
centos linux系统日常管理3 服务管理ntsysv,chkconfig,系统日志rsyslog,last ,lastb ,exec,xargs,dmesg,screen,nohup,cur ...
- centos Linux系统日常管理2 tcpdump,tshark,selinux,strings命令, iptables ,crontab,TCP,UDP,ICMP,FTP网络知识 第十五节课
centos Linux系统日常管理2 tcpdump,tshark,selinux,strings命令, iptables ,crontab,TCP,UDP,ICMP,FTP网络知识 第十五节课 ...
- CentOS 7如何开放其它的端口,比如8080
CentOS 7如何开放其它的端口,比如8080 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop ...
- centos 关闭不使用的服务
CentOS关闭服务的方法: chkconfig –level 2345 服务名称 off 服務名稱 建議 說明 acpid 停用 Advanced Configuration and Power I ...
- 查看系统网络连接打开端口、系统进程、DOS打开文件
问题描述: DOS查看系统网络连接打开端口.打开的服务 问题解决: (1)DOS查看系统网络连接打开端口 注: 使用 netstat 命令,可以查看系统打开的端口 (2)查看和关闭系统打开进程 ...
随机推荐
- QQ音乐爬虫
#今日目标 **QQ音乐爬虫** 今天要爬取的是QQ音乐任意歌手的所有音乐歌词,因为笔者是周杰伦的忠实粉丝,所以专门写了个爬虫来爬取他的音乐的歌词,因为他的音乐在咪咕音乐可以听,所以便没有去爬取. 好 ...
- 续AspectJ篇
这篇将介绍AspectJ的第二种开发方法:基于注解的声明式-AspectJ. 与基于代理类的AOP实现相比,基于XML的声明式AspectJ要便捷的多,但是它也存在一些缺点,那就是在Spring文件中 ...
- JavaEE--JSP详解
一.JSP JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计,它是由Sun Microsystems公司倡导.许多公司参与一起建立的一种 ...
- 查看 php 编译参数
/app/php/bin/php -i|grep configure 范例 4: [root@VM-001 ~]# /app/php/bin/php -i|grep configure Configu ...
- init_module - 初始化一条可加载模块的记录.
总览 #include <linux/module.h> int init_module(const char *name, struct module *image); 描述 init_ ...
- Docker 镜像 容器 仓库
Docker 包括三个基本概念镜像(Image)容器(Container)仓库(Repository) Docker 镜像 Docker 镜像是一个特殊的文件系统,除了提供容器运行时所需的程序.库.资 ...
- nacos集群搭建
nacos介绍 Nacos 支持基于 DNS 和基于 RPC 的服务发现(可以作为springcloud的注册中心).动态配置服务(可以做配置中心).动态 DNS 服务. 1.从官网下载nacos压缩 ...
- 机器学习聚类算法之DBSCAN
一.概念 DBSCAN是一种基于密度的聚类算法,DBSCAN需要两个参数,一个是以P为中心的邻域半径:另一个是以P为中心的邻域内的最低门限点的数量,即密度. 优点: 1.不需要提前设定分类簇数量,分类 ...
- CentOS7 配置阿里云yum源,非常之简单
1.进入yum的文件夹 命令:cd /etc/yum.repos.d/ 2.下载wget 命令:yum -y install wget 命令:yum install bash-completion ...
- nll_loss
''' torch.nn torch.nn.functional (F)CrossEntropyLoss cross_entropy LogSoftmax log_softmax NLLLoss nl ...