DNS Queries for Regitration and Call Setup

Hello Community!

I have managed to connect an Asterisk box with an IMS platform. As you may know an IMS platform includes a Session Boarder Gateway acting as an Outbound Proxy and a CSCF node acting as the proxy.

The problem:
When I register Asterisk on the IMS platform it sends a Registration Request like:
REGISTER sip:aaaa.bbbb.com:5060,
where aaaa.bbbb.com is the IMS domain, while when I try to make a call it sends:
INVITE sip:@111.222.111.222:5060,
where the 111.222.111.222 is the IP address of the Outbound Proxy: sbg.aaaa.bbbb.com.

Both registration and calls to IMS users work fine but calls to PSTN users (that have to be forwarded after the Application Server not to the same Outbound Proxy but to a Media Gateway Controller) fail because they are routed irregularly to the Outbound Proxy 111.222.111.222.

In my point of view that problem could be resolved if the INVITE packet was sent like:
INVITE sip:@aaaa.bbbb.com:5060
and thus let the “IMS” decide where the call should be terminated (for PSTN numbers it should be sent to MGC instead of SBG).

The auth id with which Asterisk is registered at the IMS is: @aaaa.bbbb.com while the Password is:

My sip.conf file looks like:

[size=75][general]
register => @aaaa.bbbb.com::@aaaa.bbbb.com@sbg.aaaa.bbbb.com/

[calls2ims]
type=friend
dtmfmode=rfc2833
context=ims
outboundproxy=sbg.aaaa.bbbb.com
port=5060
fromuser=
fromdomain=aaaa.bbbb.com
userqphone=yes
canreinvite=no
disallow=all
allow=alaw
allow=ulaw[/size]

I have noticed that when the asterisk starts up it sends a dns query (to the adsl router where it is connected with dhcp) for the sbg.aaaa.bbbb.com and gets a response with the IP address 111.222.111.222 of the Outbound Proxy; and thus it sends there the INVITE packets.

My question is how it would be possible to send the INVITEs to aaaa.bbbb.com:5060 (like the Registration Requests) instead of the IP address.

Any help would be really appreciated.

Thank you in advance.

Cheers!
Nikos