Internal numbering, or internal extensions are common practice among SIP providers for having multiple DID numbers on a single SIP registration.

MyNetFone is a good example. You register to MyNetFone using your assigned internal extension, eg, 0946xxxx. In my case, I have two regional DID numbers assigned to my account.


Inbound calls to these regional numbers show the following in the SIP INVITE packet:

To: <>

How can I find which number was dialled and re-write the To: header? I want FreeSWITCH to route these calls through the same rules as my numbers from other providers. I want to route these numbers to different destinations if required.


After some investigation I discovered MyNetFone places the "dialled" number in the Diversion: header shown below:

Diversion: <>;reason=unconditional

As mentioned, I have multiple numbers routing through a common set of dialplan rules; requiring me to normalise (E.164) all incoming calls. This structure makes it very easy to re-write the header.

The first XML dialplan in my public SIP profile is "00_normalisation.xml". An excerpt is shown below that re-writes the Diversion header:

    <extension name="mynetfone_normalisation" continue="true">
        <condition field="destination_number" expression="0946xxxx" require-nested="true" break="on-false">
            <condition field="${sip_h_Diversion}" expression="^(?:<sip:)?(\d+)(?:@.+)?$">
                <action application="set" data="sip_h_Diversion=null"/>
                <action application="transfer" data="$1 XML public"/>


Note: Place this rule at the top of the file for normalisation to occur after the transfer.

Also for anyone interested, I have included my SIP provider configuration I use for MyNetFone; it's nice and simple:

    <gateway name="MyNetFone">
        <param name="username" value="0946xxxx"/>
        <param name="password" value="xxxxxxxxxxxxxxxxxxx"/>
        <param name="realm" value=""/>
        <param name="proxy" value=""/>
        <param name="register" value="true"/>
        <param name="expire-seconds" value="120"/>