PJSIP trunk behind NAT and client URI

Looking at the Asterisk wiki for pjsip, I have a question:

What information belongs into the client_uri when configuring a pjsip trunk on an Asterisk machine behind NAT that registers to a SIP provider or another Asterisk server on the internet.
Wiki example:
client_uri=sip:myaccountname@192.0.2.1:5060

Is that 192.0.2.1 the IP address of the local Asterisk machine and would I insert my public IP or private IP if behind NAT?
The port in this example is the pjsip bind port of my local machine as well, not the remote machine, correct?

It is the IP address or hostname (and port) of the remote SIP server.

The Contact header is automatically generated and does not need to be set. It gets updated with the appropriate IP address if behind NAT and the transport is configured properly.

Thanks.
Then I don’t understand the example in the wiki for configuring a pjsip trunk.(https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip).

That example says that IP 203.0.113.1 is the address of the remote server, which is in the server_uri.
Now the example client_uri contains a private IP, how could that then be the IP address or hostname of the remote server?

[mytrunk]
type=registration
outbound_auth=mytrunk
server_uri=sip:myaccountname@203.0.113.1:5060
client_uri=sip:myaccountname@192.0.2.1:5060

It’s a mistake, I’ve updated it. In practice many things don’t care. The server URI is how to reach the server you are registering to, and the client URI is the information about what you are registering to on that server.

1 Like

So would you then be able to leave out the myaccountname if the server_uri specifies the location of the remote server?

You could likely leave it out of server_uri. It doesn’t do any harm though. It must be in client_uri.

1 Like