Create a service that logs all input











up vote
1
down vote

favorite












I need to create a service that logs all input on a certain port to a file. Do I have to create a custom program for this, or is there an already existing tool out there?










share|improve this question
























  • I have updated the question for RHEL base system, if you are using any other version let me know , I will update that also..
    – Rahul Patil
    Jul 8 '13 at 19:46















up vote
1
down vote

favorite












I need to create a service that logs all input on a certain port to a file. Do I have to create a custom program for this, or is there an already existing tool out there?










share|improve this question
























  • I have updated the question for RHEL base system, if you are using any other version let me know , I will update that also..
    – Rahul Patil
    Jul 8 '13 at 19:46













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I need to create a service that logs all input on a certain port to a file. Do I have to create a custom program for this, or is there an already existing tool out there?










share|improve this question















I need to create a service that logs all input on a certain port to a file. Do I have to create a custom program for this, or is there an already existing tool out there?







linux networking services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 at 19:40









Rui F Ribeiro

38.3k1476127




38.3k1476127










asked Jul 8 '13 at 18:12









Brett G

1084




1084












  • I have updated the question for RHEL base system, if you are using any other version let me know , I will update that also..
    – Rahul Patil
    Jul 8 '13 at 19:46


















  • I have updated the question for RHEL base system, if you are using any other version let me know , I will update that also..
    – Rahul Patil
    Jul 8 '13 at 19:46
















I have updated the question for RHEL base system, if you are using any other version let me know , I will update that also..
– Rahul Patil
Jul 8 '13 at 19:46




I have updated the question for RHEL base system, if you are using any other version let me know , I will update that also..
– Rahul Patil
Jul 8 '13 at 19:46










3 Answers
3






active

oldest

votes

















up vote
3
down vote



accepted










With help of IPtables and Syslog , we can logs all input on a certain port to a file.



IPtables default log file is /var/log/messages in RHEL based System and /var/log/syslog in Debian base system. we can log details to different log file.



Open your /etc/syslog.conf and Append following lines



kern.warning   /var/log/iptables.log


after adding , you have to restart syslog service to reflect changes using :



/etc/init.d/syslog restart


Now suppose you want to log port 80 , then just add below rule :



 iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 4


Now just tail the logs and see



tail -f /var/log/iptables.log


To save rule :



/etc/init.d/iptables save


and enable required services at Start-up



chkconfig --level 35 iptables on
chkconfig --level 35 syslog on





share|improve this answer




























    up vote
    0
    down vote













    There are a few tools out there but one of the most common is rsyslog. It's almost undoubtedly available in your distribution's package repository or you could of course build it from source.



    The daemon usually listens on port 514 UDP and accepts UDP packets which are then put into specific log files based on rulesets specified in your rsyslog configuration.






    share|improve this answer




























      up vote
      0
      down vote













      It think also tcpdump could be handy here. (It is not limited to TCP)






      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%2f82236%2fcreate-a-service-that-logs-all-input%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        3
        down vote



        accepted










        With help of IPtables and Syslog , we can logs all input on a certain port to a file.



        IPtables default log file is /var/log/messages in RHEL based System and /var/log/syslog in Debian base system. we can log details to different log file.



        Open your /etc/syslog.conf and Append following lines



        kern.warning   /var/log/iptables.log


        after adding , you have to restart syslog service to reflect changes using :



        /etc/init.d/syslog restart


        Now suppose you want to log port 80 , then just add below rule :



         iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 4


        Now just tail the logs and see



        tail -f /var/log/iptables.log


        To save rule :



        /etc/init.d/iptables save


        and enable required services at Start-up



        chkconfig --level 35 iptables on
        chkconfig --level 35 syslog on





        share|improve this answer

























          up vote
          3
          down vote



          accepted










          With help of IPtables and Syslog , we can logs all input on a certain port to a file.



          IPtables default log file is /var/log/messages in RHEL based System and /var/log/syslog in Debian base system. we can log details to different log file.



          Open your /etc/syslog.conf and Append following lines



          kern.warning   /var/log/iptables.log


          after adding , you have to restart syslog service to reflect changes using :



          /etc/init.d/syslog restart


          Now suppose you want to log port 80 , then just add below rule :



           iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 4


          Now just tail the logs and see



          tail -f /var/log/iptables.log


          To save rule :



          /etc/init.d/iptables save


          and enable required services at Start-up



          chkconfig --level 35 iptables on
          chkconfig --level 35 syslog on





          share|improve this answer























            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            With help of IPtables and Syslog , we can logs all input on a certain port to a file.



            IPtables default log file is /var/log/messages in RHEL based System and /var/log/syslog in Debian base system. we can log details to different log file.



            Open your /etc/syslog.conf and Append following lines



            kern.warning   /var/log/iptables.log


            after adding , you have to restart syslog service to reflect changes using :



            /etc/init.d/syslog restart


            Now suppose you want to log port 80 , then just add below rule :



             iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 4


            Now just tail the logs and see



            tail -f /var/log/iptables.log


            To save rule :



            /etc/init.d/iptables save


            and enable required services at Start-up



            chkconfig --level 35 iptables on
            chkconfig --level 35 syslog on





            share|improve this answer












            With help of IPtables and Syslog , we can logs all input on a certain port to a file.



            IPtables default log file is /var/log/messages in RHEL based System and /var/log/syslog in Debian base system. we can log details to different log file.



            Open your /etc/syslog.conf and Append following lines



            kern.warning   /var/log/iptables.log


            after adding , you have to restart syslog service to reflect changes using :



            /etc/init.d/syslog restart


            Now suppose you want to log port 80 , then just add below rule :



             iptables -A INPUT -p tcp --dport 80 -j LOG --log-level 4


            Now just tail the logs and see



            tail -f /var/log/iptables.log


            To save rule :



            /etc/init.d/iptables save


            and enable required services at Start-up



            chkconfig --level 35 iptables on
            chkconfig --level 35 syslog on






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 8 '13 at 19:43









            Rahul Patil

            14.6k185982




            14.6k185982
























                up vote
                0
                down vote













                There are a few tools out there but one of the most common is rsyslog. It's almost undoubtedly available in your distribution's package repository or you could of course build it from source.



                The daemon usually listens on port 514 UDP and accepts UDP packets which are then put into specific log files based on rulesets specified in your rsyslog configuration.






                share|improve this answer

























                  up vote
                  0
                  down vote













                  There are a few tools out there but one of the most common is rsyslog. It's almost undoubtedly available in your distribution's package repository or you could of course build it from source.



                  The daemon usually listens on port 514 UDP and accepts UDP packets which are then put into specific log files based on rulesets specified in your rsyslog configuration.






                  share|improve this answer























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    There are a few tools out there but one of the most common is rsyslog. It's almost undoubtedly available in your distribution's package repository or you could of course build it from source.



                    The daemon usually listens on port 514 UDP and accepts UDP packets which are then put into specific log files based on rulesets specified in your rsyslog configuration.






                    share|improve this answer












                    There are a few tools out there but one of the most common is rsyslog. It's almost undoubtedly available in your distribution's package repository or you could of course build it from source.



                    The daemon usually listens on port 514 UDP and accepts UDP packets which are then put into specific log files based on rulesets specified in your rsyslog configuration.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 8 '13 at 18:27









                    j883376

                    1,5331112




                    1,5331112






















                        up vote
                        0
                        down vote













                        It think also tcpdump could be handy here. (It is not limited to TCP)






                        share|improve this answer

























                          up vote
                          0
                          down vote













                          It think also tcpdump could be handy here. (It is not limited to TCP)






                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            It think also tcpdump could be handy here. (It is not limited to TCP)






                            share|improve this answer












                            It think also tcpdump could be handy here. (It is not limited to TCP)







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jul 8 '13 at 19:09









                            Alois Mahdal

                            1,87232846




                            1,87232846






























                                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%2f82236%2fcreate-a-service-that-logs-all-input%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

                                List directoties down one level, excluding some named directories and files

                                list processes belonging to a network namespace

                                list systemd RuntimeDirectory mounts