Networking with multiple interfaces


I have a use case where my host pc has multiple physical interfaces that the container needs to connect to and I’ve been using ipvlan and macvlan to achieve that.

Scenario 1: Container needs to ping a physical robot at 192.168.1.100 on the 192.168.1.0/24 subnet.

services:
  test:
    extends:
      file: common.yml
      service: test_sub
    networks:
      robot_net:
        ipv4_address: 192.168.1.36
    
networks:
  robot_net:
    driver: ipvlan
    driver_opts:
      parent: eno2
    ipam:
      config:
        - subnet: 192.168.1.0/24

The above compose file connects the container to ping only the robot at 192.168.1.100. Scenario 1 Easy.

Scenario 2: Container only needs to access the internet via the wlo1 interface.

services:
  test:
    extends:
      file: common.yml
      service: test_sub
    networks:
      wifi_net:
        ipv4_address: 172.20.10.12
    
networks:
  wifi_net:
    driver: ipvlan
    driver_opts:
      parent: wlo1
    ipam:
      config:
        - subnet: 172.20.10.0/24
          gateway: 172.20.10.1

The above compose file connects the container to ping the internet at e.g. 8.8.8.8 Scenario 2 Easy.

Challenge starts.
Scenario 3: The container needs to be able to ping both the robot as well as the internet 8.8.8.8 at the same time. The below compose codes runs and my container can see both nets when i run ifconfig. I can also ping the robot, but I can never ping 8.8.8.8. I even specifically defined the gateway (for the wifi net), but the ping still does not reach 8.8.8.8.

services:
  test:
    extends:
      file: common.yml
      service: test_sub
    networks:
      wifi_net:
        ipv4_address: 172.20.10.12
      robot_net:
        ipv4_address: 192.168.1.36
    
networks:
  robot_net:
    driver: ipvlan
    driver_opts:
      parent: eno2
    ipam:
      config:
        - subnet: 192.168.1.0/24

  wifi_net:
    driver: ipvlan
    driver_opts:
      parent: wlo1
    ipam:
      config:
        - subnet: 172.20.10.0/24
          gateway: 172.20.10.1

Can someone advise what needs to be done? I even tried to use macvlan but the results are pretty much the same.