Limiting Networks in Red hat Linux
Limiting Network by Firewalld – Redhat 7
Object:
To learn the firewall configuration, commands, creating a zone, modifying the zones, log analysis and troubleshoot the firewall in red hat enterprise distributions.
Introduction:
Firewalld is a new feature for red hat 7 enterprise which used to interact with Netfilter to monitor the zones. Firewalld is a daemon which from firewalld package. It uses to manage the firewall by classifying into zones. Every zone has its own zone and services.
Netfilter is a kernel network filtering system. It allows the kernel to verify every packet transferring (incoming, outgoing, forwarded) by the system.
How Firewalld works:
Configuration:
The default firewalld Configuration:
Zone Name
|
Default Configuration settings
|
Internal
|
Reject incoming packets which not being used in infrastructure (Ex : SSH, Samba, DHCP, DNS, IPP)
|
External
|
Reject incoming packets which not related pre-defined outgoing services. (Ex: SSH, Samba, DHCP, DNS, IPP)
|
Trusted
|
Allow all incoming packets
|
Public
|
Reject incoming packets which not related pre-defined outgoing services. (Ex: SSH, Samba, DHCP, DNS, IPP). The default zone for interfaces.
|
Block
|
Block all incoming packets
|
Drop
|
Drop all incoming packets
|
Home
|
Reject incoming packets which not being used in infrastructure (Ex: SSH, Samba, DHCP, DNS. IPP)
|
Example of Pre-defined Ports/Protocols:
# firewall-cmd --get-services command used to list the pre-defined services.
Examples: SSH – 22/tcp , HTTP – 80/tcp, DHCP – 68/udp, DNS – 53/tcp
There are ways a system administrator can interact with firewalld.
1. Graphical firewalld tool
2. Command line interface
3. Edit configuration file.
Graphical firewalld tool:
Firewall-config is a graphical tool which is installed from the firewalld package. By entering #firewall-config command in cli to launch the firewalld graphical interface or under the application menu bar and it will prompt for root password and can change current, the permanent (Persistent), in-disk configuration, and in-memory configuration.
Steps in Graphical interface:
1. Select the zone for modification in left and assign network interface, source ip, ports or protocol in the right panel.
2. By select the service the respective port can be open by default.
3. Reload the firewall services by Options -> Reload Firewall.
4. If want to change to default zones Options -> Change Default zone
5. Permanent Configuration will be effective until restart or reload the firewall.
Command Line Configuration:
Firewalld CLI configuration is used to configure the zones by using the #firewall-cmd command which used to install along with firewalld packages.
Commands:
#firewall-cmd Commands
|
Explanation
|
--get-default-zone
|
View current default zone
|
--set-default-zone=<zone>
|
Set default zone in runtime and permanent.
|
--get-zones
|
List all zones
|
--get-active-zones
|
List currently used zones with interface and source info
|
--add-source=<CIDR>[--zone=<zone>]
|
Add new source to zone (route all incoming traffic from ip or netmask to specific zone).
|
--remove-source=<CIDR>[--zone=<zone>]
|
Remove all routed traffic to particular zone.
|
--add-interface=<Interface name> [--zone=<Zone>]
|
Add interface to route the packets to specific zone
|
--change-interface=<interface> [--zone=<zone>]
|
Change the interface associated with mentioned zone.
If no zone mentioned, it will be change in default zone.
|
--list-all [--zone=<ZONE>]
|
List all configured interface, services, interfaces, sources.
|
--list-all-zones
|
List all information in all zones.
|
--add-services=<services> [--zone=<Zone>]
|
Allow packets (services) to zone
|
--remove-<port/protocol>=<services> [--zone=<Zone>]
|
Allow packets (ports/protocol) to zone
|
--add-services=<services> [--zone=<Zone>]
|
Remove packets (services) to zone
|
--remove-<port/protocol>=<services> [--zone=<Zone>]
|
Remove packets (ports/protocol) to zone
|
--reload
|
Reload the firewall to allow for permanent configuration
|
Examples:
1. Add 192.168.1.1/24 to internal zone permanently.
#firewall-cmd --permanent --zone=internal --add-source=192.168.1.1/24
2. Add Services to internal zone permanently.
#firewall-cmd --permanent --zone=internal –add-services=DHCP
3. Set default services.
#firewall-cmd --set-default -zone=internal
4. Reload the services.
#firewall-cmd –reload
Enable firewall at startup:
#sudo systemctl enable firewalld
#sudo systemctl start firewalld
Mask iptables to prevent from accidently interact with kernel/firewalld.
#sudo systemctl mask iptables
#sudo systemctl mask ip6tables
Hope, understood the firewalld concept in red hat distribution. Please comment on your feedbacks and quires.


Comments
Post a Comment