在CentOS系统中,要禁止Telnet访问特定IP,您可以使用firewalld
或iptables
来实现。下面是两种方法的详细步骤:
方法一:使用firewalld
sudo yum install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.100" port protocol="tcp" port="23" reject'
sudo firewall-cmd --reload
方法二:使用iptables
sudo iptables -A INPUT -p tcp --dport 23 -s 192.168.1.100 -j DROP
sudo service iptables save
注意:如果您使用的是CentOS 7或更高版本,可能需要先启用iptables-services
包:
sudo yum install iptables-services
然后启动并启用iptables服务:
sudo systemctl start iptables
sudo systemctl enable iptables
以上两种方法均可实现禁止Telnet访问特定IP的目的。您可以根据自己的需求和喜好选择合适的方法。