Register a sip client to asterisk

Register a sip client to asterisk

In sip.conf under [general] add a register definition:

Format:
register => user[:secret[:authuser]]@host[:port][/extension]

or
register => fromuser@fromdomain:secret@host

or
register => fromuser@fromdomain:secret:authuser@host:port/extension

If you have problems with your network connection going up and down (e.g. an unreliable cable connection) and you keep losing your sip registry, you may want to add registerattempts and registertimeout settings to the general section above the register definitions. Setting registerattempts=0 will force Asterisk to attempt to reregister until it can (the default is 10 tries). registertimeout sets the length of time in seconds between registration attempts (the default is 20 seconds).

Example:

  ; Register 2345@mysipprovider.com with authname 2345 at mysipprovider.com at sip provider as 1234 here:
  register => 2345:password@mysipprovider.com/1234
  ; Register 1235@mysipprovider.com with authname 1235 and realm mysipprovider.com at proxyof.mysipprovider.com as s here.
  ; (as needed by budgetphone.nl):
  register => 1235@mysipprovider.com:password:1235@proxyof.mysipprovider.com

 

  • user is the user id for this SIP server (ex 2345)
  • authuser is the optional authorization user for the SIP server
  • secret is the user’s password
  • host is the domain or host name for the SIP server. This SIP server needs a definition in a section of its own in SIP.conf (mysipprovider.com).
  • port send the register request to this port at host. Defaults to 5060
  • /1234 is the Asterisk contact extension. 1234 is put into the contact header in the SIP Register message. The contact extension is used by remote SIP server when it needs to send a call to Asterisk. See the example below. The default context extension is “s”.

Check the success of your own server’s registrations at the CLI with SIP SHOW REGISTRY, whereas you can obtain a list of clients that registered with your server with the help of SIP SHOW PEERS. You may examine all details of a peer’s registration with SIP SHOW PEER <NAME>

 

The server definition for outgoing calls looks like this:

[mysipprovider-out]
type=peer
secret=password
username=2345
host=sipserver.mysipprovider.com
fromuser=2345
fromdomain=fwd.pulver.com
canreinvite=no
insecure=invite,port
qualify=yes
nat=yes
context=from-mysipprovider ; this section will be defined in extensions.conf

In extensions.conf you’d then use a statement like this:

exten => _9.,1,Dial(SIP/${EXTEN:1}@mysipprovider-out,30,r)