SlideShare a Scribd company logo
2
Most read
Set up a Firewall using FirewallD
Introduction
Firewalld is a firewall management solution available for many Linux distributions which acts
as a frontend for the iptables packet filtering system provided by the Linux kernel. In this
guide, we will cover how to set up a firewall for your server and show you the basics of
managing the firewall with the firewall-cmd administrative tool.
Basic Concepts of FirewallD
Let’s get familiar with a few basic concepts that the tool (firewall-cmd) introduces.
Zones:
The firewalld daemon manages groups of rules using entities called "zones".
In order from least trusted to most trusted, the predefined zones within firewalld are:
 drop: The lowest level of trust. All incoming connections are dropped without reply and
only outgoing connections are possible.
 block: Similar to the above, but instead of simply dropping connections, incoming
requests are rejected with an icmp-host-prohibited or icmp6-adm-prohibited message.
 public: Represents public, untrusted networks. You don't trust other computers but
may allow selected incoming connections on a case-by-case basis.
 external: External networks in the event that you are using the firewall as your
gateway. It is configured for NAT masquerading so that your internal network remains
private but reachable.
 internal: The other side of the external zone, used for the internal portion of a gateway.
The computers are fairly trustworthy and some additional services are available.
 dmz: Used for computers located in a DMZ (isolated computers that will not have
access to the rest of your network). Only certain incoming connections are allowed.
 work: Used for work machines. Trust most of the computers in the network. A few
more services might be allowed.
 home: A home environment. It generally implies that you trust most of the other
computers and that a few more services will be accepted.
 trusted: Trust all of the machines in the network. The most open of the available
options and should be used sparingly.
To use the firewall, we can create rules and alter the properties of our zones and then assign
our network interfaces to whichever zones are most appropriate.
SagarG
or
Rule Permanence
In firewalld, rules can be designated as either permanent or immediate. If a rule is added or
modified, by default, the behavior of the currently running firewall is modified. At the next boot,
the old rules will be reverted.
Most firewall-cmd operations can take the --permanent flag to indicate that the non-
ephemeral firewall should be targeted. This will affect the rule set that is reloaded upon boot.
This separation means that you can test rules in your active firewall instance and then reload
if there are problems. You can also use the --permanent flag to build out an entire set of rules
over time that will all be applied at once when the reload command is issued.
Install and Enable Your Firewall to Start at Boot
firewalld is installed by default on some Linux distributions, including many images of
CentOS 7. However, it may be necessary for you to install firewalld yourself:
[root@localhost ~]# yum install firewalld
[root@localhost ~]# systemctl enable firewalld
[root@localhost ~]# systemctl reboot Or reboot Or init 6
We can verify that the service is running and reachable by typing:
Getting Familiar with the Current Firewall Rules
Exploring the Defaults
We can see which zone is currently selected as the default by typing:
Since we haven't given firewalld any commands to deviate from the default zone, and none of
our interfaces are configured to bind to another zone, that zone will also be the only "active"
zone (the zone that is controlling the traffic for our interfaces). We can verify that by typing:
SagarG
or
How do we know what rules are associated with the home zone though? We can print out the
default zone's configuration by typing:
Exploring Alternative Zones
To get a list of the available zones, type:
We can see the specific configuration associated with a zone by including the --
zone= parameter in our --list-all command:
You can output all of the zone definitions by using the --list-all-zones option. You will
probably want to pipe the output into a pager for easier viewing:
[root@localhost ~]# firewall-cmd --list-all-zones | less
SagarG
or
Selecting Zones for your Interfaces
Changing the Zone of an Interface
You can transition an interface between zones during a session by using the --
zone= parameter in combination with the --change-interface= parameter. As with all
commands that modify the firewall.
Note: Whenever you are transitioning an interface to a new zone, be aware that you are
probably modifying the services that will be operational. For instance, here we are
moving to the "public" zone, which has SSH available. This means that our connection
shouldn't drop. Some other zones do not have SSH enabled by default and if your
connection is dropped while using one of these zones, you could find yourself unable to
log back in.
We can verify that this was successful by asking for the active zones again:
Adjusting the Default Zone
If all of your interfaces can best be handled by a single zone, it's probably easier to just select
the best default zone and then use that for your configuration.
You can change the default zone with the --set-default-zone= parameter. This will immediately
change any interface that had fallen back on the default to the new zone:
SagarG
or
Setting Rules for your Applications
The basic way of defining firewall exceptions for the services you wish to make available is
easy. We'll run through the basic idea here.
Adding a Service to your Zones
The easiest method is to add the services or ports you need to the zones you are using. Again,
you can get a list of the available services with the --get-services option:
Note: You can get more details about each of these services by looking at their
associated .xml file within the /usr/lib/firewalld/services directory. For
instance, the SSH service is defined like this:
For instance, if we are running a web server serving conventional HTTP traffic, we can allow
this traffic for interfaces in our "home" zone for this session by typing:
You can leave out the --zone= if you wish to modify the default zone. We can verify the
operation was successful by using the --list-all or --list-services operations:
Once you have tested that everything is working as it should, you will probably want to modify
the permanent firewall rules so that your service will still be available after a reboot. We can
make our "home" zone change permanent by typing:
SagarG
or
You can verify that this was successful by adding the --permanent flag to the --list-
services operation.
What If No Appropriate Service Is Available?
The firewall services that are included with the firewalld installation represent many of the
most common requirements for applications that you may wish to allow access to. However,
there will likely be scenarios where these services do not fit your requirements.
In this situation, you have two options.
Opening a Port for your Zones
The easiest way to add support for your specific application is to open up the ports that it uses
in the appropriate zone(s). This is as easy as specifying the port or port range, and the
associated protocol for the ports you need to open.
For instance, if our application runs on port 5000 and uses TCP, we could add this to the
"public" zone for this session using the --add-port= parameter. Protocols can be
either tcp or udp:
We can verify that this was successful using the --list-ports operation:
It is also possible to specify a sequential range of ports by separating the beginning and ending
port in the range with a dash. For instance, if our application uses UDP ports 5555 to 5565,
we could open these up on "home" by typing:
After testing, we would likely want to add these to the permanent firewall. You can do that by
typing:
SagarG
or
Defining a Service
Opening ports for your zones is easy, but it can be difficult to keep track of what each one is
for. If you ever decommission a service on your server, you may have a hard time
remembering which ports that have been opened are still required. To avoid this situation, it
is possible to define a service.
Services are simply collections of ports with an associated name and description. Using
services is easier to administer than ports, but requires a bit of upfront work. The easiest way
to start is to copy an existing script (found in /usr/lib/firewalld/services) to
the /etc/firewalld/services directory where the firewall looks for non-standard
definitions.
For instance, we could copy the SSH service definition to use for our "example" service
definition like this. The filename minus the .xml suffix will dictate the name of the service within
the firewall services list:
[root@localhost ~]#cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/example.xml
Now, you can adjust the definition found in the file you copied:
[root@localhost ~]# nano /etc/firewalld/services/example.xml
Reload your firewall to get access to your new service:
SagarG
or
You can see that it is now among the list of available services:
Creating Your Own Zones
For Instance,
For Web Server: Publicweb
DNS Server: privatedns
You can verify,
As stated before, these won't be available in the current instance of the firewall yet:
SagarG
or
Now, you can begin assigning the appropriate services and ports to your zones. It's usually a
good idea to adjust the active instance and then transfer those changes to the permanent
configuration after testing. For instance, for the "publicweb" zone, you might want to add the
SSH, HTTP, and HTTPS services:
Likewise, we can add the DNS service to our "privateDNS" zone:
Now, set –permanent flag and reload the firewallD & Network to work efficiently.
[root@localhost ~]# firewall-cmd --set-default-zone=publicweb
SagarG
or

More Related Content

PDF
FIREWALLD
Benjamin Samuel
 
PPT
Linux Networking Commands
tmavroidis
 
PDF
GSM Idle Mode Behavior
Md Mustafizur Rahman
 
PPT
Mac sub layer
DIKSHA_LAHRANI
 
PDF
GPEH, PCHR, CHR, MR, SIG, CTUM, CELL TRACE, UETR Parsers - Innovile
Ahmet Ozturk
 
PPTX
SSV Tool
nedimsahin
 
DOCX
Ericsson MSC commands
Anthony Uisso
 
PPTX
Transport layer
Mukesh Chinta
 
FIREWALLD
Benjamin Samuel
 
Linux Networking Commands
tmavroidis
 
GSM Idle Mode Behavior
Md Mustafizur Rahman
 
Mac sub layer
DIKSHA_LAHRANI
 
GPEH, PCHR, CHR, MR, SIG, CTUM, CELL TRACE, UETR Parsers - Innovile
Ahmet Ozturk
 
SSV Tool
nedimsahin
 
Ericsson MSC commands
Anthony Uisso
 
Transport layer
Mukesh Chinta
 

What's hot (20)

PDF
Mobile Network Layer
Rahul Hada
 
PDF
Beginners: Bandwidth, Throughput, Latency & Jitter in mobile networks
3G4G
 
DOCX
Layer 3 messages
John Samir
 
PPTX
NR_Frame_Structure_and_Air_Interface_Resources.pptx
Bijoy Banerjee
 
DOCX
Rach procedure in lte
Saurav Banerjee
 
PDF
GSM Channel Concept
Md Mustafizur Rahman
 
PDF
Ericsson documents.mx ericsson-field-guide-for-utran
Thananan numatti
 
PPTX
LTE RACH Procedure
Aalekh Jain
 
PPSX
Paging in LTE
Surya Munda
 
PPTX
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
Kruti Niranjan
 
PPTX
OSPF Basics
Martin Bratina
 
PPTX
Transmission Control Protocol (TCP)
k33a
 
PPT
IP Subnetting
Shahzad Rashid
 
PDF
Multiplexing
Aman Jaiswal
 
PPTX
IP based standards for IoT
Michael Koster
 
PPSX
3G drive test procedure (SSV) by Md Joynal Abaden
Md Joynal Abaden
 
PPT
Dns ppt
Bizuworkk Jemaneh
 
PDF
Events in tems products
To Anh
 
PPTX
IPv4
Dhiraj Mishra
 
Mobile Network Layer
Rahul Hada
 
Beginners: Bandwidth, Throughput, Latency & Jitter in mobile networks
3G4G
 
Layer 3 messages
John Samir
 
NR_Frame_Structure_and_Air_Interface_Resources.pptx
Bijoy Banerjee
 
Rach procedure in lte
Saurav Banerjee
 
GSM Channel Concept
Md Mustafizur Rahman
 
Ericsson documents.mx ericsson-field-guide-for-utran
Thananan numatti
 
LTE RACH Procedure
Aalekh Jain
 
Paging in LTE
Surya Munda
 
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
Kruti Niranjan
 
OSPF Basics
Martin Bratina
 
Transmission Control Protocol (TCP)
k33a
 
IP Subnetting
Shahzad Rashid
 
Multiplexing
Aman Jaiswal
 
IP based standards for IoT
Michael Koster
 
3G drive test procedure (SSV) by Md Joynal Abaden
Md Joynal Abaden
 
Events in tems products
To Anh
 
Ad

Similar to Firewalld (20)

PDF
Configuration Firewalld On CentOS 8
Kaan Aslandağ
 
ODP
Firewalld : A New Interface to Your Netfilter Stack
Mahmoud Shiri Varamini
 
PDF
Firewalld LAB
Kaan Aslandağ
 
PPT
Mcserviceguard2
grogers1124
 
PDF
Aruba Instant 6.4.0.2-4.1 Command Line Interface Reference Guide
Aruba, a Hewlett Packard Enterprise company
 
PDF
Securing Switch Access
Netwax Lab
 
PDF
Aruba OS 7.3 Command Line Interface Reference Guide
Aruba, a Hewlett Packard Enterprise company
 
PPTX
Basic Cisco ASA 5506-x Configuration (Firepower)
NetProtocol Xpert
 
DOCX
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
carliotwaycave
 
PPTX
NagiOs.pptxhjkgfddssddfccgghuikjhgvccvvhjj
rani marri
 
PDF
Cisco asa firewall command line technical guide
MDEMARCOCCIE
 
ODP
PandoraFMS: Free Monitoring System
Enrique Verdes
 
PPT
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days
 
PDF
Ansible automation tool with modules
mohamedmoharam
 
DOCX
Creating a firewall in UBUNTU
Mumbai University
 
PDF
How To Install and Configure SNMP on RHEL 7 or CentOS 7
VCP Muthukrishna
 
PPT
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltStack
 
PPTX
F5 tcpdump
alex wade
 
PPT
Air Live Rs 1200
guest52b3f5
 
PDF
Webinar NETGEAR - La gestione wireless centralizzata con la modalità Ensemble
Netgear Italia
 
Configuration Firewalld On CentOS 8
Kaan Aslandağ
 
Firewalld : A New Interface to Your Netfilter Stack
Mahmoud Shiri Varamini
 
Firewalld LAB
Kaan Aslandağ
 
Mcserviceguard2
grogers1124
 
Aruba Instant 6.4.0.2-4.1 Command Line Interface Reference Guide
Aruba, a Hewlett Packard Enterprise company
 
Securing Switch Access
Netwax Lab
 
Aruba OS 7.3 Command Line Interface Reference Guide
Aruba, a Hewlett Packard Enterprise company
 
Basic Cisco ASA 5506-x Configuration (Firepower)
NetProtocol Xpert
 
INFA 620Laboratory 4 Configuring a FirewallIn this exercise.docx
carliotwaycave
 
NagiOs.pptxhjkgfddssddfccgghuikjhgvccvvhjj
rani marri
 
Cisco asa firewall command line technical guide
MDEMARCOCCIE
 
PandoraFMS: Free Monitoring System
Enrique Verdes
 
Positive Hack Days. Pavlov. Network Infrastructure Security Assessment
Positive Hack Days
 
Ansible automation tool with modules
mohamedmoharam
 
Creating a firewall in UBUNTU
Mumbai University
 
How To Install and Configure SNMP on RHEL 7 or CentOS 7
VCP Muthukrishna
 
SaltConf14 - Ben Cane - Using SaltStack in High Availability Environments
SaltStack
 
F5 tcpdump
alex wade
 
Air Live Rs 1200
guest52b3f5
 
Webinar NETGEAR - La gestione wireless centralizzata con la modalità Ensemble
Netgear Italia
 
Ad

More from Sagar Gor (6)

PDF
Device software image verification
Sagar Gor
 
PPTX
AAA Best Practices
Sagar Gor
 
PPT
logical addressing
Sagar Gor
 
PPT
hardware addressing
Sagar Gor
 
PPT
Osi reference model
Sagar Gor
 
PPT
Introduction to networks
Sagar Gor
 
Device software image verification
Sagar Gor
 
AAA Best Practices
Sagar Gor
 
logical addressing
Sagar Gor
 
hardware addressing
Sagar Gor
 
Osi reference model
Sagar Gor
 
Introduction to networks
Sagar Gor
 

Recently uploaded (20)

PPTX
办理方法西班牙假毕业证蒙德拉贡大学成绩单MULetter文凭样本
xxxihn4u
 
PPTX
dns domain name system history work.pptx
MUHAMMADKAVISHSHABAN
 
PDF
Project English Paja Jara Alejandro.jpdf
AlejandroAlonsoPajaJ
 
PPTX
谢尔丹学院毕业证购买|Sheridan文凭不见了怎么办谢尔丹学院成绩单
mookxk3
 
PPTX
How tech helps people in the modern era.
upadhyayaryan154
 
PDF
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
PPTX
B2B_Ecommerce_Internship_Simranpreet.pptx
LipakshiJindal
 
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
APNIC
 
PPTX
LESSON-2-Roles-of-ICT-in-Teaching-for-learning_123922 (1).pptx
renavieramopiquero
 
PDF
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
PPT
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
PPTX
Black Yellow Modern Minimalist Elegant Presentation.pptx
nothisispatrickduhh
 
PDF
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
PPTX
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
PDF
Generative AI Foundations: AI Skills for the Future of Work
hemal sharma
 
PDF
UI/UX Developer Guide: Tools, Trends, and Tips for 2025
Penguin peak
 
PPTX
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
PDF
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
PDF
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
PPTX
EthicalHack{aksdladlsfsamnookfmnakoasjd}.pptx
dagarabull
 
办理方法西班牙假毕业证蒙德拉贡大学成绩单MULetter文凭样本
xxxihn4u
 
dns domain name system history work.pptx
MUHAMMADKAVISHSHABAN
 
Project English Paja Jara Alejandro.jpdf
AlejandroAlonsoPajaJ
 
谢尔丹学院毕业证购买|Sheridan文凭不见了怎么办谢尔丹学院成绩单
mookxk3
 
How tech helps people in the modern era.
upadhyayaryan154
 
KIPER4D situs Exclusive Game dari server Star Gaming Asia
hokimamad0
 
B2B_Ecommerce_Internship_Simranpreet.pptx
LipakshiJindal
 
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
APNIC
 
LESSON-2-Roles-of-ICT-in-Teaching-for-learning_123922 (1).pptx
renavieramopiquero
 
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
Black Yellow Modern Minimalist Elegant Presentation.pptx
nothisispatrickduhh
 
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
Generative AI Foundations: AI Skills for the Future of Work
hemal sharma
 
UI/UX Developer Guide: Tools, Trends, and Tips for 2025
Penguin peak
 
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
BGP Security Best Practices that Matter, presented at PHNOG 2025
APNIC
 
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
EthicalHack{aksdladlsfsamnookfmnakoasjd}.pptx
dagarabull
 

Firewalld

  • 1. Set up a Firewall using FirewallD Introduction Firewalld is a firewall management solution available for many Linux distributions which acts as a frontend for the iptables packet filtering system provided by the Linux kernel. In this guide, we will cover how to set up a firewall for your server and show you the basics of managing the firewall with the firewall-cmd administrative tool. Basic Concepts of FirewallD Let’s get familiar with a few basic concepts that the tool (firewall-cmd) introduces. Zones: The firewalld daemon manages groups of rules using entities called "zones". In order from least trusted to most trusted, the predefined zones within firewalld are:  drop: The lowest level of trust. All incoming connections are dropped without reply and only outgoing connections are possible.  block: Similar to the above, but instead of simply dropping connections, incoming requests are rejected with an icmp-host-prohibited or icmp6-adm-prohibited message.  public: Represents public, untrusted networks. You don't trust other computers but may allow selected incoming connections on a case-by-case basis.  external: External networks in the event that you are using the firewall as your gateway. It is configured for NAT masquerading so that your internal network remains private but reachable.  internal: The other side of the external zone, used for the internal portion of a gateway. The computers are fairly trustworthy and some additional services are available.  dmz: Used for computers located in a DMZ (isolated computers that will not have access to the rest of your network). Only certain incoming connections are allowed.  work: Used for work machines. Trust most of the computers in the network. A few more services might be allowed.  home: A home environment. It generally implies that you trust most of the other computers and that a few more services will be accepted.  trusted: Trust all of the machines in the network. The most open of the available options and should be used sparingly. To use the firewall, we can create rules and alter the properties of our zones and then assign our network interfaces to whichever zones are most appropriate. SagarG or
  • 2. Rule Permanence In firewalld, rules can be designated as either permanent or immediate. If a rule is added or modified, by default, the behavior of the currently running firewall is modified. At the next boot, the old rules will be reverted. Most firewall-cmd operations can take the --permanent flag to indicate that the non- ephemeral firewall should be targeted. This will affect the rule set that is reloaded upon boot. This separation means that you can test rules in your active firewall instance and then reload if there are problems. You can also use the --permanent flag to build out an entire set of rules over time that will all be applied at once when the reload command is issued. Install and Enable Your Firewall to Start at Boot firewalld is installed by default on some Linux distributions, including many images of CentOS 7. However, it may be necessary for you to install firewalld yourself: [root@localhost ~]# yum install firewalld [root@localhost ~]# systemctl enable firewalld [root@localhost ~]# systemctl reboot Or reboot Or init 6 We can verify that the service is running and reachable by typing: Getting Familiar with the Current Firewall Rules Exploring the Defaults We can see which zone is currently selected as the default by typing: Since we haven't given firewalld any commands to deviate from the default zone, and none of our interfaces are configured to bind to another zone, that zone will also be the only "active" zone (the zone that is controlling the traffic for our interfaces). We can verify that by typing: SagarG or
  • 3. How do we know what rules are associated with the home zone though? We can print out the default zone's configuration by typing: Exploring Alternative Zones To get a list of the available zones, type: We can see the specific configuration associated with a zone by including the -- zone= parameter in our --list-all command: You can output all of the zone definitions by using the --list-all-zones option. You will probably want to pipe the output into a pager for easier viewing: [root@localhost ~]# firewall-cmd --list-all-zones | less SagarG or
  • 4. Selecting Zones for your Interfaces Changing the Zone of an Interface You can transition an interface between zones during a session by using the -- zone= parameter in combination with the --change-interface= parameter. As with all commands that modify the firewall. Note: Whenever you are transitioning an interface to a new zone, be aware that you are probably modifying the services that will be operational. For instance, here we are moving to the "public" zone, which has SSH available. This means that our connection shouldn't drop. Some other zones do not have SSH enabled by default and if your connection is dropped while using one of these zones, you could find yourself unable to log back in. We can verify that this was successful by asking for the active zones again: Adjusting the Default Zone If all of your interfaces can best be handled by a single zone, it's probably easier to just select the best default zone and then use that for your configuration. You can change the default zone with the --set-default-zone= parameter. This will immediately change any interface that had fallen back on the default to the new zone: SagarG or
  • 5. Setting Rules for your Applications The basic way of defining firewall exceptions for the services you wish to make available is easy. We'll run through the basic idea here. Adding a Service to your Zones The easiest method is to add the services or ports you need to the zones you are using. Again, you can get a list of the available services with the --get-services option: Note: You can get more details about each of these services by looking at their associated .xml file within the /usr/lib/firewalld/services directory. For instance, the SSH service is defined like this: For instance, if we are running a web server serving conventional HTTP traffic, we can allow this traffic for interfaces in our "home" zone for this session by typing: You can leave out the --zone= if you wish to modify the default zone. We can verify the operation was successful by using the --list-all or --list-services operations: Once you have tested that everything is working as it should, you will probably want to modify the permanent firewall rules so that your service will still be available after a reboot. We can make our "home" zone change permanent by typing: SagarG or
  • 6. You can verify that this was successful by adding the --permanent flag to the --list- services operation. What If No Appropriate Service Is Available? The firewall services that are included with the firewalld installation represent many of the most common requirements for applications that you may wish to allow access to. However, there will likely be scenarios where these services do not fit your requirements. In this situation, you have two options. Opening a Port for your Zones The easiest way to add support for your specific application is to open up the ports that it uses in the appropriate zone(s). This is as easy as specifying the port or port range, and the associated protocol for the ports you need to open. For instance, if our application runs on port 5000 and uses TCP, we could add this to the "public" zone for this session using the --add-port= parameter. Protocols can be either tcp or udp: We can verify that this was successful using the --list-ports operation: It is also possible to specify a sequential range of ports by separating the beginning and ending port in the range with a dash. For instance, if our application uses UDP ports 5555 to 5565, we could open these up on "home" by typing: After testing, we would likely want to add these to the permanent firewall. You can do that by typing: SagarG or
  • 7. Defining a Service Opening ports for your zones is easy, but it can be difficult to keep track of what each one is for. If you ever decommission a service on your server, you may have a hard time remembering which ports that have been opened are still required. To avoid this situation, it is possible to define a service. Services are simply collections of ports with an associated name and description. Using services is easier to administer than ports, but requires a bit of upfront work. The easiest way to start is to copy an existing script (found in /usr/lib/firewalld/services) to the /etc/firewalld/services directory where the firewall looks for non-standard definitions. For instance, we could copy the SSH service definition to use for our "example" service definition like this. The filename minus the .xml suffix will dictate the name of the service within the firewall services list: [root@localhost ~]#cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/example.xml Now, you can adjust the definition found in the file you copied: [root@localhost ~]# nano /etc/firewalld/services/example.xml Reload your firewall to get access to your new service: SagarG or
  • 8. You can see that it is now among the list of available services: Creating Your Own Zones For Instance, For Web Server: Publicweb DNS Server: privatedns You can verify, As stated before, these won't be available in the current instance of the firewall yet: SagarG or
  • 9. Now, you can begin assigning the appropriate services and ports to your zones. It's usually a good idea to adjust the active instance and then transfer those changes to the permanent configuration after testing. For instance, for the "publicweb" zone, you might want to add the SSH, HTTP, and HTTPS services: Likewise, we can add the DNS service to our "privateDNS" zone: Now, set –permanent flag and reload the firewallD & Network to work efficiently. [root@localhost ~]# firewall-cmd --set-default-zone=publicweb SagarG or