How to assign a DID to a SIP Trunk

Discussion in 'General' started by jandir, Sep 19, 2008.

  1. jandir

    Joined:
    Aug 24, 2008
    Messages:
    65
    Likes Received:
    0
    How do I assign a DID to a SIP Trunk so that I can associate an Inbound Route to it?

    Elastix Without Tears explains how to do it for Zaptel Trunks but not for SIP trunks.

    Thanks
     
  2. Bob

    Bob

    Joined:
    Nov 4, 2007
    Messages:
    2,400
    Likes Received:
    1
    Re:How to assing a DID to a SIP Trunk

    It depends on the provider you use and how then implement their DID's, and can vary based on the equipment that they have on their end. Let us know what provider you are using.

    Now having said that the concepts are

    1) Setup a SIP Trunk. This generally performs nothing more than the authentication to your SIP Provider, plus a few other configuration items such as DTMF, Peer, Friend, etc etc. It generally does not have any DID information that actually goes in the SIP configuration. However there are a few SIP providers, who as part the authentication process, use at least one of the DID numbers as part of the register string, but note, that in general, this is again part of their authentication process, not a set DID number for that trunk. This one trunk from the SIP provider could have one DID associated with it or 20 DID's assoociated with it.

    2) In the inbound routes on ELastix/Freepbx, you actually add the DID and where you want calls to that DID to end up e.g. an extension, or ring group, or queue or etc etc. You can also add DID's directly under the extension as well, but we are keeping this simple for the moment. Start with basic concepts first, then branch out.

    That is it......simple heh!!! Thats where the simple part ends, because if it is not working it gets harder. Problems that can occur are

    1) Your SIP Trunk is not registering/Authenticating with your SIP Provider
    2) Your DID info setup in Freepbx does not match what your provider is sending as a DID
    3) Your Codecs are incorrect or not matching the SIP provider
    and so on.

    the Asterisk CLI is your friend....watch this as you make calls in as it will give you a wealth of information. If you don't see any calls coming in, then you probably have an authentication issue (as long as you have correctly setup the firewall/router).

    So in a big nutshell that is it, without further info, it is hard to tell you any more specific.

    So to summarise further....the SIP trunk that you setup is purely a conduit for your SIP provder to pass data packets down. The information that they send to you (at least the first few packets), will be the DID number, which is then picked up by Asterisk/Freepbx and at that point it looks at where you want that DID to end up.

    Hope this helps.

    Bob
     
  3. jandir

    Joined:
    Aug 24, 2008
    Messages:
    65
    Likes Received:
    0
    Re:How to assing a DID to a SIP Trunk

    In my case I have a IPKall incoming route. I do not have a Trunk configured for IPKall because there is no registration or outbound calls on IPKall. I can handle incoming calls from IPKall but just wanted to get a better idea on how to handle multiple IPKall numbers and custom route them.

    When a SIP Call (INVITE) comes in from IPKall (of for that matter any SIP provider) what part of the message will Elastix/Asterisk recognize as the DID? The TO header? SIP URI?
     
  4. jandir

    Joined:
    Aug 24, 2008
    Messages:
    65
    Likes Received:
    0
    Re:How to assing a DID to a SIP Trunk

    I looked at the asterisk CLI logs and it does seem to treat the number before the @domain in the TO header of the SIP INVITE as the DID.

    I understand that this may not always be the case and different VOIP providers may use different mechanisms to indicate DIDs (http://aussievoip.com/wiki/How+to+get+the+DID+of+a+SIP+trunk).

    However this does give me a way to selectively handle incoming calls from IPKall.

    Thank you.
     
  5. Bob

    Bob

    Joined:
    Nov 4, 2007
    Messages:
    2,400
    Likes Received:
    1
    Re:How to assing a DID to a SIP Trunk

    Jandir,

    You have probably got your issue sorted out, and this information is not necessarily just for you, but for others that come across this thread...

    One of the first things I do with new VoIP connections (usually inbound only) that do not use user/challenge authentication is by looking at the header that is being sent. Normally I do this by using the Asterisk CLI and by turning SIP Debug on.

    I first of all setup the account to use SIP.
    SIP PHONE NUMBER: 5000 <====just any number to start off with
    SIP PROXY Server: your.asterisk.server IP address

    I then initiated a call and got the following SIP Header back in the SIP Debug

    This shows me that they are passing the username/SIP Phone number that I entered as part of the SIP header.

    I went back into my account and replaced the SIP Phone number with the SIP phone number that I received in the email from IPKALL

    I then initiate another call to my DID and watch/capture what is coming in from that particular host.

    Basically what this does is confirm that IPKall is not passing the DID, but what I setup as the Username/SIP Phone number part of the SIP Header. This can be used to identify which DID is coming in, and can be setup on Elastix.

    So in the Trunk section of Elastix, I setup a SIP Trunk

    That is it, no more to be added into the trunk section. (you might want DTMF, Codec, NAT, but this is the basics required to get it functional)

    Now go to the INBOUND ROUTES and add your SIP PHONE NUMBER and where you want it to go.
    Remember, it is not actually using your DID here but the number that you have as an account at IPKall. In otherwords, if I had left my account with a number of 5000, then I would enter a DID of 5000. However, to keep it tidy, clean and traceable, I changed by IPKall username/SIP Number to my actual IPKall phone number, and this is the number I use in the inbound routes.

    Test your calls.

    The only thing I will add is that you may need (I haven't tested it) is another SIP Trunk with the same information except call it IPKall1 and change the host to voiper2.ipkall.com to accept calls from a second server that IPKall uses. However in all the testing, the calls seem to come from the one server that I had set already in Asterisk.

    Hope this helps.....

    Jandir, thanks for the prompt to muck around with SIP/IAX trunks and get some of the Brain juices running again.

    Regards

    Bob
     
  6. jandir

    Joined:
    Aug 24, 2008
    Messages:
    65
    Likes Received:
    0
    Re:How to assing a DID to a SIP Trunk

    What is the point of setting up a trunk for IPKall? I never see asterisk detecting any incoming calls on it, at least from the flash operator panel. I have tried both voiper and voiper2. I see the Extension ringing but never any activity on the trunk. Have not looked at the Asterisk CLI yet though.

    Thanks
     
  7. Bob

    Bob

    Joined:
    Nov 4, 2007
    Messages:
    2,400
    Likes Received:
    1
    Jandir,

    I am not sure if I understand the question correctly, so I will ask another question.

    How have you got your IPKall setup now. e.g. what configuration have you used, and what files have you changed (if any)??

    Regards

    Bob
     
  8. jandir

    Joined:
    Aug 24, 2008
    Messages:
    65
    Likes Received:
    0
    Ok. Let me explain my setup. I had setup IPKall to route calls to my public ip (dyndns.com). And to an extension (600). On my Elastix server I had just setup a inbound route for (anyDID/anyCID) and enabled "allow anonymous inbound SIP calls" in my "General Settings". I had not setup any trunk for IPKall.

    Everything worked fine until I added a ZAP card and hooked up my POTS line to it. I did not want Asterisk to handle the POTS line (although I wanted to use it for outgoing asterisk calls). But the catch-all (anyDID/anyCID) Inbound Route would always handle any incoming call on the POTS line (I had posted about this on other threads but probably did not have enough understanding of asterisk to ask the question properly). Finally I posted this question which helped me understand Trunks to inbound route association.

    So now, as per your previous post, I have changed my IPKall setting to my correct DID number and also changed by inbound route to handle the DID and everything works fine (meanwhile I have setup a virtual fax for the POTS line so that issue is resolved). Then I also followed your suggestion about setting up a Trunk for IPKall but I never see it getting used (Blinking red) like other trunks on the flash operator panel when an incoming call comes in. Everything (IPKall incoming calls) worked fine before I setup the Trunk and it is the same after I setup the trunk. Hence my question.

    It looks like somehow asterisk is not able to associate the incoming SIP invite to the IPKall Trunk.
     
  9. Bob

    Bob

    Joined:
    Nov 4, 2007
    Messages:
    2,400
    Likes Received:
    1
    Jandir,

    Thank you for explaining your setup, your question is a little clearer now.

    First of all, the fact that your "Allow anonymous inbound SIP calls" is turned on, basically negates the setup of a SIP Trunk, as you have basically said let every SIP call directed to my IP address, into my Asterisk system.

    Without sounding all righteous, this is not a good idea, leaving your system open to possible abuse. What security issues am I referring to??? I can't give you any examples at the moment relating to Asterisk systems (they may be around), but no matter how big the company is, or how good they believe their security is, there is always a way that someone will find into the system. I was aware of a very large name telephone system, which due to small flaw in their software, in combination with the administrator not knowing the ramifications, cost the carrier/PBX Supplier/owner well over $500,000 in calls (a cracked direct number was used to divert calls). So it can happen and they did it all via DTMF, not direct computer based access as many systems have now.

    The idea of setting it up as a Trunk is first of all good practice. Like any system, such as a Network, first and foremost, I protect and am aware of the perimeter. Now external entry into an Asterisk system is far easier to see if it is setup in the Trunk section. It makes it easier for future readability, and possibly someone else that may come along in the future.

    Secondly, the majority of SIP Trunks actually use User/Secret challenges, so again it is good practice to setup the connection as a SIP Trunk, and to be honest I prefer that every connection into production systems came in with a User/Secret challenge, but I appreciate that is not always possible.

    Continuing on the second point, another benefit of setting up a trunk, is so you can specify the host that the SIP connection will come from, via use of the HOST=Voiper.ipkcall.com. This specifies to my system (in combination with the setup I have the previous posts) that it is allowed to accept an unauthenticated calls from this host and only this host. In other words, if we dont use user/secret challenges, we can use IP authentication (You may have seen it called this on other IP PBX systems). If you change the line HOST=Voiper.ipkcallnothing.com, you will find that the call will not get through, which is to be expected. If I omit the HOST Line altogether, then this will match all, and is basically identical to "Allow anonymous inbound SIP calls" being turned on.

    Now to be fair, the idea of SIP trunks is more a named group categorisation than a functional categorisation, as generally your SIP Devices such as phones and gateways are generally the same thing. Extensions are no more than an authenticated SIP Connection. Products like Freepbx and similar have done more to perpetuate the use of the name SIP Trunks, and for good reason as many people view incoming lines whether they be E1 / T1 / PSTN / SIP or IAX as Trunks. Without this categorisation, many people would have trouble understanding the concepts.

    On your last part, why can't Flash Operator Panel recognise that that trunk is in use?? I am not really sure. Not having done a lot with non user authenticated SIP Trunks, I would begin to suspect that FOP does not see these as trunks, but I am taking a guess here. Maybe someone could offer a little more on this item.

    Regards

    Bob
     
  10. jandir

    Joined:
    Aug 24, 2008
    Messages:
    65
    Likes Received:
    0
    Bob,

    Thanks for the suggestion. I have turned off my inbound anonymous calls and verified that setting up the trunk does authenticate the incoming calls from IPKall.

    I do see it matching the peer in the SIP traces in asterisk CLI when the call comes in. I still do not see any indication of the incoming call in FOP. Not a big deal though.

    Thanks.
     
  11. lionrico

    Joined:
    Nov 24, 2009
    Messages:
    4
    Likes Received:
    0
    Re:How to assing a DID to a SIP Trunk

    Dear Bob,

    I am a newbie in the Elastix/Asterisk field, but have quite experience in Telephony nd telecoms.
    So here is my question:
    It is true that SIP route/trunk is like a conduit for DID numbers coming from SIP provider, but if the SIP provider does not provide DID number?
    For example, we have installed an Elastix system with 2 Skype trunks. We want to segregate each trunk to be directed to a specific extension. Is there a way to force a SIP trunk (in our case Skype trunk) to have a fixed DID?

    Please let me know if I explained myself well.

    Rgds
    Richard
     

Share This Page