You need to allow anonymous relay on a custom receive connector and then set the allowed remote IP:
https://learn.microsoft.com/en-us/exchange/mail-flow/connectors/allow-anonymous-relay?view=exchserver-2019#step-1-create-a-dedicated-receive-connector-for-anonymous-relay
On the next page, in the Remote network settings section, do the following steps:
Select the existing 0.0.0.0-255.255.255.255 entry, and then click Remove Remove icon., and then click Add Add icon.
In the resulting Remote Address Settings dialog, enter an IP address or IP address range that identifies the network hosts that are allowed use this connector, and then click Save. You can repeat this step to add multiple IP addresses or IP address ranges. Err on the side of being too specific instead of too general to clearly identify the network hosts that are allowed to use this connector.