Linux is sending ARP requests to hosts in other subnets?

Solution 1:

The routing table on the router looks incorrect. It looks as if you are running both VLAN untagged from the router.

I don't know how the switch manages to deliver packets from the router to both A and B, when the router apparently sends all of the packets to the switch with no indication of which VLAN they belong to. The switch I am using wouldn't be able to do that. But perhaps you are using a brand of switch which can somehow correctly guess which VLAN to send the packets to.

However from the routers point of view A and B are on the same Ethernet segment, which means the router is expected to instruct A and B to communicate directly without involving the router. And that is where communication breaks down.

The routing table entries looking like this:

192.168.1.0      255.255.255.0    *                 0             eth0   
192.168.2.0      255.255.255.0    *                 0             eth0   

Should in fact have been looking like this:

192.168.1.0      255.255.255.0    *                 0             eth0.1     
192.168.2.0      255.255.255.0    *                 0             eth0.20    

The virtual interfaces eth0.1 and eth0.20 can be created with the commands:

vconfig add eth0 1
vconfig add eth0 20

Solution 2:

Found a solution for me: I put Host A and the subnet 192.168.1.0/24 to new VLAN with ID 10. Now everything is fine. It's ok for my overall configuration, but still strange, that it was not working with VLAN ID 1. Maybe the router is the problem and it treats VLAN 1 in a special manner. But how could that affect Linux ARP behavior? Still a question.