This guide covers keeping a running CloudSOE Asterisk instance patched on AWS or Azure: the Ubuntu 26.04 LTS operating system, Asterisk itself, and (for the changes that shouldn’t be made in place) moving your configuration to a fresh instance of the latest image.
With a run of serious CVEs this autumn, now is a good time to check your instance is current. This image has no web UI and doesn’t include PHP, so PHP vulnerabilities such as PHP2Shell don’t affect it.
What you can upgrade in place
| Component | In place? | How |
|---|---|---|
| Operating system (Ubuntu 26.04 security and point updates) | Yes | apt (see Update the operating system) |
| Ubuntu release upgrade (e.g. to a later LTS) | No | Use a fresh image |
| Asterisk (patch updates within Asterisk 22) | Yes | apt, from Ubuntu’s repositories |
| Asterisk major version | No | Use a fresh image |
| fail2ban | Yes | apt, from Ubuntu’s repositories |
Before you start: back up
Take two backups: a disk snapshot (fast rollback for the whole machine) and a copy of your Asterisk configuration (portable, restores onto a new instance).
Disk snapshot:
- AWS: EC2 console → Elastic Block Store → Volumes → select the instance’s root volume → Actions → Create snapshot.
- Azure: open the VM → Disks → select the OS disk → Create snapshot.
Or from the CLI:
# AWS
aws ec2 create-snapshot --volume-id vol-xxxxxxxx --description "asterisk-01 before patching"
# Azure
az snapshot create --resource-group my-rg --name asterisk-01-pre-patch \
--source "$(az vm show -g my-rg -n asterisk-01 --query storageProfile.osDisk.managedDisk.id -o tsv)"
Asterisk configuration: everything that defines your PBX lives in /etc/asterisk/. Add /var/spool/asterisk/ if you keep voicemail or recordings, and /var/lib/asterisk/ if you use the AstDB (call forwards, blacklists and similar runtime settings) or custom sounds. Also keep your fail2ban tweaks:
sudo tar czf /home/$(whoami)/asterisk-backup-$(date +%F).tar.gz \
-C / etc/asterisk var/spool/asterisk var/lib/asterisk etc/fail2ban/jail.d
sudo chown $(whoami): /home/$(whoami)/asterisk-backup-*.tar.gz
chmod 600 /home/$(whoami)/asterisk-backup-*.tar.gz
The archive contains your SIP secrets, so store it somewhere private.
Schedule a maintenance window outside calling hours. Restarting Asterisk drops every active call, and an Asterisk package upgrade restarts the service automatically.
Update the operating system
All software on this image, Asterisk included, comes from Ubuntu’s repositories, so one update covers everything:
sudo apt update
sudo apt upgrade
When prompted about a changed configuration file under /etc/asterisk/, keep your installed version (the default answer, N). Your config is what makes the PBX yours.
Then check whether a reboot is needed (typically after a kernel or core library update) and reboot in your maintenance window:
[ -f /var/run/reboot-required ] && cat /var/run/reboot-required.pkgs
sudo reboot
Automatic updates
Ubuntu installs security updates automatically through unattended-upgrades by default. Check whether it’s active on your instance:
systemctl status unattended-upgrades --no-pager
cat /etc/apt/apt.conf.d/20auto-upgrades
Automatic security updates are a good thing. But if a security update to Asterisk arrives this way, the package restarts Asterisk when it installs, at whatever time unattended-upgrades runs. If that’s unacceptable for your call traffic, add asterisk to Unattended-Upgrade::Package-Blacklist in /etc/apt/apt.conf.d/50unattended-upgrades, and patch it yourself in your maintenance window instead.
Don’t run do-release-upgrade. A release upgrade swaps in a different Asterisk major version along with the OS. Instead, move to a fresh image.
Upgrade Asterisk
The image installs Asterisk 22 from Ubuntu’s own repositories (the asterisk package), not from source. Ubuntu delivers security and bug fixes for Asterisk 22 for the life of the release, but never a new major version. Patching Asterisk is simply:
sudo apt update
sudo apt install --only-upgrade asterisk
or a full sudo apt upgrade. Check the version before and after:
sudo asterisk -rx "core show version"
Asterisk is in Ubuntu’s universe component. If you need guaranteed security coverage for universe packages, look at Ubuntu Pro (Expanded Security Maintenance).
Need a newer Asterisk major version? Don’t mix in packages from another Ubuntu release or compile over the packaged install. That leaves the system half-managed by apt. Launch the latest CloudSOE image when it ships the version you need, and move your config over as described next. Read the Asterisk upgrade notes (UPGRADE.txt for each version in between) before you do: module names and config options change between major versions.
Move to a fresh CloudSOE image
1. Back up the old instance
Create the archive from Before you start and copy it to your own machine:
scp ubuntu@<old-ip>:asterisk-backup-<date>.tar.gz .
On Azure, use the admin username you chose at deployment instead of ubuntu.
2. Launch the latest image
Follow the getting-started guide for your cloud (AWS, Azure) with the same security group / NSG rules. Let first boot finish. It writes the new public IP into /etc/asterisk/pjsip_cloudsoe.conf.
3. Restore
Copy the archive across and save the new instance’s transport file, which already holds the right IP:
scp asterisk-backup-<date>.tar.gz ubuntu@<new-ip>:
ssh ubuntu@<new-ip>
sudo cp /etc/asterisk/pjsip_cloudsoe.conf /root/pjsip_cloudsoe.conf.new
Stop Asterisk, extract (running tar with sudo restores the original owners and permissions), and put the new transport file back:
sudo systemctl stop asterisk
sudo tar xzf asterisk-backup-<date>.tar.gz -C /
sudo cp /root/pjsip_cloudsoe.conf.new /etc/asterisk/pjsip_cloudsoe.conf
sudo systemctl start asterisk
sudo systemctl restart fail2ban
If you defined your own transports or NAT settings in pjsip.conf rather than in pjsip_cloudsoe.conf, edit them now (see step 4). Make sure logger.conf still contains the security => security line, or the fail2ban jail goes blind.
4. Update everything that embeds the IP address
Easiest is to move the public IP itself:
- AWS: disassociate the Elastic IP from the old instance and associate it with the new one.
- Azure: dissociate the static public IP from the old VM’s network interface and associate it with the new VM’s.
If you move the IP after first boot, update external_media_address and external_signaling_address in /etc/asterisk/pjsip_cloudsoe.conf to match, then sudo systemctl restart asterisk. If the address changes:
- NAT settings:
external_media_address,external_signaling_addressandlocal_neton every transport, inpjsip_cloudsoe.confand any transports of your own. - Your SIP trunk provider: update the IP allow-list or registration/authentication settings at the carrier.
- Phones and softphones: point them at the new address (or update the DNS name they use).
- Dialplan and endpoints: search your config for the old address:
sudo grep -rn '<old-ip>' /etc/asterisk/.
5. Re-register phones and test
Reboot or re-provision the phones, then check from the console:
sudo asterisk -rx "pjsip show endpoints"
sudo asterisk -rx "pjsip show registrations"
Make test calls in both directions and confirm two-way audio. One-way audio after a move almost always means stale NAT addresses or a closed RTP range (see tips & tricks).
6. Retire the old instance
Once the new instance has handled real traffic for a few days, stop and then terminate (AWS) or delete (Azure) the old one, and delete the snapshots and disks you no longer need so they stop costing money.
Check everything works
After any upgrade:
systemctl status asterisk fail2ban --no-pager
sudo asterisk -rx "core show version"
sudo asterisk -rx "pjsip show transports" # transport-udp and transport-tcp
sudo asterisk -rx "pjsip show endpoints" # phones registered
sudo asterisk -rx "pjsip show registrations" # trunk registered
sudo fail2ban-client status asterisk
Then register a softphone from outside the cloud network and place a test call. The echo test from the configuration guide is the quickest check of both signalling and audio.
Next steps
- Configure Asterisk: config files, PJSIP, NAT settings and the security log
- Tips & tricks: fail2ban management, one-way audio, backups and troubleshooting