This guide covers keeping a running CloudSOE OpenSIPS instance patched on AWS or Azure: the Ubuntu 26.04 LTS operating system, OpenSIPS 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 |
| OpenSIPS (patch releases within your release line, e.g. 4.0.x) | Yes | apt, from apt.opensips.org |
| OpenSIPS major release line (e.g. 4.0 → 4.1) | Possible, with care | Prefer a fresh image; see new release lines |
| fail2ban, rsyslog | 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 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 "opensips-01 before patching"
# Azure
az snapshot create --resource-group my-rg --name opensips-01-pre-patch \
--source "$(az vm show -g my-rg -n opensips-01 --query storageProfile.osDisk.managedDisk.id -o tsv)"
OpenSIPS configuration: the proxy’s behaviour is /etc/opensips/ (opensips.cfg plus anything it includes), and your fail2ban tweaks live in /etc/fail2ban/jail.d/. If you changed the memory settings in /etc/default/opensips, include that too:
sudo tar czf /home/$(whoami)/opensips-etc-$(date +%F).tar.gz -C /etc opensips fail2ban/jail.d default/opensips
sudo chown $(whoami): /home/$(whoami)/opensips-etc-*.tar.gz
The image’s stock config uses no database. If you’ve added a database backend (for usrloc, auth, dialplan and so on), back that up as well with your database’s own dump tool.
Schedule a maintenance window outside calling hours. Restarting OpenSIPS 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 OpenSIPS from apt.opensips.org in one go. When prompted about a changed configuration file such as /etc/opensips/opensips.cfg, keep your installed version (the default answer, N). The image has already customised that file (listening sockets, the TCP module and your public IP), and the package’s version would undo it.
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 OpenSIPS updates from apt.opensips.org are only installed when you run apt upgrade yourself. Make that part of your routine.
Don’t run do-release-upgrade. The apt.opensips.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 OpenSIPS
OpenSIPS is installed from the official apt.opensips.org repository, which publishes each release line as a separate component (4.0-releases, and so on). The image was built against the newest stable line available at build time. The repository is defined in /etc/apt/sources.list.d/opensips.sources:
cat /etc/apt/sources.list.d/opensips.sources # Components: 4.0-releases (for example)
opensips -V | head -1 # running version
apt-cache policy opensips # installed vs available
Patch releases within your release line
Patch releases (4.0.x → 4.0.y) are bug and security fixes and are config-compatible. Upgrade, check the config against the new binary, then restart:
sudo apt update
sudo apt install --only-upgrade opensips
sudo opensips -C -f /etc/opensips/opensips.cfg
sudo systemctl restart opensips
If you’ve installed extra module packages (for example opensips-mysql-module or opensips-tls-module), apt upgrade updates them together with opensips. Keep them on the same version.
Moving to a new OpenSIPS release line
A new release line (4.0 → 4.1) can rename modules and parameters, change script functions and alter database schemas. We recommend a fresh instance of the latest CloudSOE image, which tracks the newest stable line, so you can test your config side by side and cut over when it passes.
If you must upgrade in place:
- Take the snapshot and config backup described above.
- Read the OpenSIPS migration notes for every release line in between and update
opensips.cfgaccordingly. If you use a database, migrate its schema as those notes describe. - Edit
/etc/apt/sources.list.d/opensips.sourcesand change theComponents:line (e.g.4.0-releases→4.1-releases). Confirm the new line publishes packages for your Ubuntu release first. - Upgrade, syntax-check and restart:
sudo apt update
sudo apt upgrade
sudo opensips -C -f /etc/opensips/opensips.cfg && sudo systemctl restart opensips
If the syntax check fails, fix the config before restarting. Or roll back: restore the Components: 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>:opensips-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. First boot writes the new public IP into advertised_address in /etc/opensips/opensips.cfg. Note it before you restore:
grep '^advertised_address=' /etc/opensips/opensips.cfg
3. Restore
Copy the archive across, extract it over the stock config (running tar with sudo restores the original owners and permissions):
scp opensips-etc-<date>.tar.gz ubuntu@<new-ip>:
ssh ubuntu@<new-ip>
sudo cp /etc/opensips/opensips.cfg /etc/opensips/opensips.cfg.stock
sudo tar xzf opensips-etc-<date>.tar.gz -C /etc
Your restored opensips.cfg still advertises the old public IP. Unless you’re moving the old IP over (step 4), set it to the new one, then syntax-check and restart:
sudo sed -i 's/^advertised_address=.*/advertised_address="<new-public-ip>"/' /etc/opensips/opensips.cfg
sudo opensips -C -f /etc/opensips/opensips.cfg
sudo systemctl restart opensips fail2ban
If the new image ships a newer OpenSIPS release line and the syntax check fails, the errors point at the modules, parameters or functions that changed. Fix them using the migration notes. If you use a database, restore it and migrate its schema before starting OpenSIPS.
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.
Then advertised_address can keep the old value. If the address changes, update:
advertised_addressand anysocket=lines with anasaddress or a specific private IP inopensips.cfg: search withsudo grep -rn '<old-ip>' /etc/opensips/. Private IPs change too.- 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 place test calls through the proxy in both directions while watching the log (sudo journalctl -u opensips -f).
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 opensips fail2ban --no-pager
opensips -V | head -1
sudo opensips -C -f /etc/opensips/opensips.cfg
sudo ss -lntup | grep 5060 # listening on UDP and TCP 5060
sudo fail2ban-client status opensips
sudo journalctl -u opensips --since -10min --no-pager
Then register a client from outside the cloud network and place a test call. sngrep (sudo apt install sngrep) gives a live SIP call-flow view if anything looks wrong.
Next steps
- Configure OpenSIPS: opensips.cfg, syntax checking, arming the fail2ban filter and NAT
- Tips & tricks: lockout recovery, watching scanners, backups and updates