Linux bridge SNAT with ebtables2019 Community Moderator ElectionUsing a bridge, an LXC container can't ping router, but the host OS cantc on bridge portBridge interfaces with Vlan on Linux based access pointPackets not moving through linux ethernet bridgePacket flow in a virtual bridge with two interfaces, centos 7VM host management in case of Linux bridgeWhy assign MAC and IP addresses on Bridge interfaceiptables not filtering bridged trafficDoes ping omit iptables / postrouting rulesLinux bridge stops working after adding 2nd interface

Latex does not go to next line

Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?

Linux Ubuntu 18.04 Full Backup

Do f-stop and exposure time perfectly cancel?

Is there a difference between equilibrium and steady state?

Child Theme Path Being Ignored With wp_enqueue_scripts

How to draw cubes in a 3 dimensional plane

Why the color red for the Republican Party

How is the wildcard * interpreted as a command?

Why was Goose renamed from Chewie for the Captain Marvel film?

Why is computing ridge regression with a Cholesky decomposition much quicker than using SVD?

How did Alan Turing break the enigma code using the hint given by the lady in the bar?

Conservation of Mass and Energy

Is "conspicuously missing" or "conspicuously" the subject of this sentence?

Coax or bifilar choke

Database Backup for data and log files

Death from old age has stopped, but fertility window is the same. What is the new population equlibrium?

If I receive a SOS signal, what is the proper response?

How can I get players to stop ignoring or overlooking the plot hooks I'm giving them?

Find longest word in a string: are any of these algorithms good?

Sort with one element at the end

How many characters using PHB rules does it take to be able to have access to any PHB spell at the start of an adventuring day?

Why does liquid water form when we exhale on a mirror?

How are showroom/display vehicles prepared?



Linux bridge SNAT with ebtables



2019 Community Moderator ElectionUsing a bridge, an LXC container can't ping router, but the host OS cantc on bridge portBridge interfaces with Vlan on Linux based access pointPackets not moving through linux ethernet bridgePacket flow in a virtual bridge with two interfaces, centos 7VM host management in case of Linux bridgeWhy assign MAC and IP addresses on Bridge interfaceiptables not filtering bridged trafficDoes ping omit iptables / postrouting rulesLinux bridge stops working after adding 2nd interface










4















I was reading the following code (dot1x bridge bypass):
https://github.com/mubix/8021xbridge/blob/master/scripts/trans_bridge.prepop



A quick description, we have 2 interfaces, the first is connected to a switch ($SWINT) and the other to our target host. The goal is to
interact with the rest of the network, while making it look like the traffic is generated by the target host.



From the referenced code, what I am trying to figure out is why both of the below commands are needed:



# use ebtables to source NAT the $COMPMAC for traffic leaving the device from the bridge mac address
(A)ebtables -t nat -A POSTROUTING -s $SWMAC -o $SWINT -j snat --to-src $COMPMAC
(B)ebtables -t nat -A POSTROUTING -s $SWMAC -o $BRINT -j snat --to-src $COMPMAC


I don't get why it's needed to SNAT the POSTROUTING traffic of $BRINT. Since our goal is to avoid transmitting any frames towards switch side interface with source MAC different than the target host, shouldn't the first ebtables rule be suffice?



Or in other words, isn't $SWINT (switch side interface) the only way any frames are getting to the switch? Based on the diagram below, the rule (B) looks redundant since we only care for frames going towards eth0 (SWINT), and we already apply SNAT to eth0.



Some good resources I found on bridges (but still haven't answered my question) are:



Understanding Linux Network Internals



Anatomy of Linux Bridge



ebtables with Linux Bridge



https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page:359
https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page 359










share|improve this question




























    4















    I was reading the following code (dot1x bridge bypass):
    https://github.com/mubix/8021xbridge/blob/master/scripts/trans_bridge.prepop



    A quick description, we have 2 interfaces, the first is connected to a switch ($SWINT) and the other to our target host. The goal is to
    interact with the rest of the network, while making it look like the traffic is generated by the target host.



    From the referenced code, what I am trying to figure out is why both of the below commands are needed:



    # use ebtables to source NAT the $COMPMAC for traffic leaving the device from the bridge mac address
    (A)ebtables -t nat -A POSTROUTING -s $SWMAC -o $SWINT -j snat --to-src $COMPMAC
    (B)ebtables -t nat -A POSTROUTING -s $SWMAC -o $BRINT -j snat --to-src $COMPMAC


    I don't get why it's needed to SNAT the POSTROUTING traffic of $BRINT. Since our goal is to avoid transmitting any frames towards switch side interface with source MAC different than the target host, shouldn't the first ebtables rule be suffice?



    Or in other words, isn't $SWINT (switch side interface) the only way any frames are getting to the switch? Based on the diagram below, the rule (B) looks redundant since we only care for frames going towards eth0 (SWINT), and we already apply SNAT to eth0.



    Some good resources I found on bridges (but still haven't answered my question) are:



    Understanding Linux Network Internals



    Anatomy of Linux Bridge



    ebtables with Linux Bridge



    https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page:359
    https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page 359










    share|improve this question


























      4












      4








      4








      I was reading the following code (dot1x bridge bypass):
      https://github.com/mubix/8021xbridge/blob/master/scripts/trans_bridge.prepop



      A quick description, we have 2 interfaces, the first is connected to a switch ($SWINT) and the other to our target host. The goal is to
      interact with the rest of the network, while making it look like the traffic is generated by the target host.



      From the referenced code, what I am trying to figure out is why both of the below commands are needed:



      # use ebtables to source NAT the $COMPMAC for traffic leaving the device from the bridge mac address
      (A)ebtables -t nat -A POSTROUTING -s $SWMAC -o $SWINT -j snat --to-src $COMPMAC
      (B)ebtables -t nat -A POSTROUTING -s $SWMAC -o $BRINT -j snat --to-src $COMPMAC


      I don't get why it's needed to SNAT the POSTROUTING traffic of $BRINT. Since our goal is to avoid transmitting any frames towards switch side interface with source MAC different than the target host, shouldn't the first ebtables rule be suffice?



      Or in other words, isn't $SWINT (switch side interface) the only way any frames are getting to the switch? Based on the diagram below, the rule (B) looks redundant since we only care for frames going towards eth0 (SWINT), and we already apply SNAT to eth0.



      Some good resources I found on bridges (but still haven't answered my question) are:



      Understanding Linux Network Internals



      Anatomy of Linux Bridge



      ebtables with Linux Bridge



      https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page:359
      https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page 359










      share|improve this question
















      I was reading the following code (dot1x bridge bypass):
      https://github.com/mubix/8021xbridge/blob/master/scripts/trans_bridge.prepop



      A quick description, we have 2 interfaces, the first is connected to a switch ($SWINT) and the other to our target host. The goal is to
      interact with the rest of the network, while making it look like the traffic is generated by the target host.



      From the referenced code, what I am trying to figure out is why both of the below commands are needed:



      # use ebtables to source NAT the $COMPMAC for traffic leaving the device from the bridge mac address
      (A)ebtables -t nat -A POSTROUTING -s $SWMAC -o $SWINT -j snat --to-src $COMPMAC
      (B)ebtables -t nat -A POSTROUTING -s $SWMAC -o $BRINT -j snat --to-src $COMPMAC


      I don't get why it's needed to SNAT the POSTROUTING traffic of $BRINT. Since our goal is to avoid transmitting any frames towards switch side interface with source MAC different than the target host, shouldn't the first ebtables rule be suffice?



      Or in other words, isn't $SWINT (switch side interface) the only way any frames are getting to the switch? Based on the diagram below, the rule (B) looks redundant since we only care for frames going towards eth0 (SWINT), and we already apply SNAT to eth0.



      Some good resources I found on bridges (but still haven't answered my question) are:



      Understanding Linux Network Internals



      Anatomy of Linux Bridge



      ebtables with Linux Bridge



      https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page:359
      https://doc.lagout.org/operating%20system%20/linux/Understanding%20Linux%20Network%20Internals.pdf Page 359







      firewall bridge






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago







      gip

















      asked Jan 13 at 20:21









      gipgip

      665




      665




















          0






          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%2f494302%2flinux-bridge-snat-with-ebtables%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 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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494302%2flinux-bridge-snat-with-ebtables%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







          -bridge, firewall

          Popular posts from this blog

          Creating 100m^2 grid automatically using QGIS?Creating grid constrained within polygon in QGIS?Createing polygon layer from point data using QGIS?Creating vector grid using QGIS?Creating grid polygons from coordinates using R or PythonCreating grid from spatio temporal point data?Creating fields in attributes table using other layers using QGISCreate .shp vector grid in QGISQGIS Creating 4km point grid within polygonsCreate a vector grid over a raster layerVector Grid Creates just one grid

          Word for a person who has no opinion about whether god existsWord for having a definite opinion while simultaneously withholding judgment?What's the opposite of “newcomer? Is ”veteran" OK?What do you call an “atheist” who might believe in an afterlife?What's a word for someone who wants to voice opinions but not have them challenged?Word for someone who dismisses contrary opinions as irrational?Somone who thinks they are overly special/out of the ordinaryIs there a word, phrase or idiom for “a person who is incapable of thinking about the future”?The belief that a god is human-likeA word for a non-famous person/thing you have heard a lot aboutAdjective for a person who enjoys taking care of their appearance

          Can I redirect output to a log file and background a process at the same time?2019 Community Moderator ElectionUnable to write to file in shell script when running command in backgroundredirect and log script outputhow to properly log the output of a console program that frequently updates “parts” of the screen, resulting in a messy log file?How can I redirect the output of a child process?grep script - output lines at the same time into echoHow to run process in background and get its pid to create log file nameHow to redirect output to a log from expect commandHow to clear a redirect log file content in shell?Log background jobs started in all the manually started shells?Why do `jobs` and `dirs` run in command subsitution, process substitution, pipeline, and background jobs output the same as in original shell?How to redirect output to file to STDOUT?