Howwise RSS
VoIP & Phone Systems8 min read

chan_sip vs pjsip: Migration Runbook and Setting Map

Short answer

The main difference in chan_sip vs pjsip is that chan_sip uses one [peer] section per device, while PJSIP splits each device into endpoint, aor and auth objects. chan_sip is removed in Asterisk 21, so extensions and trunks must move.

Key takeaways
  • chan_sip was deprecated in Asterisk 17 and removed in Asterisk 21, and FreePBX 17 is PJSIP-only, so any upgrade path forces the migration.
  • Each chan_sip peer becomes at least three PJSIP objects: endpoint (media and routing), aor (registration contact limits) and auth (credentials).
  • Both drivers default to UDP 5060, so move one of them (for example chan_sip to 5160) before running them side by side.
  • In FreePBX an extension number cannot exist in both drivers at once, so pilot one extension at a time and keep the old config and a backup for rollback.
  • Trunks need manual rebuilding as registration, auth, aor, endpoint and identify objects, and Fail2ban jails must be updated to watch PJSIP log lines.

What is the real difference between chan_sip and PJSIP?

chan_sip is the legacy SIP channel driver configured in sip.conf. Each phone or trunk is a single [peer] section that mixes credentials, media, NAT and registration behaviour. It was deprecated in Asterisk 17 and removed in Asterisk 21.

chan_pjsip is built on the PJSIP library and configured in pjsip.conf. It splits every device into separate objects, so one registration can be shared, reused or matched in different ways. FreePBX 13 added chan_pjsip as an option, and later releases made it the default for new extensions. FreePBX 15 and 16 support both drivers, and FreePBX 17 is PJSIP-only.

The object model is the main thing to learn. Most migration errors come from misplacing a setting on the wrong object, not from the settings themselves.

PJSIP objectJobTypical settings
transportSocket Asterisk listens ontype=transport, protocol=udp, bind=0.0.0.0:5060, external_signaling_address, local_net
endpointCall behaviour for one device or trunkcontext, disallow/allow, aors, auth, direct_media, dtmf_mode, force_rport, rtp_symmetric
aorWhere the device can be reachedmax_contacts, qualify_frequency, remove_existing, contact (for static trunks)
authCredentialsauth_type=userpass, username, password
identifyMatch inbound packets by source IPendpoint, match
registrationOutbound registration to a providerserver_uri, client_uri, outbound_auth, retry_interval

How do sip.conf settings map to PJSIP objects?

Use this table as a one-to-one translation sheet while you read through sip.conf. Settings that have no equivalent are listed in a later section.

chan_sip (sip.conf)PJSIP equivalentObject
host=dynamicmax_contacts=1 (or more)aor
secret=password= with auth_type=userpassauth
username=username=auth
context=context=endpoint
disallow= / allow=disallow= / allow=, same syntaxendpoint
nat=force_rport,comediaforce_rport=yes, rtp_symmetric=yes, rewrite_contact=yesendpoint
qualify=yesqualify_frequency=60 (seconds)aor
canreinvite=nodirect_media=noendpoint
dtmfmode=rfc2833dtmf_mode=rfc4733endpoint
insecure=invite / host=1.2.3.4identify section with match=1.2.3.4identify
register => user:pass@hostregistration with client_uri, server_uri, outbound_authregistration
bindport / udpbindbind= on the transporttransport
externip / localnetexternal_signaling_address, external_media_address, local_nettransport
Tip: For rfc2833 DTMF, the PJSIP value is rfc4733. Use inband only if a device cannot do RFC 4733, because it needs a clean G.711 audio path.

What does a minimal working pjsip.conf extension look like?

This is the smallest config for one registering phone. The endpoint names its auth and aor, and by default Asterisk identifies the inbound request by the username in the From header matching the endpoint name.

On plain Asterisk, put this in pjsip.conf. On FreePBX, do not edit pjsip.conf directly because it is regenerated. Use the GUI or pjsip_custom.conf.

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
; behind NAT, add:
;external_signaling_address=203.0.113.10
;external_media_address=203.0.113.10
;local_net=192.168.1.0/24

[1001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw,alaw
transport=transport-udp
auth=1001
aors=1001
direct_media=no
force_rport=yes
rtp_symmetric=yes
rewrite_contact=yes
dtmf_mode=rfc4733

[1001]
type=auth
auth_type=userpass
username=1001
password=UseALongRandomSecret1

[1001]
type=aor
max_contacts=1
remove_existing=yes
qualify_frequency=60

How do I verify the PJSIP extension is working?

Reload the module, then check each object type. A phone that shows Unavailable in the endpoint list but has no contact has not registered. A contact with status Unavail means the OPTIONS qualify is failing, which usually points to NAT or a firewall.

  1. Reload with module reload res_pjsip.so (or fwconsole reload on FreePBX).
  2. Run pjsip show endpoints and confirm the endpoint exists and shows Not in use.
  3. Run pjsip show aors to confirm max_contacts and the contact count.
  4. Run pjsip show contacts to see the registered address, port and RTT status (Avail or Unavail).
  5. If registration fails, run pjsip set logger on and watch with sngrep. A 401 with no retry means a wrong password. A 401 or 403 on a phone that does send credentials usually means the endpoint was not identified, so check that the From user matches the endpoint name.
asterisk -rx "module reload res_pjsip.so"
asterisk -rx "pjsip show endpoints"
asterisk -rx "pjsip show aors"
asterisk -rx "pjsip show contacts"
asterisk -rx "pjsip set logger on"
sngrep -d any port 5060

How do I avoid the chan_sip and PJSIP port conflict on 5060?

Both drivers default to UDP 5060. Whichever loads second fails to bind, and the symptom is usually a log line about being unable to bind, with the other stack's phones working and the new ones silent. Running both in parallel requires distinct ports.

In FreePBX, go to Settings > Asterisk SIP Settings. Set the chan_sip port (for example 5160) in the Chan SIP tab and the PJSIP port in the Chan PJSIP tab. Keeping the production phones on their current port and moving the new stack avoids repointing everything. Which stack to move depends on which one your phones already use.

On plain Asterisk, chan_sip uses bindport in the [general] section of sip.conf, and PJSIP uses bind= in the transport.

Phones moved to the new driver must be repointed to the new server port, and firewall and NAT rules must allow the added port.

; sip.conf  (legacy, moved aside)
[general]
bindport=5160

; pjsip.conf (new)
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
Warning: Changing a port on a live system drops registrations for every phone using it. Do it in a maintenance window, and confirm the firewall allows UDP 5160 (or your chosen port) from the phone networks before you reload.

Which FreePBX conversion method should I use?

FreePBX offers three routes. All of them convert extensions only. None of them rebuilds trunks, custom sip_general settings or provider registrations, so those need manual work.

One FreePBX rule drives the order of operations: an extension number cannot exist in both drivers at once. You switch the device driver on the existing extension, or create the new PJSIP extension after removing or changing the old one. You cannot create a second extension 1001 next to the first.

MethodBest forCarries overDoes not carry over
Convert to PJSIP option on the extension (or Chan_SIP to PJSIP converter in Connectivity)Many standard extensions at onceExtension number, secret, voicemail, CID, most core settingsCustom sip_general, sip_custom overrides, odd per-device options
Per-extension Device driver changePilot extensions and one-by-one cutoversExtension and its dialplan routingAnything stored only in chan_sip custom fields
Bulk Handler export, change tech column, importLarge or scripted movesEverything in the export CSVTrunks, registrations, anything not in the CSV; needs a clean test import first
Tip: Export the extensions from Bulk Handler before you convert anything. The CSV is a readable record of every setting and lets you restore the old tech value if a bulk import goes wrong.

Which behaviour differences break phones after migration?

Most failures come from behaviour, not syntax. These are the ones that cause tickets.

chan_sip identified a caller by peer name or IP, and PJSIP identifies by the From user, then by identify objects, so a mismatch yields 401 or 403 responses. Realtime peers do not behave identically in PJSIP, and host=dynamic does not exist because max_contacts replaces it.

call-limit has no equivalent. Use device state busy detection and the endpoint's device_state settings, or limit channels in the dialplan. BLF and MWI depend on the mailboxes= setting on the endpoint and on subscription handling, so re-test them. Auto-provisioned phones often carry the old port in their templates and need updating.

On FreePBX, sip_custom and sip_additional files are chan_sip specific. Customisations stored there are silently dropped for a converted extension, so diff them before and after.

SymptomLikely causeFix
401 or 403 on REGISTEREndpoint not identified, or wrong authMatch From user to endpoint name, check auth link
Phone registers then goes Unavailqualify or NAT problemSet force_rport, rewrite_contact, check firewall
Registered but no phone ringWrong port in provisioning templateUpdate the template and re-provision
One-way audioMissing external_media_address or local_netSet both on the transport
BLF lamps dead, no MWISubscriptions or mailboxes missingSet mailboxes= and test NOTIFY with sngrep
Fail2ban never bansJail watches chan_sip log linesUse a PJSIP-aware filter on the security log

How do I migrate trunks and run the pilot with a rollback?

A chan_sip trunk with register=> becomes five objects. Build them by hand, test them on the new port, and only then change routes.

Provider registration needs a registration object with client_uri, server_uri and outbound_auth, plus auth, aor, endpoint and an identify with match for the provider IP. Set from_user and from_domain on the endpoint if the provider needs a specific From header, and set contact on the aor if the provider is static.

  1. Back up with fwconsole backup, and copy sip.conf, pjsip.conf and the asterisk database.
  2. Open a maintenance window, and define go/no-go criteria before you start (for example all test calls pass and no registration failures after 30 minutes).
  3. Move chan_sip to its own port, for example 5160, with old configs untouched.
  4. Convert one or two pilot extensions and repoint those phones to the new port.
  5. Test registration, inbound and outbound calls, voicemail and MWI, BLF, attended and blind transfers, hold, DTMF into an IVR, and one-way audio. Watch with pjsip set logger on and core show channels.
  6. Build the PJSIP trunk beside the old one and test inbound and outbound before you change the routes.
  7. Update the firewall and Fail2ban jails for PJSIP logs, then move the remaining extensions in batches over a few days.
  8. Rollback: switch the device driver back for the affected extensions, point phones and provisioning templates to the old port, and restore the backup if the database was damaged.
Warning: Do not remove sip.conf or the old trunk until the new setup has run a full business week. Keep the old config on its own port as your rollback path, and note that on upgrades to Asterisk 21 or FreePBX 17 that path no longer exists.

Common questions

In which Asterisk version was chan_sip removed?

chan_sip was deprecated starting in Asterisk 17 and removed in Asterisk 21. Asterisk 18, 19 and 20 still include it, so you have time on those versions, but not on Asterisk 21 or later.

Can chan_sip and PJSIP run at the same time?

Yes, on Asterisk 20 and earlier and on FreePBX 15 and 16, provided they listen on different ports. Give each a distinct port, such as 5060 for PJSIP and 5160 for chan_sip.

Why does PJSIP need three objects for one extension?

Separating endpoint, auth and aor lets several endpoints share credentials, and lets one aor hold several contacts. It also makes identification, registration and media behaviour independent, which chan_sip could not do in one peer.

Do I have to recreate FreePBX trunks when moving to PJSIP?

Yes. The converters handle extensions, but trunks, registrations and custom sip_general settings must be rebuilt by hand on the PJSIP side and tested before routes are switched.

How do I replace call-limit in PJSIP?

PJSIP has no call-limit option. Use device state busy detection so a busy endpoint reports in-use, or enforce a limit with a dialplan check such as GROUP or GROUP_COUNT before dialling.

Related topics:asteriskfreepbxpjsipchansipmigration