wazuh-packages icon indicating copy to clipboard operation
wazuh-packages copied to clipboard

Unify unatteded check firewalls

Open myu1d157h0u54nd opened this issue 3 years ago • 2 comments

Related issue
Closes #1217

Description

Check if firewalld, ufw or iptables exists. If they exist, check if there is any rule that prevents another component from connecting to it.

myu1d157h0u54nd avatar Feb 01 '22 03:02 myu1d157h0u54nd

Simulation adding similar ports, to validate the use of grep with an exact match.

iptables -L -n | grep 1514
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:1514
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:15141

Simulation of an environment with all firewalls installed, and all Wazuh ports blocked.

03/02/2022 18:00:40 INFO: Starting Wazuh unattended installer. Wazuh version: 4.3.0. Wazuh installer version: 0.1
03/02/2022 18:00:40 INFO: ---------------------------------- Check firewalls -----------------------------------
03/02/2022 18:00:44 INFO: iptables blocked port report: 1514, 1515, 1516, 55000, 9200, 9300, 9400, 443,  open the recommended ports.
03/02/2022 18:00:44 INFO: nft blocked port report: 1514, 1515, 1516, 55000, 9200, 9300, 9400, 443,  open the recommended ports.
03/02/2022 18:00:44 INFO: ufw blocked port report: 1514, 1515, 1516, 55000, 9200, 9300, 9400, 443,  open the recommended ports.
03/02/2022 18:00:44 INFO: firewall-cmd blocked port report: 1514, 1515, 1516, 55000, 9200, 9300, 9400, 443,  open the recommended ports.
03/02/2022 18:00:44 WARNING: Please check your firewall. To then repeat the installation of Wazuh.

myu1d157h0u54nd avatar Feb 04 '22 21:02 myu1d157h0u54nd

@alberpilot

Use switch case instead of 4 if command == value.

If I use the 'if', I get it to go into each command. This was a necessity of my laboratory that led me to not be able to apply it. Since when implementing it it failed in my scenario. And now I notice it and understand why. I implement it on Monday.

Change it to -d.

After a try. Maybe I'm not seeing something. I doubt whether it is necessary? The behavior that I hope is that report that made me visibly fail. If I don't use -d. They are logs that will not be seen.

myu1d157h0u54nd avatar Feb 04 '22 22:02 myu1d157h0u54nd