This is done through UE IP pools.Your UE IP Pools are allocated in to per APN per UPF so once allocated controll plane knows which IP is which UPF.
1 Like
UPF selection in a 5G SA network is performed by the SMF, not by the UE. The SMF selects a UPF based on factors such as the UE’s serving area, DNN, S-NSSAI (network slice), operator policies, UPF load, and proximity to the serving gNB. Deploying a nearby UPF helps reduce latency and optimize traffic routing.
Detailed explanation with examples, check out:
https://techlteworld.com/upf-selection-in-5g-network/