wireshark – Why are the transferred Ethernet packets rejected on the endpoint?

I have a Wroom32 ESP32 that has internal WiFi and an Ethernet port. I wish to connect my phone to the WiFi network and access a web server running on the Ethernet port. Schematically, it looks like:

PC ———————– ETH (ESP32) <----Forwarding----> Wifi (ESP32) ———— Telephone

The PC has a static IP address: 192.168.2.150 ETH (ESP32) has a static IP address 192.168.2.100 Wifi (ESP) has DHCP enabled, subnet: 192.168.4.x

I can configure the Wifi and ethernet part to initialize. The ETH side has a static IP address and the Wifi side has the DHCP protocol to assign an IP address to the phone.

I only want to access a specific web server page running on the PC (access via 192.168.2.150:8000). This makes me think that it should be possible to have a very simple transfer function that transmits between Wifi and ETH.

Now, I've tried two things so far:

  1. Accept incoming TCP / UDP connections on the wifi interface and open a connection on the ETH interface where all incoming wifi packets
    are transmitted to. This does not work because TCP connections to
    open to load the web page wants to open multiple sockets. The number of sockets that can be opened is limited by WROOM. Moreover the catches are not closed
    which makes me wonder how a TCP connection to load a web page "knows"
    that he should close. An added benefit: The web page uses Websockets to transmit data. As I understand it, there is a protocol other than TCP, which is an additional implementation.
  2. The second option is lower level. What I do is monitor incoming Ethernet packets on both interfaces. For the
    wifi interface: if the destination port is 8000, I change the IP address
    addresses and hardware addresses on the header of the package and send it by the
    ETH interface. And everything that happens on the ETH
    the interface is transmitted via the wifi interface (after modification of the
    IP and hardware addresses).

I think the second option is the best implementation for this problem. And I managed to make it almost work. With Weashark, I can listen to both Wifi and Ethernet interfaces. I can see that the packets are sent and received at the other end. However, when I listen with netcat, packets do not arrive.

Wireshark also sends a message that the packets are being broadcast by an intermediate device. So, my best guess is that packets are rejected for this reason.

To come to my question:

  • a) How is it determined that these packets are broadcast by
    an intermediate device?
  • b) Can I do something to solve these problems
    the packets being rejected?

Note: I am limited to a WROOM or other type of embedded device because of the features I need: it must be very small for an integrated application and must have multiple interfaces for other sensors ( I2C, UART, SPI).