techne/firewalld.org
2024-09-20 21:17:26 -05:00

1.3 KiB

Firewalld

Allow connections only from certain IP addresses

Source: FirewallD: Allow connections only from certain IP addresses

  • Do not use rich rules for this.
  • A firewalld zone corresponds to a set of services that you want to allow, and the sources of the traffic to those services.
  • Traffic sources can be designated in two ways: by interface, or by source IP address. Traffic that matches any source passes this check.

Create a new zone for Kali Linux IP addresses:

sudo firewall-cmd --permanent --new-zone=kali
sudo firewall-cmd --reload

Enable the services allow for kali zone:

sudo firewall-cmd --zone=kali --permanent --add-service=ssh
sudo firewall-cmd --zone=kali --permanent --add-service=rsyncd
sudo firewall-cmd --reload

Add the IP addresses allowed to reach the above services. Ensure there are no interfaces designated to this zone.

sudo firewall-cmd --zone=kali --permanent --add-source=<IPv4 addr 1>
sudo firewall-cmd --zone=kali --permanent --add-source=<IPv6 addr>
sudo firewall-cmd --zone=kali --permanent --add-source=<IPv4 addr 2>
sudo firewall-cmd --zone=kali --permanent --add-source=<IPv4 addr 3>
sudo firewall-cmd --reload