在 Debian 上,**“telnet 防火墙如何设”**通常有两个层面的理解:
1️⃣ 允许/禁止 telnet 端口(23)通过防火墙
2️⃣ telnet 本身的安全性问题及替代方案
下面按常见场景说明(假设 Debian 使用 nftables 或 iptables)。
⚠️ Telnet 是明文协议,极不安全,生产环境不建议使用
✅ 推荐使用 SSH(22端口) 替代 telnet
iptables -A INPUT -p tcp --dport 23 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 23 -j ACCEPT
iptables -A INPUT -p tcp --dport 23 -j DROP
或拒绝并返回错误:
iptables -A INPUT -p tcp --dport 23 -j REJECT
iptables -A INPUT -p tcp --dport 23 -s 192.168.1.100 -j ACCEPT
iptables -A INPUT -p tcp --dport 23 -j DROP
apt install iptables-persistent
netfilter-persistent save
nft add rule inet filter input tcp dport 23 accept
nft add rule inet filter input tcp dport 23 drop
nft add rule inet filter input ip saddr 192.168.1.100 tcp dport 23 accept
nft add rule inet filter input tcp dport 23 drop
保存:
nft list ruleset > /etc/nftables.conf
systemctl restart nftables
systemctl status inetd
# 或
systemctl status telnet.socket
如未安装:
apt install telnetd
ufw allow 23/tcp
# 或
ufw deny 23/tcp
✅ 生产环境
ufw deny 23/tcp
apt install openssh-server
如果你告诉我:
我可以给你精确命令。