I am connecting some number of embedded linux devices to a main LAN using a DHCP server and routing tables. On the main LAN (192.168.1.0/24) I have a PC connected and the first embedded linux device. The embedded linux device has two ethernet ports such. Some number of the linux devices are chained together using a software ethernet bridge. There are two scenarios how each of embedded devices should act:
The head of the chain. I have written a simple bash script to detect when it is on the main LAN by pulling the MAC of the gateway it sees. If it is the head, it receives the IP address from the main LAN DHCP server and creates a new subnet on the second ethernet port (192.168.50.0/24).
Not the head. When a device is found to be not the head by the bash script, it simply bridges the two ethernet ports.
I have tried some simple routing commands (ip route, route). Currently from a device other than the head, I can ping the 50.1 server, the main LAN port on the head device (1.101), but not the main DHCP server (1.1) or the main LAN PC (1.100). From the main LAN PC I can ping the LAN side of the first device (1.2) but not the subnet side (50.1).
On head device:
$ ip route 192.168.50.0/24 dev eth1 src 192.168.50.1 192.168.1.0/24 dev eth0 src 192.168.1.2 default via 192.168.1.1 dev eth0
On chained device:
$ ip route 192.168.50.0/24 dev eth0 proto kernel scope link src 192.168.50.254 127.0.0.0/8 dev lo scope link default via 192.168.50.1 dev eth0
The end goal here is to have all embedded devices be able to talk with the PC on the main LAN.
It should also be made known that there can be several chains connected to the main LAN also.