# FreeBSD kernel and duplicate MAC addresses



## m4rtin (Oct 1, 2014)

I connected Ethernet adapters of two servers running FreeBSD 9.2 like this:


```
server1[rl0] <-> [rl0]server2
```

NIC's are directly connected with crossover cable. When I configure both rl0 interfaces with the same MAC address and send ARP request from server1 to server2, then server2 will not reply. For example a Cisco router behaves the same way. Additionally, it will log "it's our address" message for each such ARP request if debugging is enabled. On the other hand, Linux 2.6 and 3.7 will reply to ARP request with an ARP reply message even if the MAC addresses on both machines are the same. Why do Linux and FreeBSD kernels behave differently? Isn't there a standard which describes how OS should handle an ARP request message is this has the same source MAC address as the receiver? I made such test in order to understand CARP and VRRP with the same VRRP GID as CARP VHID on the same broadcast domain.


----------



## usdmatt (Oct 1, 2014)

Configuring two machines with the same MAC address makes no sense and may fall into 'undefined behaviour'. I've no idea what causes Linux to get a response, it may even be coming from the local network card rather than the "remote" machine. Maybe someone else can answer that question.

When a machine sends an arp broadcast, it will send a packet with the following source and destination mac:


```
SRC:   SENDER_MAC
DEST:  FF:FF:FF:FF:FF:FF
"Who has some_ip"
```

When received by the remote machine, it will send a response to the SENDER_MAC mac (assuming it has "some_ip"), but if you've given both machines the same MAC, this will be itself... It makes no sense.

In the case of CARP, each machine has a unique IP address assigned to their interface and uses their default MAC address provided in the hardware, eg


```
Server 1: 192.168.0.1 mac 00:11:22:33:44:55
Server 2: 192.168.0.2 mac 00:11:22:33:44:66
```


When you enable CARP, one of those machines will be the master.


```
Server 1: 192.168.0.1 mac 00:11:22:33:44:55
Server 1 CARP MASTER: 192.168.0.10 mac VIRTUAL_MAC
Server 2: 192.168.0.2 mac 00:11:22:33:44:66
Server 2 CARP SLAVE: (disabled)
```

The two machines will continue to talk to each other via their real IP & MAC addresses, and you will access them individually using those details. The virtual IP & MAC are only advertised by Server 1, and only server 1 will reply to ARP requests for the CARP address. As soon as server 1 goes down, server 2 will become the master and will start responding to ARP requests for the CARP address, using the VIRTUAL_MAC.

They will never use the same MAC address at the same time.

I'm not certain exactly what you're after (whether you're just learning or planning to actually use CARP/VRRP), but if you've got multiple redundancy protocols in use on the same broadcast domain, and they happen to be trying to use the same value for their "VIRTUAL_MAC", you're almost certainly going to get problems.


----------



## SirDice (Oct 1, 2014)

ARP is defined in RFC-826 and as far as I could see there's nothing that defines its behavior when duplicate MAC addresses are involved. I would expect the driver to know the packet is being sent to itself (due to the destination MAC address) and would therefor not put it on the wire.


----------

