L2 nat

Hi All,

Is there any possibility to change the IP address of a package according to its MAC address. It would be a sort of L2 NAT. (i.e. If the MAC address is 00:1A:A0:1E:XX:XX so the dir IP will be 192.168.X.X)

Thanks!.

If you are using IPTABLES you could try the following:

iptables -A PREROUTE -m  mac --mac-source <MAC> -j SNAT <IP>

You could change preroute to what ever you need.

Thanks Lazydog,

I executed the following command, but unfortunately it did not work. :frowning:

iptables -A -m mac --mac-source 00:80:42:1D:DA:0F -j SNAT --to-source 172.16.1.220

iptables: Invalid argument

thanks.

Somebody know how I can use iptables and ebtables in order to change the IP address of the package according to its MAC.

thanks.

Sorry, try this;

iptables -A PREROUTE -i <IFACE> -m  mac --mac-source <MAC> -j SNAT <IP>