[quote] If a DID is dialed that is not assigned to a ser subscriber our sip proxy routes the caller to the PSTN gateway. But the PSTN gateway provider sees the DID as belonging to our sip proxy so they route it right back to us. And we get in a loop. [/quote]
So basically it's not your fault but the PSTN gateways fault, it should only send the assigned DID's to you? You are stating that the gateway sees the number as assigned to your proxy while you don't.
(you could also check if the incoming message is coming from an ip address of your pstn gateway)
Kind regards,
E. Versaevel