catch iptables logs from container to host










0














I'm trying to catch the logs generated by iptables running inside a container.
Since LOG support is disabled for container (see here), I'm trying to set the iptables log rules in the host.
I'm testing it with a rule (on the host) that catches a SYN scan from NMap (*1).



So the idea is to set iptables rules on host to log scans performed against a container (named c_victim), which is using a virtual bridged interface br-a1b2c3 (*2).



I've tried different rules similar to:



# iptables -I FORWARD -m physdev --physdev-out veth144i0 --physdev-is-bridged -j LOG --log-prefix "[fw::test]"


where veth144i0 is the virtual ethernet interface associated to br-a1b2c3 (*3). I got this rule from here.
None of the rules I tried generated logs in my host after checking with:



$ journalctl -b | grep "[fw.*]"


Any ideas on how to set the iptables rule in (*1) for a container??




(*1): Just to make sure that the rule works, I tested it in my host:



# iptables -I INPUT -p tcp -m multiport --dports 23,79 --tcp-flags ALL SYN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "[fw::syn-scan] "


then scanned the host from a container with:



root@887952fed115# nmap -sS 192.168.0.14


and then checked the logs with:



$ journalctl -b | grep "[fw.*]"


where the logs of the scan appear ok.




(*2): I know this because I checked using a combination of these commands:



$ docker container inspect c_victim | grep NetworkID 
$ docker network ls
$ ifconfig -a



(*3): I checked this by looking at the symlinks:



ls -l /sys/devices/virtual/net/veth*/master



As exploratory checks, I also set the rules (in host always):



# iptables -I FORWARD -i br-a1b2c3 -j LOG --log-prefix "[fw::test-in]"
# iptables -I FORWARD -o br-a1b2c3 -j LOG --log-prefix "[fw::test-out]"


to see what happens, and this is what I get:



  • no logs are generated if I scan the container from the host.

  • only the first one generates logs in my journalctl if I scan the host from the container c_victim.









share|improve this question


























    0














    I'm trying to catch the logs generated by iptables running inside a container.
    Since LOG support is disabled for container (see here), I'm trying to set the iptables log rules in the host.
    I'm testing it with a rule (on the host) that catches a SYN scan from NMap (*1).



    So the idea is to set iptables rules on host to log scans performed against a container (named c_victim), which is using a virtual bridged interface br-a1b2c3 (*2).



    I've tried different rules similar to:



    # iptables -I FORWARD -m physdev --physdev-out veth144i0 --physdev-is-bridged -j LOG --log-prefix "[fw::test]"


    where veth144i0 is the virtual ethernet interface associated to br-a1b2c3 (*3). I got this rule from here.
    None of the rules I tried generated logs in my host after checking with:



    $ journalctl -b | grep "[fw.*]"


    Any ideas on how to set the iptables rule in (*1) for a container??




    (*1): Just to make sure that the rule works, I tested it in my host:



    # iptables -I INPUT -p tcp -m multiport --dports 23,79 --tcp-flags ALL SYN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "[fw::syn-scan] "


    then scanned the host from a container with:



    root@887952fed115# nmap -sS 192.168.0.14


    and then checked the logs with:



    $ journalctl -b | grep "[fw.*]"


    where the logs of the scan appear ok.




    (*2): I know this because I checked using a combination of these commands:



    $ docker container inspect c_victim | grep NetworkID 
    $ docker network ls
    $ ifconfig -a



    (*3): I checked this by looking at the symlinks:



    ls -l /sys/devices/virtual/net/veth*/master



    As exploratory checks, I also set the rules (in host always):



    # iptables -I FORWARD -i br-a1b2c3 -j LOG --log-prefix "[fw::test-in]"
    # iptables -I FORWARD -o br-a1b2c3 -j LOG --log-prefix "[fw::test-out]"


    to see what happens, and this is what I get:



    • no logs are generated if I scan the container from the host.

    • only the first one generates logs in my journalctl if I scan the host from the container c_victim.









    share|improve this question
























      0












      0








      0







      I'm trying to catch the logs generated by iptables running inside a container.
      Since LOG support is disabled for container (see here), I'm trying to set the iptables log rules in the host.
      I'm testing it with a rule (on the host) that catches a SYN scan from NMap (*1).



      So the idea is to set iptables rules on host to log scans performed against a container (named c_victim), which is using a virtual bridged interface br-a1b2c3 (*2).



      I've tried different rules similar to:



      # iptables -I FORWARD -m physdev --physdev-out veth144i0 --physdev-is-bridged -j LOG --log-prefix "[fw::test]"


      where veth144i0 is the virtual ethernet interface associated to br-a1b2c3 (*3). I got this rule from here.
      None of the rules I tried generated logs in my host after checking with:



      $ journalctl -b | grep "[fw.*]"


      Any ideas on how to set the iptables rule in (*1) for a container??




      (*1): Just to make sure that the rule works, I tested it in my host:



      # iptables -I INPUT -p tcp -m multiport --dports 23,79 --tcp-flags ALL SYN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "[fw::syn-scan] "


      then scanned the host from a container with:



      root@887952fed115# nmap -sS 192.168.0.14


      and then checked the logs with:



      $ journalctl -b | grep "[fw.*]"


      where the logs of the scan appear ok.




      (*2): I know this because I checked using a combination of these commands:



      $ docker container inspect c_victim | grep NetworkID 
      $ docker network ls
      $ ifconfig -a



      (*3): I checked this by looking at the symlinks:



      ls -l /sys/devices/virtual/net/veth*/master



      As exploratory checks, I also set the rules (in host always):



      # iptables -I FORWARD -i br-a1b2c3 -j LOG --log-prefix "[fw::test-in]"
      # iptables -I FORWARD -o br-a1b2c3 -j LOG --log-prefix "[fw::test-out]"


      to see what happens, and this is what I get:



      • no logs are generated if I scan the container from the host.

      • only the first one generates logs in my journalctl if I scan the host from the container c_victim.









      share|improve this question













      I'm trying to catch the logs generated by iptables running inside a container.
      Since LOG support is disabled for container (see here), I'm trying to set the iptables log rules in the host.
      I'm testing it with a rule (on the host) that catches a SYN scan from NMap (*1).



      So the idea is to set iptables rules on host to log scans performed against a container (named c_victim), which is using a virtual bridged interface br-a1b2c3 (*2).



      I've tried different rules similar to:



      # iptables -I FORWARD -m physdev --physdev-out veth144i0 --physdev-is-bridged -j LOG --log-prefix "[fw::test]"


      where veth144i0 is the virtual ethernet interface associated to br-a1b2c3 (*3). I got this rule from here.
      None of the rules I tried generated logs in my host after checking with:



      $ journalctl -b | grep "[fw.*]"


      Any ideas on how to set the iptables rule in (*1) for a container??




      (*1): Just to make sure that the rule works, I tested it in my host:



      # iptables -I INPUT -p tcp -m multiport --dports 23,79 --tcp-flags ALL SYN -m limit --limit 3/m --limit-burst 5 -j LOG --log-prefix "[fw::syn-scan] "


      then scanned the host from a container with:



      root@887952fed115# nmap -sS 192.168.0.14


      and then checked the logs with:



      $ journalctl -b | grep "[fw.*]"


      where the logs of the scan appear ok.




      (*2): I know this because I checked using a combination of these commands:



      $ docker container inspect c_victim | grep NetworkID 
      $ docker network ls
      $ ifconfig -a



      (*3): I checked this by looking at the symlinks:



      ls -l /sys/devices/virtual/net/veth*/master



      As exploratory checks, I also set the rules (in host always):



      # iptables -I FORWARD -i br-a1b2c3 -j LOG --log-prefix "[fw::test-in]"
      # iptables -I FORWARD -o br-a1b2c3 -j LOG --log-prefix "[fw::test-out]"


      to see what happens, and this is what I get:



      • no logs are generated if I scan the container from the host.

      • only the first one generates logs in my journalctl if I scan the host from the container c_victim.






      docker networking iptables virtual-network






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 2:17









      issrcissrc

      12




      12






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53272819%2fcatch-iptables-logs-from-container-to-host%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53272819%2fcatch-iptables-logs-from-container-to-host%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







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3