Preventing other applications from using a port












-1














One of my applications uses randomly-selected ports from a port range to listen on. By default, 40000-59999.



The application runs on a firewalled server, and of course expects me to open the whole range on the firewall.



I'm not comfortable opening a large range of ports, most of which will never be used. The main concern is that another application may, also randomly, choose a port in that range and end up open to the world. I can configure the port range to be smaller, which would reduce the problem somewhat, but not truly solve it.



I have two ideas how to solve this conceptually, but don't know how/if it can actually be implemented. Operating system is RedHat Linux 7.4. The firewall is iptables/firewalld. SELinux is disabled (yes, I know, I don't like that either...)



My first idea: somehow "magically" prevent all other applications from binding to ports in this range. SELinux might be able to do that, but unfortunately I cannot use SELinux on that server (another application chokes on it).



My second idea: somehow get iptables to open ports by executable instead of by port number. This is a feature in the Windows firewall, but I don't think I have seen a way to do this with iptables.



What I'm looking for is ideas for implementing either of my ideas, or a third approach.










share|improve this question



























    -1














    One of my applications uses randomly-selected ports from a port range to listen on. By default, 40000-59999.



    The application runs on a firewalled server, and of course expects me to open the whole range on the firewall.



    I'm not comfortable opening a large range of ports, most of which will never be used. The main concern is that another application may, also randomly, choose a port in that range and end up open to the world. I can configure the port range to be smaller, which would reduce the problem somewhat, but not truly solve it.



    I have two ideas how to solve this conceptually, but don't know how/if it can actually be implemented. Operating system is RedHat Linux 7.4. The firewall is iptables/firewalld. SELinux is disabled (yes, I know, I don't like that either...)



    My first idea: somehow "magically" prevent all other applications from binding to ports in this range. SELinux might be able to do that, but unfortunately I cannot use SELinux on that server (another application chokes on it).



    My second idea: somehow get iptables to open ports by executable instead of by port number. This is a feature in the Windows firewall, but I don't think I have seen a way to do this with iptables.



    What I'm looking for is ideas for implementing either of my ideas, or a third approach.










    share|improve this question

























      -1












      -1








      -1







      One of my applications uses randomly-selected ports from a port range to listen on. By default, 40000-59999.



      The application runs on a firewalled server, and of course expects me to open the whole range on the firewall.



      I'm not comfortable opening a large range of ports, most of which will never be used. The main concern is that another application may, also randomly, choose a port in that range and end up open to the world. I can configure the port range to be smaller, which would reduce the problem somewhat, but not truly solve it.



      I have two ideas how to solve this conceptually, but don't know how/if it can actually be implemented. Operating system is RedHat Linux 7.4. The firewall is iptables/firewalld. SELinux is disabled (yes, I know, I don't like that either...)



      My first idea: somehow "magically" prevent all other applications from binding to ports in this range. SELinux might be able to do that, but unfortunately I cannot use SELinux on that server (another application chokes on it).



      My second idea: somehow get iptables to open ports by executable instead of by port number. This is a feature in the Windows firewall, but I don't think I have seen a way to do this with iptables.



      What I'm looking for is ideas for implementing either of my ideas, or a third approach.










      share|improve this question













      One of my applications uses randomly-selected ports from a port range to listen on. By default, 40000-59999.



      The application runs on a firewalled server, and of course expects me to open the whole range on the firewall.



      I'm not comfortable opening a large range of ports, most of which will never be used. The main concern is that another application may, also randomly, choose a port in that range and end up open to the world. I can configure the port range to be smaller, which would reduce the problem somewhat, but not truly solve it.



      I have two ideas how to solve this conceptually, but don't know how/if it can actually be implemented. Operating system is RedHat Linux 7.4. The firewall is iptables/firewalld. SELinux is disabled (yes, I know, I don't like that either...)



      My first idea: somehow "magically" prevent all other applications from binding to ports in this range. SELinux might be able to do that, but unfortunately I cannot use SELinux on that server (another application chokes on it).



      My second idea: somehow get iptables to open ports by executable instead of by port number. This is a feature in the Windows firewall, but I don't think I have seen a way to do this with iptables.



      What I'm looking for is ideas for implementing either of my ideas, or a third approach.







      linux iptables






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 21 mins ago









      Kevin Keane

      325111




      325111



























          active

          oldest

          votes











          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',
          autoActivateHeartbeat: false,
          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%2f491263%2fpreventing-other-applications-from-using-a-port%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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%2f491263%2fpreventing-other-applications-from-using-a-port%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

          Accessing regular linux commands in Huawei's Dopra Linux

          Can't connect RFCOMM socket: Host is down

          Kernel panic - not syncing: Fatal Exception in Interrupt