DHCP and STATIC same bridge

Hi everyone I have a very complicated setup, at least I think it is. I have OpenWRT with two network interfaces. One the onboard LAN of a RPI and the other is a USB ethernet adapter. This RPI will be placed in a project box with an arduino for a project I'm working on. The reason for the two network interfaces is just to simplify the connections to the project box. One network device will be the input from the LAN in the building the other network device will be plugged into the network card of my arduino within my project box. The building lan runs on a subnet of 10.0.0.0/24, I'm configuring a network of arduinos for various automation around the building and they are configured on a subnet of 10.0.10.0/24. The arduino in the project box is the only one that needs access to the internet but also needs to access the other arduinos on the 10.0.10.0 subnet. So I have configured a bridge to bridge the two network interfaces. I then made two interfaces one DHCP to access the buildings LAN for internet access using the bridge as a device, then a second interface as static on the 10.0.10.0 network to act as a gateway for the arduinos using the bridge as a device. This setup is working great! except on power cycle. When OpenWRT power cycles the arduino has no internet access. If I go into the bridge device and remove eth1, save changes then re-add eth1 and save changes this instantly solves my concern.

Multiple IPs can be placed on one device (the bridge) like this:

config interface 'lan'
    option device 'br-lan'
    option proto 'dhcp'

config interface 'lan10'
    option ifname '@lan'
    option proto 'static'
    option ipaddr '10.0.10.1/24'

When the Ethernet ports are in a bridge, eth0 and eth1 can't hold an IP of their own. The bridge itself is the link from all the bridged devices to the kernel. Think of it as a virtual unmanaged Ethernet switch with one port plugged into the CPU and the others external.

This isn't the best way to do this. Since the networks aren't physically separate or on different VLANs, there's no actual security or reduction in broadcast traffic that you would have with separate networks. There's little advantage between your scheme vs. just having the Arduinos in 10.0.0.0/24 along with everything else.

Why are you putting both networks in a bridge? The preferred method would be to setup a standard routed wan/lan configuration (which is the general default openwrt config, but with a pi you just need to add a wan interface).

1 Like

That’s the way I have it set up. The reason I have the arduinos on a different subnet is because I don’t have access to the buildings dhcp server. My arduinos require a static IP address to communicate with each other. Since I don’t have access to the buildings dhcp server I just set the arduinos a static address on a different subnet to avoid IP conflicts. No security or firewall is required.

This setup works great but for what ever reason on boot up the bridge seems broken and requires me to reconfigure it. It seems to be an issue with the USB Ethernet adapter. If I boot OpenWRT the devices on the 10.0.10.0 connected to eth0 “onboard lan” have no problem accessing internet. It’s only the device connected to eth1 “usb adapter” that can’t connect.