PJSIP Config Generator
Fill in your SIP trunk, how many phones you need and whether the server sits behind NAT, and get a pjsip.conf and an extensions.conf you can read, check and load. Written for Asterisk 16 to 24 with res_pjsip.
Asterisk
Asterisk version
Transport
The private range your phones are on, in CIDR form.
SIP trunk
How the provider recognises you
Stays in your browser. Leave empty to write a placeholder.
Extensions and dialling
Codecs
Opus needs the codec_opus module.
Dialled before an outside number and removed before the call goes to the trunk. Leave empty for none.
Extension passwords are random and made in your browser.
pjsip.conf
; pjsip.conf written by the free generator at https://www.chaudharyusama.com/tools/pjsip-config-generator ; Read it through and replace the placeholders before loading it on a live system. ; ---- Transport ---- [transport-udp] type=transport protocol=udp bind=0.0.0.0:5060 ; NAT: the public address Asterisk gives to phones and the provider local_net=192.168.0.0/16 external_media_address=203.0.113.10 external_signaling_address=203.0.113.10 ; ---- SIP trunk ---- [mytrunk-auth] type=auth auth_type=digest username=YOUR_SIP_USERNAME password=YOUR_SIP_PASSWORD [mytrunk-reg] type=registration transport=transport-udp outbound_auth=mytrunk-auth server_uri=sip:sip.example-provider.com client_uri=sip:YOUR_SIP_USERNAME@sip.example-provider.com retry_interval=60 forbidden_retry_interval=600 expiration=3600 [mytrunk] type=aor contact=sip:sip.example-provider.com qualify_frequency=60 [mytrunk] type=endpoint transport=transport-udp context=from-trunk disallow=all allow=ulaw,alaw aors=mytrunk outbound_auth=mytrunk-auth from_user=YOUR_SIP_USERNAME from_domain=sip.example-provider.com direct_media=no rtp_symmetric=yes force_rport=yes rewrite_contact=yes [mytrunk] type=identify endpoint=mytrunk match=sip.example-provider.com ; ---- Templates shared by every phone ---- [phone-endpoint](!) type=endpoint transport=transport-udp context=internal disallow=all allow=ulaw,alaw direct_media=no dtmf_mode=rfc4733 rtp_symmetric=yes force_rport=yes rewrite_contact=yes [phone-auth](!) type=auth auth_type=digest [phone-aor](!) type=aor max_contacts=1 remove_existing=yes qualify_frequency=60 ; ---- Extensions ---- [1001](phone-endpoint) auth=1001 aors=1001 callerid="1001" <1001> [1001](phone-auth) username=1001 password=CHANGE_ME [1001](phone-aor) [1002](phone-endpoint) auth=1002 aors=1002 callerid="1002" <1002> [1002](phone-auth) username=1002 password=CHANGE_ME [1002](phone-aor) [1003](phone-endpoint) auth=1003 aors=1003 callerid="1003" <1003> [1003](phone-auth) username=1003 password=CHANGE_ME [1003](phone-aor) [1004](phone-endpoint) auth=1004 aors=1004 callerid="1004" <1004> [1004](phone-auth) username=1004 password=CHANGE_ME [1004](phone-aor) [1005](phone-endpoint) auth=1005 aors=1005 callerid="1005" <1005> [1005](phone-auth) username=1005 password=CHANGE_ME [1005](phone-aor) [1006](phone-endpoint) auth=1006 aors=1006 callerid="1006" <1006> [1006](phone-auth) username=1006 password=CHANGE_ME [1006](phone-aor) [1007](phone-endpoint) auth=1007 aors=1007 callerid="1007" <1007> [1007](phone-auth) username=1007 password=CHANGE_ME [1007](phone-aor) [1008](phone-endpoint) auth=1008 aors=1008 callerid="1008" <1008> [1008](phone-auth) username=1008 password=CHANGE_ME [1008](phone-aor) [1009](phone-endpoint) auth=1009 aors=1009 callerid="1009" <1009> [1009](phone-auth) username=1009 password=CHANGE_ME [1009](phone-aor) [1010](phone-endpoint) auth=1010 aors=1010 callerid="1010" <1010> [1010](phone-auth) username=1010 password=CHANGE_ME [1010](phone-aor)
extensions.conf
; extensions.conf written by the free generator at https://www.chaudharyusama.com/tools/pjsip-config-generator
; Read it through and replace the placeholders before loading it on a live system.
; ---- Phones: calls to each other ----
[internal]
exten => _100[1-9],1,Dial(PJSIP/${EXTEN},30)
same => n,Hangup()
exten => _1010,1,Dial(PJSIP/${EXTEN},30)
same => n,Hangup()
; ---- Phones: outside calls through the trunk ----
exten => _9X.,1,NoOp(Outbound call to ${EXTEN:1})
same => n,Dial(PJSIP/${EXTEN:1}@mytrunk,60)
same => n,Hangup()
; ---- Incoming calls from the trunk ----
[from-trunk]
exten => _[+0-9].,1,NoOp(Incoming call to ${EXTEN} from ${CALLERID(num)})
same => n,Dial(PJSIP/1001,30)
same => n,Hangup()
exten => s,1,Goto(from-trunk,1001,1)
; Load it with: asterisk -rx "dialplan reload"
Back up the old files, put these in /etc/asterisk, then run pjsip reload and dialplan reload.
What the generator writes
A transport (UDP, TCP or TLS) with the NAT settings Asterisk needs on a cloud server; a SIP trunk as the separate auth, registration, aor, endpoint and identify sections PJSIP expects; and your extensions, built from three templates so each phone takes a few lines instead of thirty. The extensions.conf lets phones call each other and dial out through the trunk, and puts incoming calls in their own context, so a caller from outside can never dial out through your trunk.
NAT, the usual cause of one-way audio
When Asterisk runs on a cloud server or behind a router, it must give phones and the provider its public address, or the audio goes to a private IP that nobody can reach. external_media_address and external_signaling_address carry the public IP, local_net lists the networks that do not need it, and rtp_symmetric, force_rport and rewrite_contact send replies back to where packets really came from. Open the RTP range (UDP 10000 to 20000 by default, set in rtp.conf) on the firewall as well as the SIP port.
Before you go live
A SIP port on the internet gets scanned within hours. Keep the long random passwords the generator makes, allow SIP only from your provider and your offices where you can, run fail2ban on the security log, and keep inbound calls in their own context. Load the files with pjsip reload and dialplan reload, then check pjsip show registrations and pjsip show endpoints before you move real traffic.
Frequently asked
- Which Asterisk versions does this work with?
- Asterisk 16 to 24 with the PJSIP channel driver (res_pjsip), the only SIP driver left since chan_sip was removed in Asterisk 21. FreePBX writes its own PJSIP files, so use its web interface there instead.
- Should auth_type be userpass or digest?
- Asterisk 20.12, 21.7 and 22.2 introduced auth_type=digest and treat userpass as a deprecated alias that is converted when the file loads. Pick your version and the generator writes the right one; both work with a plain-text password.
- Registration or IP authentication for the trunk?
- Use registration when the provider gave you a username and password, which is usual for small trunks and when your IP can change. Use IP authentication when the provider has allowed your server's fixed IP; then list the provider's signalling IPs so only they reach the trunk.
- The call connects but there is no audio. Why?
- Almost always NAT or a firewall. Check that the public IP is right, that local_net covers your LAN, and that the RTP port range is open. With pjsip set logger on you can read the SDP: the address in it should be your public IP.
- Is anything I type sent to a server?
- No. The page builds the files in your browser, and the extension passwords are random values made by your browser. Nothing is saved or sent.
Need a call centre built on Asterisk?
I build and run Asterisk systems for call centres: dialplans, queues, recordings, CRM integration and AI voice agents, with Laravel dashboards on top.
More free tools
- AI Prompt BuilderTurn a rough request into a clear prompt for ChatGPT, Claude or Gemini, in any answer language.
- MVP Scope PlannerDecide what goes in your app's first version and get a one-page plan with complexity and a timeline range.
- AI API Cost CalculatorEstimate your monthly AI API bill and compare OpenAI, Claude and Gemini models side by side.
- GitHub README GeneratorWrite a GitHub profile or project README with a live preview, skill icons and stats cards.
- Automation ROI CalculatorSee how many hours automating a task saves and how many months it takes to pay for itself.
- Call Center Cost CalculatorCompare Twilio with a self-hosted Asterisk server and SIP trunk, and see when self-hosting pays off.
- Meta Tag GeneratorWrite your title, description and share tags, preview them in Google and link previews, and copy the HTML.