chan_pjsip requires the proxy to be specified as it would be in an incoming Route header, i.e. with the “;lr” for loose routing appended, if you want the request as indicated by the provider.
If doing this directly, in the config file, you would need to escape the ; with a \
I know that the GUI can accept the ;lr, but I can’t remember if it needs the \
For the trunk, set Outbound Proxy to sip:Proxy-IP\;lr\;hide
and in Asterisk SIP Settings, check that External Address and Local Networks are correctly set.
Restart Asterisk and retest. There are likely other changes needed, but this should get you closer.
I missed the use of the internal address, as I was only looking for proxy issues. Although Stewart says check the External addresses, he really means set them (unless Proxy IP is within your local network).
I added the External Adress, Local Network and edited the proxy settings.
Trunk is now registered and outbound calls seem to work fine.
Inbound calls however only work if set the DID to “any”. In the logfiles for the incomming calls I can see that the DID is always “s”. Seems like there is something else which is not configured right in the trunk configuration. I got two phone numbers from my provider so to register them both the DID is necessary if I got that correctly.
I set my phone number in the “Contact User” settings of the trunk configuration. I don’t know if this was the right thing to do but incomming calls seem to work aswell now.