Comparisons · · The Wafflr team

Asterisk chan_sip to PJSIP: converting before you upgrade

A document with a folded corner and two angle brackets, a configuration file, in the live pocket of a three by three waffle grid

Moving an Asterisk system from chan_sip to PJSIP is no longer optional for anyone who wants to stay on a supported version. Asterisk's own documentation says chan_sip was deprecated in Asterisk 17, released in October 2019, and officially removed in Asterisk 21. PJSIP, through the res_pjsip and chan_pjsip modules, is the standard SIP driver, and it has been part of Asterisk since version 12. A system still configured in sip.conf cannot be upgraded past version 20 until its SIP configuration is rewritten. This post explains what changes, how Asterisk's own conversion script helps and where it stops, how the old sections map to the new ones, and an order of work that keeps phones and trunks running throughout. It is written for administrators staying on Asterisk as much as for those weighing a change.

Everything about Asterisk here comes from the project's own documentation: Configuring chan_sip and Migrating from chan_sip to res_pjsip, read on 13 November 2026, and the Asterisk Versions page, read on 22 October 2026.

Why chan_sip to PJSIP matters now

The timing comes from the support dates. On Asterisk's versions page as read in October 2026, Asterisk 20, a long term support release and the last series to include chan_sip, moved to security fixes only on 19 October 2026 and reaches end of life on 19 October 2027. Asterisk 22, the next long term support release, has security fixes only from 16 October 2028 and end of life on 16 October 2029. Our post on Asterisk end of life sets out the whole table.

So a system on Asterisk 20 with chan_sip has roughly a year of security fixes left, and the upgrade that follows requires the SIP configuration to be converted first. Doing the conversion on Asterisk 20, where both drivers exist, is much easier than doing it at the same time as a version upgrade, because one thing changes at a time.

Asterisk 21: chan_sip removed, and what that means

Removed means the module is not built or shipped. On Asterisk 21 or later:

  • sip.conf is not read;
  • Dial(SIP/...) in the dial plan fails, because there is no SIP channel technology;
  • CLI commands such as sip show peers do not exist;
  • anything that reads chan_sip's variables or its manager events stops working.

To find out whether your system still uses chan_sip, run these on the Asterisk console:

asterisk -rx "module show like chan_sip"
asterisk -rx "sip show peers"
asterisk -rx "pjsip show endpoints"

If chan_sip is loaded and sip show peers lists your phones and trunks, the configuration is in sip.conf. Many systems have both: older phones in sip.conf and newer ones in pjsip.conf.

How sip.conf maps to pjsip.conf

The biggest change is structural. chan_sip described each phone or trunk in one section, a peer, user or friend. PJSIP splits it into several objects, each with one job.

What it does sip.conf pjsip.conf
Where Asterisk listens [general], udpbindaddr A type=transport section
A phone or trunk's call settings One section, type=friend or peer type=endpoint
Where it can be reached host=dynamic or host= an address type=aor, with max_contacts for a phone that registers or contact for a fixed address
Its password secret= in the same section type=auth, with username and password
Registering to a provider register => line type=registration, with server_uri and outbound_auth
Recognising a provider by address host= the provider type=identify, with match
Dialling it Dial(SIP/6001) Dial(PJSIP/6001); a trunk as PJSIP/number@trunk

The migration page's side-by-side examples show exactly this: a phone becomes an endpoint, an aor and an auth section, and a provider that needs registration becomes an endpoint with a registration section using the same credentials. It also warns that PJSIP's configuration format is stricter than chan_sip's: follow the documentation exactly, avoid extra spaces and odd capitalisation, and check the logs for warnings after every reload.

Using sip_to_pjsip.py

Asterisk's source includes a Python script, sip_to_pjsip.py, in contrib/scripts/sip_to_pjsip. The documentation describes it as a basic conversion of a sip.conf to a pjsip.conf, not intended to work for every scenario, and for basic configurations a good example of how to convert. Some practical points from the same page:

  • Run it from /etc/asterisk, or a copy of it, so it can read any files that sip.conf includes.
  • By default it reads sip.conf and writes pjsip.conf. Included files are converted too and written with a pjsip_ prefix, which --prefix= changes.
  • Treat the output as a draft. Read every section, compare it with the documentation for each option, and remove anything you do not understand rather than leaving it in.
cd /etc/asterisk
cp -a /etc/asterisk /root/asterisk-before-pjsip
/path/to/asterisk/source/contrib/scripts/sip_to_pjsip/sip_to_pjsip.py sip.conf pjsip-converted.conf

Writing to a new file name, rather than over an existing pjsip.conf, means nothing changes on the live system until you choose to include it.

What the script will not do for you

  • The dial plan. Every SIP/ in extensions.conf, and any variable or function specific to chan_sip, must be changed by hand. Search for SIP/ and for SIPPEER, SIP_HEADER and similar.
  • NAT behaviour. chan_sip's nat= settings become several endpoint options in PJSIP, such as force_rport, rewrite_contact and rtp_symmetric. Check each phone that sits behind a home router or a remote office's firewall.
  • Anything outside Asterisk that watches chan_sip: monitoring scripts, a wallboard reading manager events, fail2ban rules matching chan_sip's log lines. Each needs the PJSIP equivalent.

An Asterisk PJSIP migration, in a safe order

  1. Back up /etc/asterisk and the database, and keep the copy off the machine.
  2. Build a test system on the same Asterisk version with a copy of the configuration, if you can. Convert there first.
  3. Run the script, then review and correct the output section by section.
  4. Move the listening port. chan_sip and PJSIP cannot both listen on 5060. During the move, put PJSIP on a different port, or move chan_sip off 5060 if the phones are being changed first.
  5. Move one phone, change its registration to PJSIP, and test calls in and out, transfer, hold, voicemail and the keys that show colleagues' status.
  6. Move the rest of the phones in groups, a department at a time.
  7. Move the trunks last, outside hours, with the provider's support line to hand. Test calls in each direction and from a mobile.
  8. Change the dial plan so every SIP/ is PJSIP/, reload, and run the test calls again.
  9. Unload chan_sip with noload => chan_sip.so in modules.conf, and run for a week before upgrading Asterisk.
  10. Then upgrade, with one change at a time behind you.

If phones fail to register after the move, the error codes are the same as on any SIP system; our guide to SIP registration failures explains what 401, 403 and 408 mean.

Where Asterisk is the better choice

Asterisk gives an administrator complete control over every part of the phone system, and a large community and decades of documentation behind it. For someone comfortable with its configuration files, the move to PJSIP is a well-documented piece of work, not a reason to leave, and staying on Asterisk with a supported version is a perfectly good outcome of this post. A product gives you less control in return for less to maintain, and that trade suits some organisations and not others.

How this compares with Wafflr

Wafflr is in development and has not launched, and its prices are not published yet; they will appear on the site's pricing page when the price list is final. For an Asterisk system part way through its own migration, Wafflr's importer reads both sip.conf and pjsip.conf, because, as the product's own code puts it, a site part way through its own migration has both, and reading only one would find half a phone system. It also reads extensions.conf, queues.conf and features.conf, translates the dial plan's patterns where it can, and names what it could not translate rather than guessing. Our page on moving from Asterisk to Wafflr has the details and says where Asterisk remains the better choice.

Questions about moving from chan_sip to PJSIP

Can I keep chan_sip on Asterisk 21 or later?

Not from the Asterisk project: its documentation says chan_sip was officially removed in Asterisk 21. Staying on chan_sip means staying on Asterisk 20 or earlier, with the support dates above.

Does sip_to_pjsip.py convert everything?

No. The documentation calls it a basic conversion that is not intended for every scenario. It converts the SIP configuration; the dial plan and anything outside Asterisk that relies on chan_sip are left to you.

Can chan_sip and PJSIP run at the same time?

On versions that include both, yes, as long as they do not listen on the same port. That is what makes a gradual move possible.

Do my desk phones need new settings?

Their registration usually needs to point at PJSIP's port if it differs, and their credentials must match the new auth sections. Phones provisioned automatically can be moved by changing the configuration they collect.

What to do next

Run the three commands above today to find out whether chan_sip is still in use. If it is, plan the conversion on the version you have, before Asterisk 20's end of life on 19 October 2027 forces it to happen in the same weekend as an upgrade.