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?
Enable routing on Linux:
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
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)