UDP broadcast and Torizon Container

I’m testing a container with my application that use UDP (Bacnet Protocol), I receive broadcast and unicast packets inside the container but when i need to send back a broadcast response packet this doesn’t reach the host. The socket is open on “eth0” and only with bridge driver I can receive properly, host not works.

This is my debug info with the packets received and sent
BIP: Received MPDU-> 172.19.0.2:47808 (25 bytes)
BIP: Sending MPDU-> 172.19.255.255:47808 (25 bytes)

IP host pc 192.168.1.73/24 (static)
IP torizon board 192.168.1.209/24 (static)

it seems like broadcast packets not sent back to the network (192.168.1.xx), when i send unicast packet they is sent back to the host properly, for example using Modbus TCP or Modbus UDP.

this is my docker-compose.yaml

version: “3.9”
services:
sert_c-debug:
build:
context: .
dockerfile: Dockerfile.debug
image: ${LOCAL_REGISTRY}:5002/sert_c-debug:${TAG}
#restart: always
ports:
- 2230:2230
- 502:502
- “900:900/udp”
- “47808:47808/udp”
devices:
- “/dev/gpiochip1:/dev/gpiochip1”
- “/dev/gpiochip4:/dev/gpiochip4”
- “/dev/colibri-uarta:/dev/colibri-uarta”
- “/dev/colibri-uartb:/dev/colibri-uartb”
volumes:
- type: bind
source: /home/torizon/SeRT/bootdbg
target: /home/torizon/app/boot
read_only: false
sert_c:
build:
context: .
dockerfile: Dockerfile
image: ${DOCKER_LOGIN}/sert_c:${TAG}
restart: always
network_mode: bridge
ports:
- 502:502
- “900:900/udp”
- “47808:47808/udp”
devices:
- “/dev/gpiochip1:/dev/gpiochip1”
- “/dev/gpiochip4:/dev/gpiochip4”
- “/dev/colibri-uarta:/dev/colibri-uarta”
- “/dev/colibri-uartb:/dev/colibri-uartb”
volumes:
- type: bind
source: /home/torizon/SeRT/bootrel
target: /home/torizon/app/boot
read_only: false

After 2 days of testing and searching I found a solution using in the yaml file

network_mode: “host”

the problem with this setting is that the ethernet port name becomes “ethernet0” and not “eth0” as in the container with bridge mode.

With host mode there is another problem if you use port < 1023 (like in the Modbus TCP port 502) you need to activate them with

sudo sysctl net.ipv4.ip_unprivileged_port_start=0

I’m asking if it is possible in bridge mode