Is there an easy way to show a full list of all the ports that have been opened using firewalld
?
I know the command firewall-cmd --list-all
, but that just shows service names, not the ports that those services define as being open.
For example:
[root@myserver log]# firewall-cmd --list-all
dmz (active)
target: default
icmp-block-inversion: no
interfaces: ens160
sources:
services: ssh squid my-icap
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
I know I can go into the definition files for each of these services to see what ports they are defining as open, but it seems like there should be a single-line way to do this, and I'm just missing it.
And I'm not looking for netstat
: that will tell me if something is listening on a port, which is a different question from whether that port is accessible from another host.
firewall-cmd --add-port
orfirewall-cmd --add-service
? – Nasir Riley Aug 21 '19 at 17:00--add-service
, which is why they show up in theservices:
line. If I had added the ports individually with--add-port
, then they would have shown up in theports:
line. But I like the concept of grouping ports by service and enabling and disabling them all together, I'm just frustrated that I can't find a simple way to see all the ports that are opened by the listed services. – Dave Mulligan Aug 21 '19 at 17:42--add-services
, the--list-all
switch only shows the services. That's the way thatfirewall-cmd
is designed to work. If you want it to list the ports then you'll either have to open them with--add-port
or edit the code offirewall-cmd
so that it shows the ports as well as the services. – Nasir Riley Aug 21 '19 at 17:48--list-all
option works. It just seems bizarre if there's no way to display all the ports that are open, which - surely - is one of the most common questions about a firewall's status. Even--service <service_name> get-ports
doesn't give the information about a single service. – Dave Mulligan Aug 21 '19 at 22:31