Lance Grover

Lance Grover

limit ssh to specific hosts with firewalld (firewall-cmd)

Posted date:


Here is a little reminder on how to limit ssh (or any port really) to a specific IP using firewalld:

<code>
systemctl start firewalld.service
systemctl enable firewalld.service
firewall-cmd –zone=”trusted” –add-source=<external IP 1>
firewall-cmd –zone=”trusted” –add-source=<external IP 1> –permanent
firewall-cmd –zone=”trusted” –add-source=<external IP 2>
firewall-cmd –zone=”trusted” –add-source=<external IP 2> –permanent
firewall-cmd –zone=”trusted” –add-service=ssh
firewall-cmd –zone=”trusted” –add-service=ssh –permanent
firewall-cmd –zone=”trusted” –list-all
firewall-cmd –zone=public –remove-service=ssh
firewall-cmd –zone=public –remove-service=ssh –permanent
</code>