Routing and filtering on Linux

Clash Royale CLAN TAG#URR8PPP
I have a VM with two interfaces, eth0 and eth1. I would like packets coming in from eth0 to be processed and if they don't match any rule, get dropped. If they match a rule, then I want them to be forwarded to eth1 without any modification. In other words, source and destination ip of a forwarded packet must remain the same as when they entered in eth0. I was thinking about using iptables for all this process but I am starting to think that the forwarding part, without modifying the packet, is not possible. Can anybody confirm this?
linux networking iptables firewall
add a comment |
I have a VM with two interfaces, eth0 and eth1. I would like packets coming in from eth0 to be processed and if they don't match any rule, get dropped. If they match a rule, then I want them to be forwarded to eth1 without any modification. In other words, source and destination ip of a forwarded packet must remain the same as when they entered in eth0. I was thinking about using iptables for all this process but I am starting to think that the forwarding part, without modifying the packet, is not possible. Can anybody confirm this?
linux networking iptables firewall
What have you tried so far? Why do you think it is not possible to forward a packet?
– RalfFriedl
Jan 22 at 17:52
What kind of rule? Forwarding without modifying packets is standard behaviour
– Torin
Jan 22 at 17:58
Both eth0 and eth1 are in the same L2 network. I wonder how the packet could be forwarded from one to the other
– M. Buil
Jan 22 at 22:15
I removed the ip in eth0 and set it to promiscuous. Activated forwarding, checked that the ip route rule points to eth1 and tried. Packets arrive to eth0 but they don't leave through eth1
– M. Buil
Jan 23 at 9:32
add a comment |
I have a VM with two interfaces, eth0 and eth1. I would like packets coming in from eth0 to be processed and if they don't match any rule, get dropped. If they match a rule, then I want them to be forwarded to eth1 without any modification. In other words, source and destination ip of a forwarded packet must remain the same as when they entered in eth0. I was thinking about using iptables for all this process but I am starting to think that the forwarding part, without modifying the packet, is not possible. Can anybody confirm this?
linux networking iptables firewall
I have a VM with two interfaces, eth0 and eth1. I would like packets coming in from eth0 to be processed and if they don't match any rule, get dropped. If they match a rule, then I want them to be forwarded to eth1 without any modification. In other words, source and destination ip of a forwarded packet must remain the same as when they entered in eth0. I was thinking about using iptables for all this process but I am starting to think that the forwarding part, without modifying the packet, is not possible. Can anybody confirm this?
linux networking iptables firewall
linux networking iptables firewall
edited Jan 23 at 21:19
Community♦
1
1
asked Jan 22 at 17:06
M. BuilM. Buil
1
1
What have you tried so far? Why do you think it is not possible to forward a packet?
– RalfFriedl
Jan 22 at 17:52
What kind of rule? Forwarding without modifying packets is standard behaviour
– Torin
Jan 22 at 17:58
Both eth0 and eth1 are in the same L2 network. I wonder how the packet could be forwarded from one to the other
– M. Buil
Jan 22 at 22:15
I removed the ip in eth0 and set it to promiscuous. Activated forwarding, checked that the ip route rule points to eth1 and tried. Packets arrive to eth0 but they don't leave through eth1
– M. Buil
Jan 23 at 9:32
add a comment |
What have you tried so far? Why do you think it is not possible to forward a packet?
– RalfFriedl
Jan 22 at 17:52
What kind of rule? Forwarding without modifying packets is standard behaviour
– Torin
Jan 22 at 17:58
Both eth0 and eth1 are in the same L2 network. I wonder how the packet could be forwarded from one to the other
– M. Buil
Jan 22 at 22:15
I removed the ip in eth0 and set it to promiscuous. Activated forwarding, checked that the ip route rule points to eth1 and tried. Packets arrive to eth0 but they don't leave through eth1
– M. Buil
Jan 23 at 9:32
What have you tried so far? Why do you think it is not possible to forward a packet?
– RalfFriedl
Jan 22 at 17:52
What have you tried so far? Why do you think it is not possible to forward a packet?
– RalfFriedl
Jan 22 at 17:52
What kind of rule? Forwarding without modifying packets is standard behaviour
– Torin
Jan 22 at 17:58
What kind of rule? Forwarding without modifying packets is standard behaviour
– Torin
Jan 22 at 17:58
Both eth0 and eth1 are in the same L2 network. I wonder how the packet could be forwarded from one to the other
– M. Buil
Jan 22 at 22:15
Both eth0 and eth1 are in the same L2 network. I wonder how the packet could be forwarded from one to the other
– M. Buil
Jan 22 at 22:15
I removed the ip in eth0 and set it to promiscuous. Activated forwarding, checked that the ip route rule points to eth1 and tried. Packets arrive to eth0 but they don't leave through eth1
– M. Buil
Jan 23 at 9:32
I removed the ip in eth0 and set it to promiscuous. Activated forwarding, checked that the ip route rule points to eth1 and tried. Packets arrive to eth0 but they don't leave through eth1
– M. Buil
Jan 23 at 9:32
add a comment |
1 Answer
1
active
oldest
votes
Enable routing on Linux:
IPv4
/proc/sys/net/ipv4/conf/all/forwarding
IPv6
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
You can also configure this per network adapter instead of globally (replace all with the name of the network adapter). Note that this change does not persist across reboots. To have these applied at boot, you can configure them in /etc/sysctl.conf.
You also should be aware of rp_filter parameter (reverse path filtering).
After IP forwarding is enabled, you can filter forwarded packets by adding rules in iptables (and ip6tables) FORWARD chain.
I forgot to say that both interfaces are in the same L2 network, therefore, I guess that by just enabling routing in Linux ist not going to be enough
– M. Buil
Jan 22 at 22:13
add a comment |
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%2f496013%2frouting-and-filtering-on-linux%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
Enable routing on Linux:
IPv4
/proc/sys/net/ipv4/conf/all/forwarding
IPv6
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
You can also configure this per network adapter instead of globally (replace all with the name of the network adapter). Note that this change does not persist across reboots. To have these applied at boot, you can configure them in /etc/sysctl.conf.
You also should be aware of rp_filter parameter (reverse path filtering).
After IP forwarding is enabled, you can filter forwarded packets by adding rules in iptables (and ip6tables) FORWARD chain.
I forgot to say that both interfaces are in the same L2 network, therefore, I guess that by just enabling routing in Linux ist not going to be enough
– M. Buil
Jan 22 at 22:13
add a comment |
Enable routing on Linux:
IPv4
/proc/sys/net/ipv4/conf/all/forwarding
IPv6
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
You can also configure this per network adapter instead of globally (replace all with the name of the network adapter). Note that this change does not persist across reboots. To have these applied at boot, you can configure them in /etc/sysctl.conf.
You also should be aware of rp_filter parameter (reverse path filtering).
After IP forwarding is enabled, you can filter forwarded packets by adding rules in iptables (and ip6tables) FORWARD chain.
I forgot to say that both interfaces are in the same L2 network, therefore, I guess that by just enabling routing in Linux ist not going to be enough
– M. Buil
Jan 22 at 22:13
add a comment |
Enable routing on Linux:
IPv4
/proc/sys/net/ipv4/conf/all/forwarding
IPv6
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
You can also configure this per network adapter instead of globally (replace all with the name of the network adapter). Note that this change does not persist across reboots. To have these applied at boot, you can configure them in /etc/sysctl.conf.
You also should be aware of rp_filter parameter (reverse path filtering).
After IP forwarding is enabled, you can filter forwarded packets by adding rules in iptables (and ip6tables) FORWARD chain.
Enable routing on Linux:
IPv4
/proc/sys/net/ipv4/conf/all/forwarding
IPv6
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
You can also configure this per network adapter instead of globally (replace all with the name of the network adapter). Note that this change does not persist across reboots. To have these applied at boot, you can configure them in /etc/sysctl.conf.
You also should be aware of rp_filter parameter (reverse path filtering).
After IP forwarding is enabled, you can filter forwarded packets by adding rules in iptables (and ip6tables) FORWARD chain.
answered Jan 22 at 17:38
sebasthsebasth
8,31632046
8,31632046
I forgot to say that both interfaces are in the same L2 network, therefore, I guess that by just enabling routing in Linux ist not going to be enough
– M. Buil
Jan 22 at 22:13
add a comment |
I forgot to say that both interfaces are in the same L2 network, therefore, I guess that by just enabling routing in Linux ist not going to be enough
– M. Buil
Jan 22 at 22:13
I forgot to say that both interfaces are in the same L2 network, therefore, I guess that by just enabling routing in Linux ist not going to be enough
– M. Buil
Jan 22 at 22:13
I forgot to say that both interfaces are in the same L2 network, therefore, I guess that by just enabling routing in Linux ist not going to be enough
– M. Buil
Jan 22 at 22:13
add a comment |
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%2f496013%2frouting-and-filtering-on-linux%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
What have you tried so far? Why do you think it is not possible to forward a packet?
– RalfFriedl
Jan 22 at 17:52
What kind of rule? Forwarding without modifying packets is standard behaviour
– Torin
Jan 22 at 17:58
Both eth0 and eth1 are in the same L2 network. I wonder how the packet could be forwarded from one to the other
– M. Buil
Jan 22 at 22:15
I removed the ip in eth0 and set it to promiscuous. Activated forwarding, checked that the ip route rule points to eth1 and tried. Packets arrive to eth0 but they don't leave through eth1
– M. Buil
Jan 23 at 9:32