How to open some port for only OpenVNP clients?












0














I have a web service on an external server, and an openvpn server on the same machine.
I need to open port 80, but only for openvpn clients. In other words, if I do nmap-p 80 server_ip I expect to see filtred. However at the same time, if I connect to the vpn and do the same command, I expect to see open.



I'm a programmer, and I don't know much about network administration. If it is possible to make a couple of rules in iptables, please tell me how to write. If it is difficult, then tell me at least in what direction to look. I can not find, on the Internet, a similar case with an explanation of how to do it.



This time, I'm trying to do this on CentOs 7 with firewalld, can it be done using firewalld, or do I need to remove it, and do it via iptables?










share|improve this question













migrated from stackoverflow.com 13 hours ago


This question came from our site for professional and enthusiast programmers.




















    0














    I have a web service on an external server, and an openvpn server on the same machine.
    I need to open port 80, but only for openvpn clients. In other words, if I do nmap-p 80 server_ip I expect to see filtred. However at the same time, if I connect to the vpn and do the same command, I expect to see open.



    I'm a programmer, and I don't know much about network administration. If it is possible to make a couple of rules in iptables, please tell me how to write. If it is difficult, then tell me at least in what direction to look. I can not find, on the Internet, a similar case with an explanation of how to do it.



    This time, I'm trying to do this on CentOs 7 with firewalld, can it be done using firewalld, or do I need to remove it, and do it via iptables?










    share|improve this question













    migrated from stackoverflow.com 13 hours ago


    This question came from our site for professional and enthusiast programmers.


















      0












      0








      0







      I have a web service on an external server, and an openvpn server on the same machine.
      I need to open port 80, but only for openvpn clients. In other words, if I do nmap-p 80 server_ip I expect to see filtred. However at the same time, if I connect to the vpn and do the same command, I expect to see open.



      I'm a programmer, and I don't know much about network administration. If it is possible to make a couple of rules in iptables, please tell me how to write. If it is difficult, then tell me at least in what direction to look. I can not find, on the Internet, a similar case with an explanation of how to do it.



      This time, I'm trying to do this on CentOs 7 with firewalld, can it be done using firewalld, or do I need to remove it, and do it via iptables?










      share|improve this question













      I have a web service on an external server, and an openvpn server on the same machine.
      I need to open port 80, but only for openvpn clients. In other words, if I do nmap-p 80 server_ip I expect to see filtred. However at the same time, if I connect to the vpn and do the same command, I expect to see open.



      I'm a programmer, and I don't know much about network administration. If it is possible to make a couple of rules in iptables, please tell me how to write. If it is difficult, then tell me at least in what direction to look. I can not find, on the Internet, a similar case with an explanation of how to do it.



      This time, I'm trying to do this on CentOs 7 with firewalld, can it be done using firewalld, or do I need to remove it, and do it via iptables?







      linux iptables openvpn firewalld






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 19 at 16:36







      Ilya Glinsky











      migrated from stackoverflow.com 13 hours ago


      This question came from our site for professional and enthusiast programmers.






      migrated from stackoverflow.com 13 hours ago


      This question came from our site for professional and enthusiast programmers.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The easy bit



          Easiest rule would be to block port 80 (and all un-used ports). Then add a rule before it to allow the local host 127.0.0.0/8 to connect to port 80.



          This will cut out most of the possibilities, at least only processes on this machine can connect.



          You can do this with the graphical fire-wall tool gufw. gufw is possibly the simplest file-wall tool, it can't do everything, but is simple, and can do a lot.



          The harder bit



          Next you need to stop processes on the machine connecting. But allow processes from the VPN user to connect, then run the VPN as a separate VPN user. (You can only control out-going connections by user.



          I don't know of an easy tool that can do this, (I am not a firewall expert) but you can do it my editing iptables.



          Do you have to remove firewalld?



          I have not used filewalld, however I have used gufw, and directly edited iptable. I have not seen any conflicts.






          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',
            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%2f490461%2fhow-to-open-some-port-for-only-openvnp-clients%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









            0














            The easy bit



            Easiest rule would be to block port 80 (and all un-used ports). Then add a rule before it to allow the local host 127.0.0.0/8 to connect to port 80.



            This will cut out most of the possibilities, at least only processes on this machine can connect.



            You can do this with the graphical fire-wall tool gufw. gufw is possibly the simplest file-wall tool, it can't do everything, but is simple, and can do a lot.



            The harder bit



            Next you need to stop processes on the machine connecting. But allow processes from the VPN user to connect, then run the VPN as a separate VPN user. (You can only control out-going connections by user.



            I don't know of an easy tool that can do this, (I am not a firewall expert) but you can do it my editing iptables.



            Do you have to remove firewalld?



            I have not used filewalld, however I have used gufw, and directly edited iptable. I have not seen any conflicts.






            share|improve this answer


























              0














              The easy bit



              Easiest rule would be to block port 80 (and all un-used ports). Then add a rule before it to allow the local host 127.0.0.0/8 to connect to port 80.



              This will cut out most of the possibilities, at least only processes on this machine can connect.



              You can do this with the graphical fire-wall tool gufw. gufw is possibly the simplest file-wall tool, it can't do everything, but is simple, and can do a lot.



              The harder bit



              Next you need to stop processes on the machine connecting. But allow processes from the VPN user to connect, then run the VPN as a separate VPN user. (You can only control out-going connections by user.



              I don't know of an easy tool that can do this, (I am not a firewall expert) but you can do it my editing iptables.



              Do you have to remove firewalld?



              I have not used filewalld, however I have used gufw, and directly edited iptable. I have not seen any conflicts.






              share|improve this answer
























                0












                0








                0






                The easy bit



                Easiest rule would be to block port 80 (and all un-used ports). Then add a rule before it to allow the local host 127.0.0.0/8 to connect to port 80.



                This will cut out most of the possibilities, at least only processes on this machine can connect.



                You can do this with the graphical fire-wall tool gufw. gufw is possibly the simplest file-wall tool, it can't do everything, but is simple, and can do a lot.



                The harder bit



                Next you need to stop processes on the machine connecting. But allow processes from the VPN user to connect, then run the VPN as a separate VPN user. (You can only control out-going connections by user.



                I don't know of an easy tool that can do this, (I am not a firewall expert) but you can do it my editing iptables.



                Do you have to remove firewalld?



                I have not used filewalld, however I have used gufw, and directly edited iptable. I have not seen any conflicts.






                share|improve this answer












                The easy bit



                Easiest rule would be to block port 80 (and all un-used ports). Then add a rule before it to allow the local host 127.0.0.0/8 to connect to port 80.



                This will cut out most of the possibilities, at least only processes on this machine can connect.



                You can do this with the graphical fire-wall tool gufw. gufw is possibly the simplest file-wall tool, it can't do everything, but is simple, and can do a lot.



                The harder bit



                Next you need to stop processes on the machine connecting. But allow processes from the VPN user to connect, then run the VPN as a separate VPN user. (You can only control out-going connections by user.



                I don't know of an easy tool that can do this, (I am not a firewall expert) but you can do it my editing iptables.



                Do you have to remove firewalld?



                I have not used filewalld, however I have used gufw, and directly edited iptable. I have not seen any conflicts.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 19 at 16:45









                ctrl-alt-delor

                10.6k41955




                10.6k41955






























                    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%2f490461%2fhow-to-open-some-port-for-only-openvnp-clients%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

                    Entries order in /etc/network/interfaces

                    新発田市

                    Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)