Linux FIREWALL Management
- What is Firewall
- Firewall Service in Linux
- Enable/disable Firewall
- How to see the existing Firewall rule?
- Adding/removing parts
- Block incoming/outgoing traffic
- Block ICMP
What is a firewall?
A firewall is a network securing system that monitors and controls incoming and outgoing network traffic based on the rules defined
It is a security software, firewall is a network security device that protects our network and computer from hackers, viruses and malware.
A firewall is installed between a private network and internet and all data exchanged between the two passes through the firewall.
Firewall acts like a wall that protects the network from harmful data.
Types of firewall
- Software Based
Running on Operating system - Hardware Based
A dedicated application with firewall software between two different network (mostly used by network team)
Tools on Linux for Managing firewall?
- iptables: – old distribution/version
- Firewall: – newer version of CentOS, RedHat, fedora
Listing, Adding, deleting firewall rules
Check if firewalld service is installd?
# rpm -qa | grep firewalld
Stop/start firewalld service?
# systemctl start firewalld
# systemctl enable firewalld
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl status firewalld
# systemctl restart firewalld
Check the rules of firewalld
# firewall-cmd --list-all
Listing of all the service firewalld is aware of:-
# firewall-cmd --get-services
To reload the config of firewalld
# firewall-cmd --reload
firewall has multiple zones, to get list
# firewall-cmd --get-zones
To see the list of active zones
# firewall-cmd --get-active-zones
To get firewall rules for a specific zone
# firewall-cmd --zone=public --list all
To add or remove a service
# firewall-cmd --add-service=<name_of_service>
# firewall-cmd --remove-service=<name_of_service>
To reload the config
# firewall-cmd --reload
To add or remove a service permanently
# firewall-cmd --add-service=<name_of_service> --permanent
# firewall-cmd --remove-service=<name_of_service> --permanent
To add or remove a port
# firewall-cmd --add-port=80/tcp
# firewall-cmd --add-port=80/tcp
To block incoming traffic from an IP
# firewall-cmd --add-rich-rule='rule family="ipv4" source address="192.168.0.0"reject'
To block outgoing traffic to a IP or URL
# firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -d <IP> -j DROP
To block ICMP icoming traffic
# firewall-cmd -add-icmp-block-inversion