防火墙启动时,启动firewall时ssh连接断开

执行“systemctl start firewalld” 时,ssh连接怎么断开了?

正常情况下,firewalld是默认开启ssh服务的,当我们开启firewalld的时候,不会影响ssh连接。这个我们可以通过查看firewall配置文件确认。
命令如下

cat /etc/firewalld/zones/public.xml

如上图,ssh服务已经开放,开启firewalld时不会影响

但其实,防火墙开放服务时,会开放服务的默认端口。可以检查ssh端口是否是默认端口22.

[root@localhost services]# cat /etc/ssh/sshd_config |grep Port
Port 2666
#GatewayPorts no
[root@localhost services]# 

端口并不是22. 。可以在public.xml文件中添加2666端口,就不会断开ssh连接了。

[root@localhost /]# cat /etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="dhcpv6-client"/>
  <port protocol="tcp" port="2666"/>              
</zone>
[root@localhost /]# 

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值