A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

March 31, 2015

ebtables to setup Forwarding and ethernet level NAT!


I would like to use ebtables to perform the following 2 things:

SCENARIO I: I would like to forward all the packets received from eth0 interface onto the eth1 interface. Similarly would like to forward all the reverse packets received from eth1 interface onto the eth0 interface without changing anything.


I would like to setup a NAT where eth0 is the external interface and eth1 is the internal interface where all the packets received on eth1 is forwarded to the external eth0 interface with the eth0 mac address replacing the internal network mac address and vice versa.

At IP level i can do the same like shown below:

/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

/sbin/iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT

/sbin/iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

I would like to achieve this same scenario at ethernet level?

Kindly help me out for both the above scenarios.

Click Here!