How does a dumb switch know the gateway?

Hi,
I just wonder how an unmanaged (dumb) switch is able to forward packets to the right port where the router is attached to,
as for such a switch there is no configuration to make by the admin.
But then how does it figure out to which port it has to forward all the packets that have to go over through the router?
Ie. I’ve 5 PCs and the router attached to the switch.
This switch (actually tested on 2 dumb switches of different brands) does not have any special “uplink/gateway” port; the router is just attached to a normal switch port.
And here DHCP is not used; all devices use just static IPv4 only, no IPv6.
Everything works well, but I’m just curious how the switch manages this situation (forwarding to the router).
Thx

Update:
after thinking twice about it, I think it is the PCs themselves that specify where the packet has to go to: to a LAN client or to the gateway, ie. to the router.
I think it’s done with the arp MAC addresses, which are valid/used only within the local LAN (actually in the underlying/carrying Ethernet frame at layer 2; IP packets are layer 3)

The answer on such a fundamental question can be found on thousands of web sites, you just need a google a little…
Try youtube…
https://www.youtube.com/watch?v=chlBlRfsnq0

https://www.youtube.com/watch?v=NDVImep5UBI

Note: SwOS uses a simple algorithm to ensure TCP/IP communication - it just replies to the same IP and MAC address packet came from. This way there is no need for Default Gateway on the device itself.

source: https://wiki.mikrotik.com/wiki/SwOS/RB250_RB260

Wrong,

Switching operates at layer 2 of the OSI model, where packets are sent to a specific switch port based on destination MAC addresses. Routing operates at layer 3, where packets are sent to a specific next-hop IP address, based on destination IP address

@satman1w answered correct…
The switches have a mac - port Table… They only know through what port they will reach a mac address…
The proccess of learning those ports, the unknown ones, is called flooding…

Wrong? Tell Mikrotik how their SwOS is working then. Switch management is not layer2 traffic (mostly, MKT devices can use MAC level access for management) but is L3, and there is no field to define a gateway. One wonders how this can work. So did I, and found the explanation in the wiki of the manufacturer. This is not for switched payload data traffic. Switched traffic is based on MAC table learning from incoming packets. If an unknown dst-MAC is used, then it is flooded.. [ Exception: Some softwares use MAC addresses that are invalid for the MAC table, otherwise the Microsoft load-balancing cluster would not be possible, as all cluster nodes need to see the same request.]

EDIT: just thought that the question was about the IP address and path for management because the question was about the “gateway”. There is sometimes no gateway entry in the config to be filled in. We known that for IP routing we should specify the routers IP address for anything that’s not on the same subnet, like a remote management point The function of a switch or bridge itself is not dependent on the IP protocol in any way. The concept “gateway” does not even exist at that level.

They just make use of ARP Tables which is a Layer 3 Protocol !!!