0

Below xml content shows firewalld rules I created. There are two rules with status "REJECT" are means to avoid the ssh connection to the server. But it is not working. It is allowing the connection. I did firewall-cmd reload. The other icmp rule works fine but not sure what gone wrong with ssh.

Please help.

<?xml version="1.0" encoding="utf-8"?>
<direct>
  <rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p all --state RELATED,ESTABLISHED -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
  <rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p icmp -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
  <rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p all -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
  <rule priority="0" table="filter" ipv="ipv4" chain="INPUT">-p tcp -s 0.0.0.0/0 -d 0.0.0.0/0 --dport 22 -j REJECT</rule>
  <rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p all --state RELATED,ESTABLISHED -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
  <rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p icmp -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
  <rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p all -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT</rule>
  <rule priority="0" table="filter" ipv="ipv6" chain="INPUT">-p tcp -s 0.0.0.0/0 -d 0.0.0.0/0 --dport 22 -j REJECT</rule>
</direct>

1 Answers1

0

The reason being the port was not open for sshd service. In sshd_config file I added below line,

Port 5670

Then ran below commands

firewall-cmd --add-port=5670/tcp --permanent
systemctl restart sshd