In this video, you'll learn how to work with ports.
Firewall-D can give access to specific ports without using a service.
I think you should consider creating a custom service in this case anyway, because configuration
as code is easier to manage and distribute.
I mean, if it's in a configuration file, you can push it to other servers as well if you
want to.
But if you do want to work with individual ports, that's possible.
Then you use a command like firewall-cmd --"add-port-82-tcp --"permanent.
That's the first part.
That will add it to the permanent configuration.
And another way to apply this permanent configuration to runtime is by using firewall-cmd --"reload."
That will reload the configuration and make sure that you get it immediately as well.
Let me show you.
So the command is going to be firewall-cmd --"add-port-82-tcp --"permanent.
And then I'm using firewall-cmd --"reload."
And that should do the job.
So firewall-cmd --"list-all."
This time, it's showing the port as well.
Now, as I was telling you, you might as well create your own service.
How do you do that?
Let me show you.
I'm copying any service from user lib firewalld services.
And let's use this NFS3 service that we have just seen.
And I'm copying that to etc firewalld services.
Let me call it port83.xml.
Next, I'm going to edit etc firewalld services port83.xml.
And there, I need to put in my information.
So we need a short description, SPP, Standard Port Protocol.
That's a whatever description.
So put in whatever you want to use.
Next, I need a longer description, Sander's Port Protocol.
I need to enter description.
And next, we have a port protocol.
Well, port protocol is port83.
And if you want to, you can even do that for port for UDP port83 as well.
Now, I need to look carefully because my command syntax highlighting is off.
And that is because I made a typo.
Do you see that?
This port protocol TCP is suddenly all blue.
And that is because it couldn't find the closing sign for the description.
So now I edit my service.
And that means that we can do something with it.
I like consistency, by the way.
So let me move etc firewalld services port83 to etc firewalld services SPP.xml.
And now firewallcmd minus minus reload.
This is a better option, by the way, than systemctl restart firewalld
because if you do a systemctl restart,
if you are being hacked at the moment that you are doing that,
the intruder might get in.
And firewallcmd reload is just reloading the configuration
without ever opening ports or being deactivated or whatsoever.
So now let's verify that it is available using firewallcmd minus minus get services
pipegrab SPP.
And as you can see, the standard port protocol service is now available.
And that means that I don't have to manage individual ports anymore,
but I have it nice and consistently in a service file.