Skip to content

Phils Blog and Stuff

TELECOMS. VIRTUALIZATION. IT. CODING. and more…

Menu
  • Home
  • Resources
    • Subnet Mask Cheat Sheet
    • Easy Dmarc+Email
    • MX Tool Box
    • LOAD BALANCING & SRE
  • SHOP
  • SOLUTIONS
  • SERVICES
  • Contact Me
Menu

Using Asterisk as a Proxy/LCR System..

Posted on 23/02/201308/03/2023 by Phil

Introduction.

asterisk-by-digiumThis post is going to briefly cover how to use asterisk to be a proxy between an old ISDN System and a SIP Trunk. This example also shows how to modify the dialed number to add in the area code you are dialing, for example if your users are used to just dialling 6 digits to get to a local business etc.

Example Explained.

In our example we have an ISDN PBX and we want to integrate a SIP trunks, so that we can take advantage of lower calling costs, IE you might have a SIP trunk from a USA provider and one from the UK, you would send all USA numbers out to the USA trunk and they would forward the call at the cost of a Local call, while still being able to dial UK numbers via the UK trunk etc etc…

This is called LCR or Least Cost Routing, and could save you some money on your telephone bill.

Right back to our example, we have an ISDN PBX, a ISDN to SIP convertor, and an asterisk server to perform both LCR and a simple dial plan.

Inbound:
SIP Provider > Asterisk > ISDN Gateway > PBX

Outbound:
PBX > ISDN Gateway > Asterisk > SIP Provider

In the example all we are doing is taking the call from the ISDN gateway checking to see if we need to add the local area code if calling locally and forward the call on to the SIP provider.

We could have a few SIP providers and get very granular on how we want the call to be routed and to where.

Example Config.

sip.conf

    ; Provider SIP Trunk

        [Trunk-Provider]
        type=friend
        context=from-provider
        deny=0.0.0.0/0.0.0.0
        permit=IP-ADDRESS
        host=IP-ADDRESS
        username=USERNAME
        secret=PASSWORD
        language=en_GB
        disallow=all
        allow=alaw
        dtmfmode=rfc2833

    ; ISDN SIP Trunk

        [ISND-Trunk]
        type=friend
        context=from-isdn
        deny=0.0.0.0/0.0.0.0
        permit=IP-ADDRESS
        host=IP-ADDRESS
        username=USERNAME
        secret=PASSWORD
        language=en_GB
        disallow=all
        allow=alaw
        dtmfmode=rfc2833

extensions.conf

    [from-isdn]

        ; from isdn with area code
            exten => _X.,1,Dial(SIP/${EXTEN}@Trunk-Provider,1000)
            exten => _X.,2,hangup

        ; from isdn, no area code, six digit, prepending area code
            exten => _NXX.,1,Dial(SIP/+0115${EXTEN}@Trunk-Provider,1000)
            exten => _NXX.,2,hangup

    [from-provider]

        ; from SIP Provider, send to ISDN
            exten => _X.,1,Dial(SIP/${EXTEN}@ISND-Trunk,1000)
            exten => _X.,2,hangup

lll

POSTS

  • Home Assistant. Add water meter with PHP+MQTT+YML.
  • Automating your home with Home Assistant. Initial install and config (Hyper-V).
  • The importance of setting up email security correctly.
  • Automate Debian installations with Seed, DHCP and Nginx.
  • A simple link shortener.. Fun little project…

WORD CLOUD

3CX 3CX Phone System Apache Asterisk Cacti CentOS CRM DHCP DNS Email Fail over Failover File System Firewall FreeBSD FreeNAS FXO IAX install IP IP PBX Linux M0n0wall Nottingham Open Source PBX PFSense PHP Router Server SIP snom SSH TrixBox ubuntu VLAN Voice VoIP VPN vyatta WAN Website WiFi yealink ZFS

© 2025 Phils Blog and Stuff | Powered by Superbs Personal Blog theme