在Debian系統中,限制Telnet訪問可以通過以下幾種方法實現:
安裝iptables(如果尚未安裝):
sudo apt-get update
sudo apt-get install iptables
配置iptables規則: 你可以添加規則來阻止特定IP地址或所有IP地址訪問Telnet端口(默認是23)。
阻止所有IP訪問Telnet:
sudo iptables -A INPUT -p tcp --dport 23 -j DROP
允許特定IP訪問Telnet:
sudo iptables -A INPUT -p tcp --dport 23 -s 允許的IP地址 -j ACCEPT
例如,允許IP地址為192.168.1.100
的設備訪問Telnet:
sudo iptables -A INPUT -p tcp --dport 23 -s 192.168.1.100 -j ACCEPT
保存iptables規則: Debian系統默認不會保存iptables規則,因此你需要手動保存它們??梢允褂靡韵旅睿?/p>
sudo sh -c "iptables-save > /etc/iptables/rules.v4"
或者使用iptables-persistent
包來自動保存規則:
sudo apt-get install iptables-persistent
sudo netfilter-persistent save
sudo netfilter-persistent reload
安裝UFW(如果尚未安裝):
sudo apt-get update
sudo apt-get install ufw
啟用UFW:
sudo ufw enable
配置UFW規則:
阻止所有IP訪問Telnet:
sudo ufw deny 23/tcp
允許特定IP訪問Telnet:
sudo ufw allow from 允許的IP地址 to any port 23 proto tcp
例如,允許IP地址為192.168.1.100
的設備訪問Telnet:
sudo ufw allow from 192.168.1.100 to any port 23 proto tcp
查看UFW狀態:
sudo ufw status
如果你不需要Telnet服務,可以直接禁用它:
停止Telnet服務:
sudo systemctl stop telnet.socket
禁用Telnet服務:
sudo systemctl disable telnet.socket
確認服務狀態:
sudo systemctl status telnet.socket
通過以上方法,你可以有效地限制Debian系統上的Telnet訪問,提高系統的安全性。