Is there any particular reason why Ethernet switches don't change the MAC address of a packet?
Is it for end host identification using the MAC address, or anything else?
Network Engineering Stack Exchange is a question and answer site for network engineers. It only takes a minute to sign up.
Sign up to join this communityIs there any particular reason why Ethernet switches don't change the MAC address of a packet?
Is it for end host identification using the MAC address, or anything else?
If a switch were to change MAC addresses, this would break networking entirely.
The MAC address is a unique identifier which is used by hosts on the local network.
If the switch were to change the destination MAC, the frame would not get delivered to the appropriate host. In the cases that it would, for example if the frame gets flooded, the destination host would drop it because it would no longer be destined for the host.
If the switch were to change the source MAC address, the destination host would use this MAC address for any responses (including updating any ARP entries with bad data). This would result in the same situation I already described, just for all return traffic.
This could further create problems with things like 802.1X and other mechanisms that use the MAC address to identify/classify the device.
Could mechanisms be developed to do this? I am sure they could. But there is no reason to do so at this point and this would only complicate networking and add unnecessary processing. We are not close to exhausting the available MAC address pool so there is no need for something like MAT (don't know if the concept of MAC address translation even exists anywhere so maybe I just coined a term?).
Rewrites of addresses of datagrams happens at layer 3 for example when gateways (router or firewall) running NAT rewrites IP addresses of hosts on the inside network so they all appear from one (or a few) external IP addresses on the gateway itself.
The reason for something similar not happening at the layer 2 level (where we use MAC addresses to distinguish hosts and switches do the movement of datagrams, that is frames) is as said in comments above that there really is no need for it.
In the layer three case with NAT, the NAT solves a number of problems:
So, if we stick with the NAT example, there is really no need for a layer two counterpart of NAT.
Hope this shed some light over why switches do not rewrite MAC addresses. The only layer 3 case I came up with from the top of my head was NAT, others certainly can provide example of other layer 3 cases where IP rewrites are warranted (and why those technologies don't really make sense on the layer 2 level).
Rewriting the MAC address would add considerable complexity (the switch would have to know about higher level protocols like arp so it could rewrite address resoloution), would make troubleshooting harder, would prevent protocols like STP from working and would generally be a PITA. It's also not normally needed.
Which is not to say it's not possible. ebtables (the layer 2 counterpart to iptables) does have some options for MAC address translation. This can be useful if you have switches that don't use per-vlan MAC tables and you want to do some layer 2 filtering.