Multiple MAC addresses on one physical network interface (linux)

ip addresslinux-networkingmac address

Simple question:
How can I setup multiple MAC addresses on one physical network interface (linux)?

Why?
My ISP is checking ip<->mac on GW and I d like to route traffic through my "linuxbox" and than forward it with different source ip.

Without checking ip<->mac, I will use eth0, eth0:0, but in this situation I need unique MAC address for every IP.

Best Answer

You can use macvlan to create multiple virtual interfaces with different MAC addresses.

ip link add link eth0 address 00:11:11:11:11:11 eth0.1 type macvlan
ip link add link eth0 address 00:22:22:22:22:22 eth0.2 type macvlan

In theory that should be all you need, though at some point something broke in the kernel and it would cause it to use one MAC for everything. I'm not sure what the status of that is; hopefully it's fixed.

If not, you could use arptables to rewrite the MAC addresses on output based on the egress interface or on input based on destination IP:

arptables -A OUT -o eth0.1 --arhln 06 -j mangle --mangle-hw-s 00:11:11:11:11:11
arptables -A OUT -o eth0.2 --arhln 06 -j mangle --mangle-hw-s 00:22:22:22:22:22
arptables -A IN -d 192.168.1.1 --arhln 06 -j mangle --mangle-hw-d 00:11:11:11:11:11
arptables -A IN -d 192.168.1.2 --arhln 06 -j mangle --mangle-hw-d 00:22:22:22:22:22

Unfortunately arptables is also quite buggy in my experience.