關(guān)閉系統(tǒng)不必要的端口西设,增強(qiáng)系統(tǒng)安全,此處以關(guān)閉111端口為例進(jìn)行說明炮叶。
1)碗旅、查看本機(jī)正在監(jiān)聽的端口:
[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)、查看正在監(jiān)聽的111端口镜悉,由哪個(gè)服務(wù)使用
[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端口服務(wù)的詳細(xì)狀態(tài)信息
[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)、關(guān)閉正在使用111端口的服務(wù)侣肄,并設(shè)置開機(jī)不啟動(dòng)該服務(wù)
[root@~]# systemctl stop rpcbind.socket
[root@~]# systemctl disable rpcbind.socket
Removed symlink /etc/systemd/system/sockets.target.wants/rpcbind.socket.