1 ; PJSIP Configuration Samples and Quick Reference
3 ; This file has several very basic configuration examples, to serve as a quick
4 ; reference to jog your memory when you need to write up a new configuration.
5 ; It is not intended to teach PJSIP configuration or serve as an exhaustive
6 ; reference of options and potential scenarios.
8 ; This file has two main sections.
9 ; First, manually written examples to serve as a handy reference.
10 ; Second, a list of all possible PJSIP config options by section. This is
11 ; pulled from the XML config help. It only shows the synopsis for every item.
12 ; If you want to see more detail please check the documentation sources
13 ; mentioned at the top of this file.
17 ; The official documentation is at http://wiki.asterisk.org
18 ; You can read the XML configuration help via Asterisk command line with
19 ; "config show help res_pjsip", then you can drill down through the various
20 ; sections and their options.
23 ;========!!!!!!!!!!!!!!!!!!! SECURITY NOTICE !!!!!!!!!!!!!!!!!!!!===========
25 ; At a minimum please read the file "README-SERIOUSLY.bestpractices.txt",
26 ; located in the Asterisk source directory before starting Asterisk.
27 ; Otherwise you risk allowing the security of the Asterisk system to be
28 ; compromised. Beyond that please visit and read the security information on
29 ; the wiki at: https://wiki.asterisk.org/wiki/x/EwFB
31 ; A few basics to pay attention to:
35 ; By default anonymous inbound calls via PJSIP are not allowed. If you want to
36 ; route anonymous calls you'll need to define an endpoint named "anonymous".
37 ; res_pjsip_endpoint_identifier_anonymous.so handles that functionality so it
38 ; must be loaded. It is not recommended to accept anonymous calls.
40 ; Access Control Lists
42 ; See the example ACL configuration in this file. Read the configuration help
43 ; for the section and all of its options. Look over the samples in acl.conf
44 ; and documentation at https://wiki.asterisk.org/wiki/x/uA80AQ
45 ; If possible, restrict access to only networks and addresses you trust.
49 ; When defining configuration (such as an endpoint) that links into
50 ; dialplan configuration, be aware of what that dialplan does. It's easy to
51 ; accidentally provide access to internal or outbound dialing extensions which
52 ; could cost you severely. The "context=" line in endpoint configuration
53 ; determines which dialplan context inbound calls will enter into.
55 ;=============================================================================
57 ; Overview of Configuration Section Types Used in the Examples
59 ; * Transport "transport"
60 ; * Configures res_pjsip transport layer interaction.
61 ; * Endpoint "endpoint"
62 ; * Configures core SIP functionality related to SIP endpoints.
63 ; * Authentication "auth"
64 ; * Stores inbound or outbound authentication credentials for use by trunks,
65 ; endpoints, registrations.
66 ; * Address of Record "aor"
67 ; * Stores contact information for use by endpoints.
68 ; * Endpoint Identification "identify"
69 ; * Maps a host directly to an endpoint
70 ; * Access Control List "acl"
71 ; * Defines a permission list or references one stored in acl.conf
72 ; * Registration "registration"
73 ; * Contains information about an outbound SIP registration
75 ; The following sections show example configurations for various scenarios.
76 ; Most require a couple or more configuration types configured in concert.
78 ;===============EXAMPLE TRANSPORTS============================================
80 ; A few examples for potential transport options.
82 ; For the NAT transport example, be aware that the options starting with
83 ; the prefix "external_" will only apply to communication with addresses
84 ; outside the range set with "localnet=".
86 ; IPv6: For endpoints using IPv6, remember to set "rtp_ipv6=yes" so that the RTP
87 ; engine will also be able to bind to an IPv6 address.
89 ; You can have more than one of any type of transport, as long as it doesn't
90 ; use the same resources (bind address, port, etc) as the others.
96 ;protocol=udp ;udp,tcp,tls,ws,wss
99 ; UDP transport behind NAT
105 ;localnet=192.0.2.0/24
106 ;external_media_address=203.0.113.1
107 ;external_signaling_address=203.0.113.1
109 ; Basic IPv6 UDP transport
111 ;[transport-udp-ipv6]
116 ; Example IPv4 TLS transport
122 ;cert_file=/path/mycert.crt
123 ;privkey_file=/path/mykey.key
128 ;===============OUTBOUND REGISTRATION WITH OUTBOUND AUTHENTICATION============
130 ; This is a simple registration that works with some SIP trunking providers.
131 ; You'll need to set up the auth example "mytrunk_auth" below to enable outbound
132 ; authentication. Note that we "outbound_auth=" use for outbound authentication
133 ; instead of "auth=", which is for inbound authentication.
135 ; If you are registering to a server from behind NAT, be sure you assign a transport
136 ; that is appropriately configured with NAT related settings. See the NAT transport example.
138 ; "contact_user=" sets the SIP contact header's user portion of the SIP URI
139 ; this will affect the extension reached in dialplan when the far end calls you at this
140 ; registration. The default is 's'.
144 ;transport=transport-udp
145 ;outbound_auth=mytrunk_auth
146 ;server_uri=sip:sip.example.com
147 ;client_uri=sip:1234567890@sip.example.com
148 ;contact_user=1234567890
150 ;forbidden_retry_interval=600
158 ;realm=sip.example.com
160 ;===============ENDPOINT CONFIGURED AS A TRUNK, OUTBOUND AUTHENTICATION=======
162 ; This is one way to configure an endpoint as a trunk. It is set up with
163 ; "outbound_auth=" to enable authentication when dialing out through this
164 ; endpoint. There is no inbound authentication set up since a provider will
165 ; not normally authenticate when calling you.
167 ; The identify configuration enables IP address matching against this endpoint.
168 ; For calls from a trunking provider, the From user may be different every time,
169 ; so we want to match against IP address instead of From user.
171 ; If you want the provider of your trunk to know where to send your calls
172 ; you'll need to use an outbound registration as in the example above this
177 ; At a basic level configure the endpoint with a transport that is set up
178 ; with the appropriate NAT settings. There may be some additional settings you
179 ; need here based on your NAT/Firewall scenario. Look to the CLI config help
180 ; "config show help res_pjsip endpoint" or on the wiki for other NAT related
181 ; options and configuration. We've included a few below.
185 ; Endpoints use one or more AOR sections to store their contact details.
186 ; You can define multiple contact addresses in SIP URI format in multiple
187 ; "contact=" entries.
191 ; Sections can have the same name as long as their "type="
192 ; options are set to different values.
196 ;transport=transport-udp
197 ;context=from-external
200 ;outbound_auth=mytrunk
202 ; ;A few NAT relevant options that may come in handy.
203 ;force_rport=yes ;It's a good idea to read the configuration help for each
204 ;direct_media=no ;of these options.
209 ;contact=sip:198.51.100.1:5060
210 ;contact=sip:198.51.100.2:5060
219 ;=============ENDPOINT CONFIGURED AS A TRUNK, INBOUND AUTH AND REGISTRATION===
221 ; Here we are allowing a remote device to register to Asterisk and requiring
222 ; that they authenticate for registration and calls.
223 ; You'll note that this configuration is essentially the same as configuring
224 ; an endpoint for use with a SIP phone.
229 ;context=from-external
232 ;transport=transport-udp
247 ;===============ENDPOINT CONFIGURED FOR USE WITH A SIP PHONE==================
249 ; This example includes the endpoint, auth and aor configurations. It
250 ; requires inbound authentication and allows registration, as well as references
251 ; a transport that you'll need to uncomment from the previous examples.
253 ; Uncomment one of the transport lines to choose which transport you want. If
254 ; not specified then the default transport chosen is the first defined transport
255 ; in the configuration file.
257 ; Modify the "max_contacts=" line to change how many unique registrations to allow.
259 ; Use the "contact=" line instead of max_contacts= if you want to statically
260 ; define the location of the device.
262 ; If using the TLS enabled transport, you may want the "media_encryption=yes"
263 ; option to additionally enable SRTP, though they are not mutually inclusive.
265 ; Use the "rtp_ipv6=yes" option if you want to utilize RTP over an ipv6 transport.
267 ; If this endpoint were remote, and it was using a transport configured for NAT
268 ; then you likely want to use "direct_media=no" to prevent audio issues.
273 ;transport=transport-udp
274 ;context=from-internal
281 ; A few more transports to pick from, and some related options below them.
283 ;transport=transport-tls
284 ;media_encryption=yes
285 ;transport=transport-udp-ipv6
287 ;transport=transport-udp-nat
290 ; MWI related options
293 ;mailboxes=6001@default,7001@default
296 ; Extension and Device state options
298 ;devicestate_busy_at=1
311 ;contact=sip:6001@192.0.2.1:5060
314 ;============EXAMPLE ACL CONFIGURATION==========================================
316 ; The ACL or Access Control List section defines a set of permissions to permit
317 ; or deny access to various address or addresses. Alternatively it references an
318 ; ACL configuration already set in acl.conf.
320 ; The ACL configuration is independent of individual endpoint configuration and
321 ; operates on all inbound SIP communication using res_pjsip.
323 ; Reference an ACL defined in acl.conf.
327 ;acl=example_named_acl1
329 ; Reference a contactacl specifically.
333 ;contactacl=example_contact_acl1
335 ; Define your own ACL here in pjsip.conf and
336 ; permit or deny by IP address or range.
340 ;deny=0.0.0.0/0.0.0.0
341 ;permit=209.16.236.0/24
344 ; Restrict based on Contact Headers rather than IP.
345 ; Define options multiple times for various addresses or use a comma-delimited string.
349 ;contactdeny=0.0.0.0/0.0.0.0
350 ;contactpermit=209.16.236.0/24
351 ;contactpermit=209.16.236.1
352 ;contactpermit=209.16.236.2,209.16.236.3
354 ; Restrict based on Contact Headers rather than IP and use
355 ; advanced syntax. Note the bang symbol used for "NOT", so we can deny
356 ; 209.16.236.12/32 within the permit= statement.
360 ;contactdeny=0.0.0.0/0.0.0.0
361 ;contactpermit=209.16.236.0
362 ;permit=209.16.236.0/24, !209.16.236.12/32
366 ; MODULE PROVIDING BELOW SECTION(S): res_pjsip
367 ;==========================ENDPOINT SECTION OPTIONS=========================
370 ;100rel=yes ; Allow support for RFC3262 provisional ACK tags (default:
372 ;aggregate_mwi=yes ; (default: "yes")
373 ;allow= ; Media Codec s to allow (default: "")
374 ;aors= ; AoR s to be used with the endpoint (default: "")
375 ;auth= ; Authentication Object s associated with the endpoint (default: "")
376 ;callerid= ; CallerID information for the endpoint (default: "")
377 ;callerid_privacy= ; Default privacy level (default: "")
378 ;callerid_tag= ; Internal id_tag for the endpoint (default: "")
379 ;context=default ; Dialplan context for inbound sessions (default:
381 ;direct_media_glare_mitigation=none ; Mitigation of direct media re INVITE
382 ; glare (default: "none")
383 ;direct_media_method=invite ; Direct Media method type (default: "invite")
384 ;connected_line_method=invite ; Connected line method type (default:
386 ;direct_media=yes ; Determines whether media may flow directly between
387 ; endpoints (default: "yes")
388 ;disable_direct_media_on_nat=no ; Disable direct media session refreshes when
389 ; NAT obstructs the media session (default:
391 ;disallow= ; Media Codec s to disallow (default: "")
392 ;dtmf_mode=rfc4733 ; DTMF mode (default: "rfc4733")
393 ;external_media_address= ; IP used for External Media handling (default:
395 ;force_rport=yes ; Force use of return port (default: "yes")
396 ;ice_support=no ; Enable the ICE mechanism to help traverse NAT (default: "no")
397 ;identify_by=username ; Way s for Endpoint to be identified (default:
399 ;mailboxes= ; Mailbox es to be associated with (default: "")
400 ;moh_suggest=default ; Default Music On Hold class (default: "default")
401 ;outbound_auth= ; Authentication object used for outbound requests (default:
403 ;outbound_proxy= ; Proxy through which to send requests (default: "")
404 ;rewrite_contact=no ; Allow Contact header to be rewritten with the source
405 ; IP address port (default: "no")
406 ;rtp_ipv6=no ; Allow use of IPv6 for RTP traffic (default: "no")
407 ;rtp_symmetric=no ; Enforce that RTP must be symmetric (default: "no")
408 ;send_diversion=yes ; Send the Diversion header conveying the diversion
409 ; information to the called user agent (default: "yes")
410 ;send_pai=no ; Send the P Asserted Identity header (default: "no")
411 ;send_rpid=no ; Send the Remote Party ID header (default: "no")
412 ;timers_min_se=90 ; Minimum session timers expiration period (default:
414 ;timers=yes ; Session timers for SIP packets (default: "yes")
415 ;timers_sess_expires=1800 ; Maximum session timer expiration period
417 ;transport= ; Desired transport configuration (default: "")
418 ;trust_id_inbound=no ; Accept identification information received from this
419 ; endpoint (default: "no")
420 ;trust_id_outbound=no ; Send private identification details to the endpoint
422 ;type= ; Must be of type endpoint (default: "")
423 ;use_ptime=no ; Use Endpoint s requested packetisation interval (default:
425 ;use_avpf=no ; Determines whether res_pjsip will use and enforce usage of
426 ; AVPF for this endpoint (default: "no")
427 ;media_encryption=no ; Determines whether res_pjsip will use and enforce
428 ; usage of media encryption for this endpoint (default:
430 ;inband_progress=no ; Determines whether chan_pjsip will indicate ringing
431 ; using inband progress (default: "no")
432 ;call_group= ; The numeric pickup groups for a channel (default: "")
433 ;pickup_group= ; The numeric pickup groups that a channel can pickup (default:
435 ;named_call_group= ; The named pickup groups for a channel (default: "")
436 ;named_pickup_group= ; The named pickup groups that a channel can pickup
438 ;device_state_busy_at=0 ; The number of in use channels which will cause busy
439 ; to be returned as device state (default: "0")
440 ;t38_udptl=no ; Whether T 38 UDPTL support is enabled or not (default: "no")
441 ;t38_udptl_ec=none ; T 38 UDPTL error correction method (default: "none")
442 ;t38_udptl_maxdatagram=0 ; T 38 UDPTL maximum datagram size (default: "0")
443 ;fax_detect=no ; Whether CNG tone detection is enabled (default: "no")
444 ;t38_udptl_nat=no ; Whether NAT support is enabled on UDPTL sessions
446 ;t38_udptl_ipv6=no ; Whether IPv6 is used for UDPTL Sessions (default:
448 ;tone_zone= ; Set which country s indications to use for channels created
449 ; for this endpoint (default: "")
450 ;language= ; Set the default language to use for channels created for this
451 ; endpoint (default: "")
452 ;one_touch_recording=no ; Determines whether one touch recording is allowed for
453 ; this endpoint (default: "no")
454 ;record_on_feature=automixmon ; The feature to enact when one touch recording
455 ; is turned on (default: "automixmon")
456 ;record_off_feature=automixmon ; The feature to enact when one touch recording
457 ; is turned off (default: "automixmon")
458 ;rtp_engine=asterisk ; Name of the RTP engine to use for channels created
459 ; for this endpoint (default: "asterisk")
460 ;allow_transfer=yes ; Determines whether SIP REFER transfers are allowed
461 ; for this endpoint (default: "yes")
462 ;sdp_owner=- ; String placed as the username portion of an SDP origin o line
464 ;sdp_session=Asterisk ; String used for the SDP session s line (default:
466 ;tos_audio=0 ; DSCP TOS bits for audio streams (default: "0")
467 ;tos_video=0 ; DSCP TOS bits for video streams (default: "0")
468 ;cos_audio=0 ; Priority for audio streams (default: "0")
469 ;cos_video=0 ; Priority for video streams (default: "0")
470 ;allow_subscribe=yes ; Determines if endpoint is allowed to initiate
471 ; subscriptions with Asterisk (default: "yes")
472 ;sub_min_expiry=0 ; The minimum allowed expiry time for subscriptions initiated
473 ; by the endpoint (default: "0")
474 ;from_user= ; Username to use in From header for requests to this endpoint
476 ;mwi_from_user= ; Username to use in From header for unsolicited MWI NOTIFYs to
477 ; this endpoint (default: "")
478 ;fromdomain= ; Domain to user in From header for requests to this endpoint
480 ;dtls_verify= ; Verify that the provided peer certificate is valid (default:
482 ;dtls_rekey= ; Interval at which to renegotiate the TLS session and rekey
483 ; the SRTP session (default: "")
484 ;dtls_cert_file= ; Path to certificate file to present to peer (default: "")
485 ;dtls_private_key= ; Path to private key for certificate file (default:
487 ;dtls_cipher= ; Cipher to use for DTLS negotiation (default: "")
488 ;dtls_ca_file= ; Path to certificate authority certificate (default: "")
489 ;dtls_ca_path= ; Path to a directory containing certificate authority
490 ; certificates (default: "")
491 ;dtls_setup= ; Whether we are willing to accept connections connect to the
492 ; other party or both (default: "")
493 ;srtp_tag_32=no ; Determines whether 32 byte tags should be used instead of 80
494 ; byte tags (default: "no")
497 ;==========================AUTH SECTION OPTIONS=========================
499 ; SYNOPSIS: Authentication type
500 ;auth_type=userpass ; Authentication type (default: "userpass")
501 ;nonce_lifetime=32 ; Lifetime of a nonce associated with this
502 ; authentication config (default: "32")
503 ;md5_cred= ; MD5 Hash used for authentication (default: "")
504 ;password= ; PlainText password used for authentication (default: "")
505 ;realm=asterisk ; SIP realm for endpoint (default: "asterisk")
506 ;type= ; Must be auth (default: "")
507 ;username= ; Username to use for account (default: "")
510 ;==========================DOMAIN_ALIAS SECTION OPTIONS=========================
512 ; SYNOPSIS: Domain Alias
513 ;type= ; Must be of type domain_alias (default: "")
514 ;domain= ; Domain to be aliased (default: "")
517 ;==========================TRANSPORT SECTION OPTIONS=========================
519 ; SYNOPSIS: SIP Transport
520 ;async_operations=1 ; Number of simultaneous Asynchronous Operations
522 ;bind= ; IP Address and optional port to bind to for this transport (default:
524 ;ca_list_file= ; File containing a list of certificates to read TLS ONLY
526 ;cert_file= ; Certificate file for endpoint TLS ONLY (default: "")
527 ;cipher= ; Preferred Cryptography Cipher TLS ONLY (default: "")
528 ;domain= ; Domain the transport comes from (default: "")
529 ;external_media_address= ; External Address to use in RTP handling
531 ;external_signaling_address= ; External address for SIP signalling (default:
533 ;external_signaling_port=0 ; External port for SIP signalling (default:
535 ;method= ; Method of SSL transport TLS ONLY (default: "")
536 ;local_net= ; Network to consider local used for NAT purposes (default: "")
537 ;password= ; Password required for transport (default: "")
538 ;priv_key_file= ; Private key file TLS ONLY (default: "")
539 ;protocol=udp ; Protocol to use for SIP traffic (default: "udp")
540 ;require_client_cert= ; Require client certificate TLS ONLY (default: "")
541 ;type= ; Must be of type transport (default: "")
542 ;verify_client= ; Require verification of client certificate TLS ONLY (default:
544 ;verify_server= ; Require verification of server certificate TLS ONLY (default:
546 ;tos=0 ; Enable TOS for the signalling sent over this transport (default: "0")
547 ;cos=0 ; Enable COS for the signalling sent over this transport (default: "0")
550 ;==========================CONTACT SECTION OPTIONS=========================
552 ; SYNOPSIS: A way of creating an aliased name to a SIP URI
553 ;type= ; Must be of type contact (default: "")
554 ;uri= ; SIP URI to contact peer (default: "")
555 ;expiration_time= ; Time to keep alive a contact (default: "")
556 ;qualify_frequency=0 ; Interval at which to qualify a contact (default: "0")
559 ;==========================AOR SECTION OPTIONS=========================
561 ; SYNOPSIS: The configuration for a location of an endpoint
562 ;contact= ; Permanent contacts assigned to AoR (default: "")
563 ;default_expiration=3600 ; Default expiration time in seconds for
564 ; contacts that are dynamically bound to an AoR
566 ;mailboxes= ; Mailbox es to be associated with (default: "")
567 ;maximum_expiration=7200 ; Maximum time to keep an AoR (default: "7200")
568 ;max_contacts=0 ; Maximum number of contacts that can bind to an AoR (default:
570 ;minimum_expiration=60 ; Minimum keep alive time for an AoR (default: "60")
571 ;remove_existing=no ; Determines whether new contacts replace existing ones
573 ;type= ; Must be of type aor (default: "")
574 ;qualify_frequency=0 ; Interval at which to qualify an AoR (default: "0")
575 ;authenticate_qualify=no ; Authenticates a qualify request if needed
579 ;==========================SYSTEM SECTION OPTIONS=========================
581 ; SYNOPSIS: Options that apply to the SIP stack as well as other system-wide settings
582 ;timer_t1=500 ; Set transaction timer T1 value milliseconds (default: "500")
583 ;timer_b=32000 ; Set transaction timer B value milliseconds (default: "32000")
584 ;compact_headers=no ; Use the short forms of common SIP header names
586 ;threadpool_initial_size=0 ; Initial number of threads in the res_pjsip
587 ; threadpool (default: "0")
588 ;threadpool_auto_increment=5 ; The amount by which the number of threads is
589 ; incremented when necessary (default: "5")
590 ;threadpool_idle_timeout=60 ; Number of seconds before an idle thread
591 ; should be disposed of (default: "60")
592 ;threadpool_max_size=0 ; Maximum number of threads in the res_pjsip threadpool
593 ; A value of 0 indicates no maximum (default: "0")
594 ;type= ; Must be of type system (default: "")
597 ;==========================GLOBAL SECTION OPTIONS=========================
599 ; SYNOPSIS: Options that apply globally to all SIP communications
600 ;max_forwards=70 ; Value used in Max Forwards header for SIP requests (default:
602 ;type= ; Must be of type global (default: "")
603 ;user_agent= ; Value used in User Agent header for SIP requests and Server
604 ; header for SIP responses (default: Populated by Asterisk
610 ; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl
611 ;==========================ACL SECTION OPTIONS=========================
613 ; SYNOPSIS: Access Control List
614 ;acl= ; Name of IP ACL (default: "")
615 ;contact_acl= ; Name of Contact ACL (default: "")
616 ;contact_deny= ; List of Contact Header addresses to Deny (default: "")
617 ;contact_permit= ; List of Contact Header addresses to Permit (default: "")
618 ;deny= ; List of IP domains to deny access from (default: "")
619 ;permit= ; List of IP domains to allow access from (default: "")
620 ;type= ; Must be of type security (default: "")
625 ; MODULE PROVIDING BELOW SECTION(S): res_pjsip_outbound_registration
626 ;==========================REGISTRATION SECTION OPTIONS=========================
628 ; SYNOPSIS: The configuration for outbound registration
629 ;auth_rejection_permanent=yes ; Determines whether failed authentication
630 ; challenges are treated as permanent failures
632 ;client_uri= ; Client SIP URI used when attemping outbound registration
634 ;contact_user= ; Contact User to use in request (default: "")
635 ;expiration=3600 ; Expiration time for registrations in seconds
637 ;max_retries=10 ; Maximum number of registration attempts (default: "10")
638 ;outbound_auth= ; Authentication object to be used for outbound registrations
640 ;outbound_proxy= ; Outbound Proxy used to send registrations (default:
642 ;retry_interval=60 ; Interval in seconds between retries if outbound
643 ; registration is unsuccessful (default: "60")
644 ;server_uri= ; SIP URI of the server to register against (default: "")
645 ;transport= ; Transport used for outbound authentication (default: "")
646 ;type= ; Must be of type registration (default: "")
651 ; MODULE PROVIDING BELOW SECTION(S): res_pjsip_endpoint_identifier_ip
652 ;==========================IDENTIFY SECTION OPTIONS=========================
654 ; SYNOPSIS: NEEDS A SYNOPSIS
655 ;endpoint= ; Name of Endpoint (default: "")
656 ;match= ; IP addresses or networks to match against (default: "")
657 ;type= ; Must be of type identify (default: "")