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)查看和关闭系统打开进程 ...
随机推荐
- Python和mysql的连接
python与mysql的连接: 说明:前提是已近安装了mysql以及可视化工具(本人装的是Navicat) 1.在cmd下下载Python的第三方数据库包:pip install pymysql: ...
- issubclass 和 isinstance和断点调试
issubclass 和 isinstance和断点调试 一.issubclass 判断第一个类是不是第二个类的子类,返回True或Flase class Foo: pass class Bar(Fo ...
- 1.javascript知识点总结
1.写javaScript的三种方式: 2.写javaScript的注意事项: ①严格区分字母的大小写: ②空格和换行.多余的空格会被忽略,可以将一行代码分成多行写: ③分号作为一个语句的结束: ④单 ...
- Smoke Testing
[Smoke Testing 释义] Smoke Testing 的概念最早源于制造业,用于测试管道.测试时,用鼓风机往管道里灌烟,看管壁外面是否有烟冒出来,以便检验管道是否有缝隙.这一测试显然比较初 ...
- Shiro单Realm加密
首先,我们要明确认证的流程: 1. 获取当前的 Subject. 调用 SecurityUtils.getSubject(); 2. 测试当前的用户是否已经被认证. 即是否已经登录. 调用 Subje ...
- 383-基于kintex UltraScale XCKU040的双路QSFP+光纤PCIe 卡
一.板卡概述 本板卡系我司自主研发,基于Xilinx UltraScale Kintex系列FPGA XCKU040-FFVA1156-2-I架构,支持PCIE Gen3 x8模式的高速信号处理板卡 ...
- nginx反向代理+负载均衡+url重写+ssl认证
Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄 ...
- 22_4mybatis——动态SQL
1.创建maven工程并导入坐标 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE confi ...
- HDU 6215 Brute Force Sorting 模拟双端链表
一层一层删 链表模拟 最开始写的是一个一个删的 WA #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) mem ...
- 牛顿迭代法——C语言
include <stdio.h> include <math.h> int main() { flaot solution(float a,flaot b,float c,f ...