Do nodes in a single-switch ethernet network governed by dnsmasq communicate directly, or via the router?

Variations on this question exist, but I cannot be certain my exact situation has been asked.

I am setting up a simple ethernet network that looks like this:

enter image description here

On Node 0 ("rpi1") I am running dnsmasq as both a DNS and DHCP server. Here is a section of its /etc/dnsmasq.conf (minus the MAC Address details):

# Assign static IPs to cluster members
# Format = MAC:hostname:IP
dhcp-host=ZZ:YY:XX:WW:VV:UU,rpi1,10.0.0.1 # Node 0
dhcp-host=ZZ:YY:XX:WW:VV:UU,rpi2,10.0.0.2 # Node 1
dhcp-host=ZZ:YY:XX:WW:VV:UU,rpi3,10.0.0.3 # Node 2
dhcp-host=ZZ:YY:XX:WW:VV:UU,rpi4,10.0.0.4 # Node 3

Both the DNS and DHCP aspects are working. Each node is getting assigned its intended 10.0.0.X IP Address, and I can resolve any domain on any node by running e.g. dig rpi4 (-> ... 10.0.0.4). And, for example, if I am inside rpi2 then I can get into rpi3 with ssh rpi3, and I can e.g. ping rpi4 or ping 10.0.0.4 and get 0% packet loss.

What is not clear to me though is whether I am communicating between nodes directly through the switch, or via rpi1 (which is operating dnsmasq and providing router services).

If the nodes are communicating directly then I assume they must know each other's MAC address in order to emit frames that go directly to each other through the switch. If that is so, then my questions in summary are:

  1. At what point does a node learn the MAC addresses of the other nodes?
  2. And how can I examine the MAC address of e.g. rpi3 on rpi2 to see that they have learned of each other?

Thanks in advance!


At what point does a node learn the MAC addresses of the other nodes?

First they will inquire about the IP address of other nodes from the DNS server. After that, they will send 'arp' request to all the nodes, and the node which has the IP address will reply to that 'arp' request with its MAC address.

And how can I examine the MAC address of e.g. rpi3 on rpi2 to see that they have learned of each other?

'arp -a' will usually give you arp table, and you can examine the entries to see if they have learned MAC addresses of each other.