在CentOS系统中,配置防火墙以允许Telnet服务需要使用firewalld或iptables。以下是两种方法的详细步骤:
firewalld安装 firewalld(如果尚未安装):
sudo yum install firewalld
启动 firewalld 服务:
sudo systemctl start firewalld
启用 firewalld 开机自启:
sudo systemctl enable firewalld
打开Telnet端口(默认端口23):
sudo firewall-cmd --permanent --add-port=23/tcp
重新加载 firewalld 配置:
sudo firewall-cmd --reload
验证端口是否已打开:
sudo firewall-cmd --list-all
在输出中,你应该能看到类似以下的内容:
ports: tcp 23/tcp
iptables安装 iptables(如果尚未安装):
sudo yum install iptables-services
启动 iptables 服务:
sudo systemctl start iptables
启用 iptables 开机自启:
sudo systemctl enable iptables
打开Telnet端口(默认端口23):
sudo iptables -A INPUT -p tcp --dport 23 -j ACCEPT
保存 iptables 规则:
sudo service iptables save
验证规则是否已添加:
sudo iptables -L -n
在输出中,你应该能看到类似以下的内容:
ACCEPT tcp -- anywhere anywhere tcp dpt:telnet
通过以上步骤,你应该能够在CentOS系统上成功配置防火墙以允许Telnet服务。