标题:[实践OK]如何关闭centos6x/7x中的sunrpc 111端口,linux如何关闭无用端口/Linux禁用111端口。和关闭rpc.statd服务。 出处:向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除 时间:Mon, 01 Jun 2020 17:34:34 +0000 作者:jackxiang 地址:http://jackxiang.com/post/10576/ 内容: 一)关闭sunrpc 111端口的步骤: ss -lnt State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:111 *:* lsof -i :111 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME systemd 1 root 34u IPv6 27796 0t0 TCP *:sunrpc (LISTEN) systemd 1 root 35u IPv4 27797 0t0 TCP *:sunrpc (LISTEN) rpcbind 52067 rpc 4u IPv6 27796 0t0 TCP *:sunrpc (LISTEN) rpcbind 52067 rpc 5u IPv4 27797 0t0 TCP *:sunrpc (LISTEN) 查看正在监听的111端口,由哪个服务使用 cat /etc/services | grep -w 111 sunrpc 111/tcp portmapper rpcbind # RPC 4.0 portmapper TCP sunrpc 111/udp portmapper rpcbind # RPC 4.0 portmapper UDP systemctl list-unit-files --all |grep rpcbind rpcbind.service indirect rpcbind.socket disabled rpcbind.target static 核心语句: systemctl stop rpcbind.socket systemctl disable rpcbind.socket systemctl disable rpcbind.socket CentOS6.X系统: chkconfig rpcbind off service rpcbind stop 核对是否真关了: systemctl list-unit-files --all |grep rpcbind 111消失了: ss -lnt State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:22 *:* LISTEN 0 128 *:10050 *:* LISTEN 0 128 :::22 :::* 参考自:https://www.qiuvps.com/1595.html https://my.oschina.net/u/1189928/blog/1824327 三)关闭rpc.statd服务 lsof -i tcp:10588 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME rpc.statd 1828 rpcuser 9u IPv4 13392 0t0 TCP *:10588 (LISTEN) which rpc.statd /sbin/rpc.statd rpm -qf /sbin/rpc.statd nfs-utils-1.2.3-39.el6_5.3.x86_64 rpm -ql nfs-utils|grep '/etc/rc.d' /etc/rc.d/init.d/nfs /etc/rc.d/init.d/nfslock /etc/rc.d/init.d/rpcgssd /etc/rc.d/init.d/rpcidmapd /etc/rc.d/init.d/rpcsvcgssd /etc/init.d/nfslock stop lsof -i tcp:631 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME cupsd 1865 root 6u IPv6 13530 0t0 TCP [::1]:ipp (LISTEN) cupsd 1865 root 7u IPv4 13531 0t0 TCP xy.xxxx.xx:ipp (LISTEN) rpm -qf `which cupsd` cups-1.4.2-78.el6_9.x86_64 netstat -anp|grep 631 tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1865/cupsd tcp 0 0 ::1:631 :::* LISTEN 1865/cupsd udp 0 0 0.0.0.0:631 0.0.0.0:* 1865/cupsd 1865 1 01:29:04 Mon Jun 1 17:53:58 2020 cupsd -C /etc/cups/cupsd.conf 1890 1 01:29:04 Mon Jun 1 17:53:58 2020 hald 1891 1890 01:29:04 Mon Jun 1 17:53:58 2020 \_ hald-runner 1923 1891 01:29:04 Mon Jun 1 17:53:58 2020 \_ hald-addon-input: Listening on /dev/input/event2 /dev/input/event0 kill -9 1865 # 干死,端口消失。 参考:http://coolnull.com/4038.html 三)特殊端口服务可能是mount 产生的端口: mount端口是看不到程序的,只显示一个小横杠。 netstat -lntp|grep 54086 tcp 0 0 0.0.0.0:54086 0.0.0.0:* LISTEN - umount /data/webdata # umount后端口消失 实践来自:https://jackxiang.com/post/10577/ Generated by Jackxiang's Bo-blog 2.1.1 Release