How do I get a list of the ports which belong to preconfigured firewall-cmd services?











up vote
0
down vote

favorite












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?










share|improve this question






















  • 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 at 9:47















up vote
0
down vote

favorite












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?










share|improve this question






















  • 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 at 9:47













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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?










share|improve this question













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?







centos systemd firewall firewalld






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 5 at 9:37









Zhro

342313




342313












  • 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 at 9:47


















  • 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 at 9:47
















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 at 9:47




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 at 9:47










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










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"?>
<service>
<short>Samba</short>
<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"/>
</service>


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






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486111%2fhow-do-i-get-a-list-of-the-ports-which-belong-to-preconfigured-firewall-cmd-serv%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    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"?>
    <service>
    <short>Samba</short>
    <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"/>
    </service>


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






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      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"?>
      <service>
      <short>Samba</short>
      <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"/>
      </service>


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






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        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"?>
        <service>
        <short>Samba</short>
        <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"/>
        </service>


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






        share|improve this answer












        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"?>
        <service>
        <short>Samba</short>
        <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"/>
        </service>


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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 5 at 9:40









        Ulrich Schwarz

        9,56512846




        9,56512846






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486111%2fhow-do-i-get-a-list-of-the-ports-which-belong-to-preconfigured-firewall-cmd-serv%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre