I want to open the following ports in my CentOS 7 firewall:

UDP 137 (NetBIOS Name Service)
UDP 138 (NetBIOS Datagram Service)
TCP 139 (NetBIOS Session Service)
TCP 445 (SMB)

I can guess that the services names include samba includes TCP 445 but I don't know if the other ports have a service name preconfigured.

I can list supported services with:

$ firewall-cmd --get-services

But this doesn't tell me what ports are configured with the services.

Is there a way to list what ports belong to these services so that I can grep for the one that I need?

  • 2
    The option you are looking for is --info-service. It wants the service name, tough. So, in order to get ports for many services, looking at service definition files as in Ulrich Schwarz's answer is probably more handy.
    – fra-san
    Dec 5, 2018 at 9:47
  • @fra-san Din kommentar borde vara ett svar. Jun 2, 2021 at 11:09
  • @SamuelÅslund Maybe, but the OP seems to need a way to list the services that use a given port. firewall-cmd --info-service service works the other way round.
    – fra-san
    Jun 2, 2021 at 12:09

1 Answer 1


You can find the xml files this information is stored in in /usr/lib/firewalld/services/ (for distro-managed services) and/or /etc/firewalld/services/ for your own user-defined services.

For example, samba.xml reads (on my centos7):

<?xml version="1.0" encoding="utf-8"?>
  <description>This option allows you to access and participate in Windows file and printer sharing networks. You need the samba package installed for this option to be useful.</description>
  <port protocol="udp" port="137"/>
  <port protocol="udp" port="138"/>
  <port protocol="tcp" port="139"/>
  <port protocol="tcp" port="445"/>
  <module name="nf_conntrack_netbios_ns"/>

so it's easy to spot what ports are enabled by this service.

  • 1
    This seems to be working well for me $ grep -r 445 /usr/lib/firewalld/services/
    – davispuh
    Dec 14, 2019 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.