This guide covers keeping a running CloudSOE Kamailio instance patched on AWS or Azure: the Ubuntu 26.04 LTS operating system, Kamailio 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

ComponentIn place?How
Operating system (Ubuntu 26.04 security and point updates)Yesapt (see Update the operating system)
Ubuntu release upgrade (e.g. to a later LTS)NoUse a fresh image
Kamailio (patch releases within your branch, e.g. 6.1.x)Yesapt, from the kamailio.org repository
Kamailio major branch (e.g. 6.1 → 6.2)Possible, with carePrefer a fresh image; see new branches
fail2ban, rsyslogYesapt, 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 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 "kamailio-01 before patching"

# Azure
az snapshot create --resource-group my-rg --name kamailio-01-pre-patch \
  --source "$(az vm show -g my-rg -n kamailio-01 --query storageProfile.osDisk.managedDisk.id -o tsv)"

Kamailio configuration: the proxy’s behaviour is /etc/kamailio/ (kamailio.cfg plus anything it includes), and your fail2ban tweaks live in /etc/fail2ban/jail.d/:

sudo tar czf /home/$(whoami)/kamailio-etc-$(date +%F).tar.gz -C /etc kamailio fail2ban/jail.d
sudo chown $(whoami): /home/$(whoami)/kamailio-etc-*.tar.gz

The image’s stock config uses no database. If you’ve enabled a database backend (for usrloc, auth and so on), back that up as well with your database’s own dump tool.

Schedule a maintenance window outside calling hours. Restarting Kamailio drops in-progress transactions and registrations held only in memory, so phones may need to re-register.

Update the operating system

sudo apt update
sudo apt upgrade

This updates Ubuntu’s packages and Kamailio from the kamailio.org repository in one go. When prompted about a changed configuration file such as /etc/kamailio/kamailio.cfg, keep your installed version (the default answer, N).

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

Ubuntu’s default unattended-upgrades setup only covers Ubuntu’s own repositories, so Kamailio updates from kamailio.org are only installed when you run apt upgrade yourself. Make that part of your routine.

Don’t run do-release-upgrade. The kamailio.org repository is configured for this Ubuntu release by name, and a release upgrade leaves it pointing at the wrong one. Instead, move to a fresh image.

Upgrade Kamailio

Kamailio is installed from the official kamailio.org apt repository, which publishes one repository per branch. The image was built against the newest branch available at build time. The repository is defined in /etc/apt/sources.list.d/kamailio.sources:

cat /etc/apt/sources.list.d/kamailio.sources     # URIs: https://deb.kamailio.org/kamailio61 (for example)
kamailio -v | head -1                            # running version
apt-cache policy kamailio                        # installed vs available, and from where

Patch releases within your branch

Patch releases (6.1.x → 6.1.y) are bug and security fixes and are config-compatible. Check your config against the new binary, then upgrade:

sudo apt update
sudo apt install --only-upgrade kamailio
sudo kamailio -c -f /etc/kamailio/kamailio.cfg
sudo systemctl restart kamailio

If you’ve installed extra module packages (for example kamailio-mysql-modules), apt upgrade updates them together with kamailio. Keep them on the same version.

Ubuntu’s own archive also carries an older kamailio package. apt-cache policy kamailio should show the installed version coming from deb.kamailio.org. If it doesn’t, check that the repository file above is still in place.

Moving to a new Kamailio branch

A new major branch (6.1 → 6.2) can change module parameters, remove deprecated functions and alter database schemas. We recommend a fresh instance of the latest CloudSOE image, which tracks the newest branch, so you can test your config side by side and cut over when it passes.

If you must upgrade in place:

  1. Take the snapshot and config backup described above.
  2. Read the upgrade notes for every branch in between on the Kamailio wiki, and update kamailio.cfg accordingly. If you use a database, apply the schema migrations it lists.
  3. Edit /etc/apt/sources.list.d/kamailio.sources and change the branch in the URIs: line (e.g. kamailio61 → kamailio62). Confirm the new branch publishes packages for your Ubuntu release first.
  4. Upgrade, syntax-check and restart:
sudo apt update
sudo apt upgrade
sudo kamailio -c -f /etc/kamailio/kamailio.cfg && sudo systemctl restart kamailio

If the syntax check fails, fix the config before restarting. Or roll back: restore the URIs: line, reinstall the previous version and restore your config from the backup.

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>:kamailio-etc-<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. Whitelist your admin IP in both fail2ban jails before you start testing.

3. Restore

Copy the archive across, extract it over the stock config (running tar with sudo restores the original owners and permissions), and syntax-check before restarting:

scp kamailio-etc-<date>.tar.gz ubuntu@<new-ip>:
ssh ubuntu@<new-ip>
sudo cp /etc/kamailio/kamailio.cfg /etc/kamailio/kamailio.cfg.stock
sudo tar xzf kamailio-etc-<date>.tar.gz -C /etc
sudo kamailio -c -f /etc/kamailio/kamailio.cfg
sudo systemctl restart kamailio fail2ban

If the new image ships a newer Kamailio branch and the syntax check fails, the errors point at the parameters or functions that changed. Fix them using the branch upgrade notes. If you use a database, restore it and apply any schema migrations before starting Kamailio.

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 the address changes, update:

  • advertise addresses and listen lines in kamailio.cfg: search for the old addresses with sudo grep -rn '<old-ip>' /etc/kamailio/. Private IPs change too, so check any listen line bound to a specific private address.
  • Trunk providers and peers: update IP allow-lists at your carriers, media servers and any other SIP peers.
  • Phones and edge devices: point them at the new address (or update the DNS name and any SRV records they use).
  • Firewall rules: update any security group / NSG rules elsewhere that reference the old IP.

5. Re-register and test

Reboot or re-register the phones and devices, then confirm they’re back:

sudo kamctl ul show          # if your config uses usrloc

Place test calls through the proxy in both directions.

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 kamailio fail2ban --no-pager
kamailio -v | head -1
sudo kamcmd core.version
sudo kamcmd core.uptime
sudo kamctl stats
sudo ss -lntup | grep 5060                   # listening on UDP and TCP 5060
sudo fail2ban-client status kamailio

Watch the log while a client registers and places a call:

sudo journalctl -u kamailio -f

sngrep (sudo apt install sngrep) gives a live SIP call-flow view if anything looks wrong.

Next steps

  • Configure Kamailio: kamailio.cfg, kamctl/kamcmd, arming the fail2ban filter and NAT
  • Tips & tricks: lockout recovery, syntax checking, watching scanners and backups