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)查看和关闭系统打开进程 ...
随机推荐
- zookeeper 实战操作
一:监听服务端zookeeper节点数据改变 import java.io.IOException; import java.util.concurrent.CountDownLatch; impor ...
- 9.jQuery之简洁版滑动下拉菜单
知识点:hover的使用,已经slideToggle的切换效果 <style> * { margin: 0; padding: 0; } li { list-style-type: non ...
- python全栈开发教程目录
python入门到进阶 Python基础2——数据类型的操作 Python基础——函数入门 Python基础——函数进阶 Python基础——函数的装饰器 Python基础——函数的装饰器 Pytho ...
- 判断浏览器类型JS
// 判断浏览器类型 getExplorer() { var explorer = window.navigator.userAgent, compare = function (s) { retur ...
- linux centos中安装flash player
本机为centos 7.0 64 1.用火狐浏览器随便打开一个视频网站,找到一个视频点进去,网站会提示未安装flash player.点击进去到adobe官网.2.下载flash player插件,可 ...
- excle 文件的导入和导出
//excle 文件导出 public function excel(){ try{ include(BASE_PATH."Excel/PHPExcel.php"); // ech ...
- Dubble 入门
Dubbo 01 架构模型 传统架构 All in One 测试麻烦,微小修改 全都得重新测 单体架构也称之为单体系统或者是单体应用.就是一种把系统中所有的功能.模块耦合在一个应用中的架构方式.其优点 ...
- php字符串大小写转换
strtoupper().strtolower().ucfirst().ucfirst().ucwords().mb_strtoupper().mb_strtolower()和mb_convert_c ...
- 对所有的webview添加userAgent
在appdelegate中- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDicti ...
- event loop 与 vue
结论 对于event loop 可以抽象成一段简单的代码表示 for (macroTask of macroTaskQueue) { // 1. Handle current MACRO-TASK h ...