linux 关闭不用的端口,linux关闭不必要的端口

关闭系统不必要的端口,增强系统安全,此处以关闭111端口为例进行说明。

1)、查看本机正在监听的端口:

[root@ ~]# netstat -pantu

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2513/rpcbind

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3259/sshd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2983/master

tcp6 0 0 :::111 :::* LISTEN 2513/rpcbind

tcp6 0 0 :::22 :::* LISTEN 3259/sshd

udp 0 0 0.0.0.0:978 0.0.0.0:* 2513/rpcbind

udp 0 0 0.0.0.0:68 0.0.0.0:* 2744/dhclient

udp 0 0 0.0.0.0:111 0.0.0.0:* 2513/rpcbind

udp 0 0 127.0.0.1:323 0.0.0.0:* 2539/chronyd

udp6 0 0 :::978 :::* 2513/rpcbind

udp6 0 0 :::111 :::* 2513/rpcbind

udp6 0 0 ::1:323 :::* 2539/chronyd

2)、查看正在监听的111端口,由哪个服务使用

[root@ ~]# 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

3)、查看使用111端口服务的详细状态信息

[root@ ~]# systemctl list-unit-files --all | grep port

dbus-org.freedesktop.import1.service static

rhel-import-state.service enabled

systemd-importd.service static

[root@ ~]# systemctl list-unit-files --all | grep rpcbind

rpcbind.service enabled

rpcbind.socket enabled

rpcbind.target static

4)、关闭正在使用111端口的服务,并设置开机不启动该服务

[root@~]# systemctl stop rpcbind.socket

[root@~]# systemctl disable rpcbind.socket

Removed symlink /etc/systemd/system/sockets.target.wants/rpcbind.socket.

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值