Port 5061 (SIP over TLS)
Key facts
- Port
- 5061
- Protocols
- TCP
- Range
- Registered port, 1024-49151
- IANA service name
- sips
IANA assigns ports in this range to services on request, under RFC 6335.
About port 5061
Port 5061 is the default port of SIP over TLS, the secure version of the protocol that sets up and manages phone and video calls over the internet (VoIP).
According to RFC 3261, sips: addresses use port 5061 by default, and RFC 5630 clarifies that SIPS means a TLS-encrypted connection on every hop along the way between the parties. IANA registers port 5061 for the sips service (SIP-TLS). The unencrypted version runs on port 5060.
What port 5061 is used for
- Phones and apps: office phones and softphone apps on phones and computers register with the PBX over an encrypted connection, so passwords and call messages don't cross the network in the clear.
- Encrypted SIP trunks: many telephony providers let you connect your PBX to them over TLS.
- Connecting PBXs: two branches or two PBXs are linked to each other over encrypted SIP.
TLS encrypts only the SIP messages. The voice itself travels over RTP, and to encrypt it as well, you use SRTP.
Port 5061 in the firewall
On the PBX, open TCP port 5061 and the RTP port range configured on it, over UDP. When the extensions and the telephony provider connect from fixed addresses, allow port 5061 only from them:
- UFW:
ufw allow from 198.51.100.0/24 to any port 5061 proto tcp - firewalld:
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.0/24" port port="5061" protocol="tcp" accept'
Once all phones have moved to encrypted SIP, you can close port 5060 to incoming connections from outside.
Risks and security
Encryption protects passwords and call messages on the way, and a few simple settings complete the protection of the PBX:
- Install a valid TLS certificate on the PBX, with a name that matches the name the phones connect to, and keep track of its expiry date.
- Give each extension a long, random password that is different from the extension name.
- Restrict port 5061 to the addresses of your offices and your telephony provider when possible.
- Temporarily block addresses with repeated failed registration attempts, for example with fail2ban.
- Turn on SRTP, so the voice is encrypted too.
Commands to check and configure
-
ss -tlnp | grep ':5061 'Checks that the PBX is listening on TCP port 5061 (requires root privileges).
-
openssl s_client -connect sip.example.com:5061 -servername sip.example.comConnects to port 5061 and shows the PBX's TLS certificate, including the name and the expiry date.
-
asterisk -rx "pjsip show transports"Shows the transports configured in Asterisk, meaning the connection types the PBX accepts, including a TLS transport and its port.
-
nc -zv sip.example.com 5061Checks from your computer whether port 5061 on the PBX is open and reachable.
-
ufw allow from 198.51.100.0/24 to any port 5061 proto tcpAllows port 5061 only from the specified network (UFW).
-
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.0/24" port port="5061" protocol="tcp" accept'Allows port 5061 in firewalld only from the specified network. Then run firewall-cmd --reload.
Port 5061 in the IANA registry
| Port | Protocol | Service | IANA registry description |
|---|---|---|---|
| 5061 | SCTP | sips | SIP-TLS |
| 5061 | TCP | sips | SIP-TLS |
| 5061 | UDP | sips | SIP-TLS |
Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)
Port 5061 FAQ
What's the difference between port 5061 and port 5060?
Both ports are used for SIP. On port 5060 the messages travel unencrypted, over UDP or TCP, while on port 5061 they travel encrypted with TLS. That's why we recommend connecting phones from outside the office through port 5061.
Does encrypted SIP also encrypt the voice?
No. TLS on port 5061 encrypts the SIP messages that set up and end the call. The voice travels separately over RTP, and to encrypt it, turn on SRTP on the PBX and the phones.
How do I check that the PBX's TLS certificate is valid?
Run openssl s_client -connect sip.example.com:5061 -servername sip.example.com and check the name and expiry date on the certificate. The SSL errors page explains the common certificate errors.
Which ports do I need to open for a PBX with encrypted SIP?
Open TCP port 5061 for the SIP messages, and the RTP port range configured on the PBX, over UDP. When possible, restrict port 5061 to the addresses of your offices and your telephony provider.