(48) 3332-8540

Query number portability for Asterisk

We have talked many times on our blog about how easy it is to integrate the portability query service (ATI) into Asterisk PBX servers, however, we have not yet written an article specifically for purely Asterisk servers, so in this post you will see the necessary settings to the two files (sip.conf and extensions.conf). In just 4 steps, your Asterisk can now count on number portability consultation (ATI).

First, we will create the SIP trunk pointing to the portability query server (ATI) using the previously created username and password. If you do not already have an account with the ATI service, access sippulse.com/ati, in the Your Account tab, and fill out the registration form right now and receive 500 free consultations to carry out tests and approval on your PBX.

1) Creating the SIP trunk

To configure the SIP trunk to use ATI, it is necessary to enter the connection data in sip.conf. Therefore, open the sip.conf file for editing (vim /etc/asterisk/sip.conf) and add the following information:

[general]
promiscredir=no

[portability]
type=peer
fromdomain=port.sippulse.com
host=port.sippulse.com
port=5060 ;OR 5080
defaultuser=YOUR ATI USER ;FOR ASTERISK 1.6 OR HIGHER
username=YOUR ATI USER ;FOR ASTERISK 1.4
fromuser=YOUR ATI USER
secret=YOUR ATI PASSWORD
context=fromredirect ; CONTEXT WHERE THE RULES WILL BE DEALING WITH THE RETURN OF ATI
insecure=invite,port
qualify=no

After entering your account details, save the changes (:wq)

2) Creating routes to the ATI

Now we will edit the dial plan in extensions.conf, so that your Asterisk will forward cellular calls to ATI first.

The numbers to be consulted on the ATI must be sent in the TN standard (DDD+NUMBER), therefore, if users make calls by dialing in another standard, the dial plan must process the number before forwarding it to the ATI.

Open the extensions.conf file in edit mode (vim /etc/asterisk/extensions.conf) and add the following information:

[from-internal]

;for local calls you must add your area code (DDD)
exten => _[6-9]XXXXXXX,1,Dial(SIP/portability/48${EXTEN}) ;change 48 to your DDD

;ATI Consultations
exten => _ZZ[6-9]XXXXXXX,1,Dial(SIP/portability/${EXTEN})

;Connections to locations with the ninth digit
exten => _ZZ9[6-9]XXXXXXX,1,Dial(SIP/portability/${EXTEN})

3) Treating ATI return

In this example we are using a Khomp card, check with your supplier how to configure your GSM termination on an Asterisk exchange.

Now we will create the [from-redirect] context to handle the ATI return. As can be seen below, we are using the NoCDR() application to avoid the duplicate ticket. Add the following rules:

First we will define the operators' CSP code. Change the values according to the code used in your region:

TIM=041

CLEAR=021

ALIVE=015

OI=031

NEXTEL=041

;Note: Many people use Tim to end calls to Nextel.

[from-redirect]

;TIM (55341)

exten => _55341ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55341ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C0/${TIM}${EXTEN:5})

exten => _55341ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55341ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C0/${TIM}${EXTEN:5})

;OF COURSE (55321)

exten => _55321ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55321ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C1/${CLEAR}${EXTEN:5})

exten => _55321ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55321ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C1/${CLEAR}${EXTEN:5})

;LIVE (55315 | 55320 | 55323)

exten => _55315ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55315ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C2/${VIVO}${EXTEN:5})

exten => _55315ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55315ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C2/${VIVO}${EXTEN:5})

exten => _55320ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55320ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C2/${VIVO}${EXTEN:5})

exten => _55320ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55320ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C2/${VIVO}${EXTEN:5})

exten => _55323ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55323ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C2/${VIVO}${EXTEN:5})

exten => _55323ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55323ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C2/${VIVO}${EXTEN:5})

;HI (55331 | 55335 | 55314)

exten => _55331ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55331ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C3/${OI}${EXTEN:5})

exten => _55331ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55331ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C3/${OI}${EXTEN:5})

exten => _55335ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55335ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C3/${OI}${EXTEN:5})

exten => _55335ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55335ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C3/${OI}${EXTEN:5})

exten => _55314ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55314ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C3/${OI}${EXTEN:5})

exten => _55314ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55314ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C3/${OI}${EXTEN:5})

;NEXTEL (55377 | 55351)

exten => _55377ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55377ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C0/${NEXTEL}${EXTEN:5})

exten => _55351ZZ[6-9]XXXXXXX,1,NoCDR()

exten => _55351ZZ[6-9]XXXXXXX,n,Dial(Khomp/B1C0/${VIVO}${EXTEN:5})

exten => _55351ZZ9[6-9]XXXXXXX,1,NoCDR()

exten => _55351ZZ9[6-9]XXXXXXX,n,Dial(Khomp/B1C0/${VIVO}${EXTEN:5})

;NUMBER NOT FOUND

exten => _55000.,1,Progress()

exten => _55000.,n,Playback(invalid)

exten => _55000.,n,Hangup()

4) Loading the settings

Stop loading the settings we just made, go to the Asterisk CLI> (# rasterisk) and reload the following settings:

# rasterisk

CLI> sip reload

CLI> dialplan reload

Okay, now your Asterisk should be forwarding calls to mobile phones via the ATI's SIP trunk.

If the query is not being carried out, check your dialing plan, making sure there is no other rule that could correspond to the dialed number.

en_USEN