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
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
firewall bridge
add a comment |
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
firewall bridge
add a comment |
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
firewall bridge
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
firewall bridge
firewall bridge
edited 2 hours ago
gip
asked Jan 13 at 20:21
gipgip
665
665
add a comment |
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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