How can I control the IP in the SIP Contact header?

Hello,

I’m trying to use a SIP trunk service and the provider ask me to have the IP address of the contact header as my public IP and not as my private one, how can I do it?

See attached the SIP invite where a.b.c.d is the SIP server IP and x.y.z.w is my public address:

sipINVITE sip:144@ a.b.c.d SIP/2.0
Via: SIP/2.0/UDP 10.100.101.107:5060;branch=z9hG4bK76d52819;rport
Max-Forwards: 70
From: “Polycom” <sip:100@ x.y.z.w>;tag=as7435100b
To: <sip:144@ a.b.c.d >
[color=#FF4000]Contact: sip:100@10.100.101.107[/color]
Call-ID: 08116cf06661dc091de10c1b3315d2f7@84.94.96.110
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Date: Mon, 05 Jul 2010 15:49:31 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 292

v=0
o=root 1812163927 1812163927 IN IP4 10.100.101.107
s=Asterisk PBX 1.6.1.20
c=IN IP4 10.100.101.107
t=0 0
m=audio 18848 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

No virus found in this incoming message.
Checked by AVG - avg.com
Version: 9.0.830 / Virus Database: 271.1.1/2978 - Release Date: 07/05/10 09:36:00

Look at parameters like localnet, externip, and the stun related parameters.

Also consider choosing a better SIP to PSTN gateway provider as any competent one should be able to give you a standard configuration for accessing them from Asterisk,