How to Check a SIP Trunk: Asterisk, FreeSWITCH, Kamailio
See how Asterisk, FreeSWITCH and Kamailio check a SIP trunk, which checks are off by default, and what 401, 403, 404, 408 and 503 replies mean.
By Arkay · Updated · Published

How do you check whether a SIP trunk is up?

Check two things. If your provider uses registration, check that the trunk is registered. Then check that the trunk answers a SIP OPTIONS request with 200 OK.
RFC 3261, section 11 says the OPTIONS method lets one user agent query another user agent or a proxy about its capabilities. It also says all user agents must support OPTIONS. A 200 (OK) reply to OPTIONS should carry the Allow, Accept, Accept-Encoding, Accept-Language and Supported headers.
Registration status and reachability are separate checks, so one does not prove the other. Registration is the step where your PBX sends a SIP REGISTER request to the provider. A reachability check asks whether the far end answers a SIP request at all. Asterisk, FreeSWITCH and Kamailio all use OPTIONS for their checks. A trunk that is registered has passed the registration step, but that does not show it answers OPTIONS.
FreeSWITCH says to set the gateway parameter register to false for trunks that authenticate by IP address. That stops it sending SIP REGISTER to the provider. For such a trunk, the OPTIONS check is the one that tests whether the trunk answers.
What check does each platform run, and is it on by default?
We compiled these settings on November 17, 2026, from the SIP standard and each project's documentation. Nothing was tested or run. In all three platforms, the automatic check is off by default.
| Platform | Setting that sends the check | Default | What marks the trunk down |
|---|---|---|---|
| Asterisk (res_pjsip) | qualify_frequency in the [aor] section, in seconds | 0, never qualify | No reply within qualify_timeout (3.0 seconds by default) marks the contact unavailable |
| FreeSWITCH (gateway) | ping, in seconds | Disabled | ping-min failed OPTIONS (1 by default) marks the gateway DOWN |
| Kamailio (dispatcher) | ds_ping_interval, in seconds | 0, which disables pinging of inactive gateways | ds_probing_threshold failures (1 by default) set the destination inactive |
The three settings work in different ways. Asterisk sends OPTIONS on a timer and marks a contact unavailable when no reply arrives within qualify_timeout. FreeSWITCH counts OPTIONS results, and one failed reply marks a gateway DOWN by default. Kamailio counts failed requests against ds_probing_threshold, and one failure sets a destination inactive by default. Until you change these settings, the platforms do not run the automatic check.
How do you check a trunk in Asterisk?
Run pjsip show registrations at the Asterisk CLI to list every outbound registration. Each one shows one of four states: Unregistered, Registered, Rejected or Stopped. Rejected means Asterisk tried to register and a failure occurred, according to the Asterisk outbound registration documentation.
Run pjsip show registration <registration name> for one registration in detail. Run pjsip show endpoint <endpoint name> or pjsip show aor <aor name> to inspect an endpoint or an AoR. The Asterisk PJSIP troubleshooting guide uses the same endpoint and AoR commands, and it also uses pjsip set logger on to inspect SIP traffic. If a registration shows Rejected, look at the endpoint and AoR details first, then turn the logger on to see the SIP messages.
After a failed registration, Asterisk waits retry_interval seconds before it tries again. The default is 60 seconds. max_retries sets how many attempts Asterisk makes before it stops, and its default is 10. The default expiration is 3600 seconds.
The Asterisk documentation includes a trunk example that uses type=registration. This excerpt shows only its registration and AoR parts, and the domain and user number are example values. In pjsip.conf:
[mytrunk]
type=registration
outbound_auth=mytrunk
server_uri=sip:sip.example.com
client_uri=sip:1234567890@sip.example.com
retry_interval=60
[mytrunk]
type=aor
contact=sip:sip.example.com:5060
The first section declares an outbound registration. The server_uri line names the provider's server, and the client_uri line gives the identity your PBX registers as. The retry_interval line sets 60 seconds between retries after a failed registration. The outbound_auth line names a related object, mytrunk, which this excerpt does not show. The second section is the AoR, and its contact line names the address Asterisk contacts, sip.example.com on port 5060.
To have Asterisk send OPTIONS on its own, add qualify_frequency to the trunk's AoR. In pjsip.conf:
[mytrunk]
type=aor
contact=sip:sip.example.com:5060
qualify_frequency=60
The res_pjsip documentation defines qualify_frequency as the interval in seconds between reachability checks. In this example, 60 means one check every 60 seconds, and the value is only an example, so set your own. The default is 0, which never qualifies. The qualify_timeout option defaults to 3.0 seconds, and the contact is marked unavailable if it does not answer in time. Leave it alone unless you have a reason to change it.
How does FreeSWITCH mark a gateway up or down?
FreeSWITCH marks a gateway up or down from its OPTIONS results. The FreeSWITCH gateway documentation describes the ping parameter, which sends SIP OPTIONS every N seconds once you set it. Values below 5 are rejected, and pinging is disabled by default. The ping-min parameter defaults to 1, so one failed OPTIONS reply marks the gateway DOWN. The ping-max parameter also defaults to 1, so one success marks it UP.
If a gateway never changes state, first check that ping is set to a value of 5 or more, because lower values are rejected.
The register parameter defaults to true, which sends SIP REGISTER to the provider. Check the FreeSWITCH gateway documentation for the full list of parameters.
The FreeSWITCH gateway page we checked does not cover the CLI status command, so this post does not describe it.
How does Kamailio check its gateways?

The Kamailio dispatcher module probes gateways with OPTIONS once ds_ping_interval is set. Its ds_ping_method defaults to OPTIONS, so OPTIONS is the method unless you change it. ds_ping_interval defaults to 0, which disables pinging of inactive gateways.
ds_probing_threshold defaults to 1, so a destination goes inactive after its first failed request. ds_probing_mode decides which destinations are tested. With ds_probing_mode set to 0, only destinations in the PROBING state are tested. With ds_probing_mode set to 1, all destinations are tested.
If you want every destination tested, set ds_probing_mode to 1. If you only want destinations in the PROBING state tested, set it to 0.
To see each destination's state, run the dispatcher.list RPC through kamctl:
kamctl rpc dispatcher.list
The output lists the routing groups with their destination addresses and attributes. The first flag letter is the state: A for active, I for inactive, T for trying or D for disabled. The second letter is P for probed with SIP OPTIONS, or X for not probed. So AX means active and not tested, and AP means active and probed.
If a destination you expect to be tested shows X, the destination is not probed. Check ds_ping_interval and ds_probing_mode, since they control whether and which destinations are probed.
The dispatcher.set_state RPC sets a destination to active or inactive, so you can take a destination out of use or bring it back by hand. This post does not show its arguments, so check the module documentation for the exact form before you run it.
What does a test call look like in sngrep?

A healthy check is an OPTIONS request with a 200 OK reply, and a test call follows the INVITE flow in RFC 3261.
sngrep displays SIP call message flows from the terminal. Its README shows a live capture command that also saves a pcap file. Replace eth0 with your network interface, then run the command:
sngrep -d eth0 -O save.pcap port 5060 and udp
That command captures live traffic on UDP port 5060 and saves it to save.pcap. To read a saved capture later, use -I with its file name:
sngrep -I file.pcap
A saved file lets you review a failed check after it has happened. The list below shows the flow of a test call as RFC 3261 defines it. In order, the messages are:
- The caller's user agent sends INVITE.
- The next-hop server replies 100 Trying, which means it received the request.
- The user agent that receives the INVITE sends 180 Ringing while it alerts the user.
- The called side sends 200 OK when the request succeeds.
- The caller's user agent sends ACK, which completes the INVITE/200/ACK handshake.
- BYE ends the session.
This is the flow as RFC 3261 defines it, not a captured call, so confirm which host sends each message in your own sngrep capture. If a message is missing from your capture, it did not cross the interface you are watching.
If no OPTIONS request appears in your capture, check that you are capturing on the right interface, then look at the setting for your platform, such as qualify_frequency, ping or ds_ping_interval.
What do the common failure replies mean?
Each failure reply has a standard meaning. Section 21 of RFC 3261 defines these replies.
401 (Unauthorized) means the request requires user authentication. Check the credentials your PBX sends, such as the username and password from your provider.
403 (Forbidden) means the server understood the request but is refusing to fulfill it. Ask your provider whether the trunk is allowed to use the service.
404 (Not Found) means the server has definitive information that the user does not exist at the domain in the Request-URI. Compare the user and domain in your request with what the provider expects.
408 (Request Timeout) means the server could not produce a response within a suitable amount of time. Check the network path to the provider, such as any firewall in between. Then capture the traffic with sngrep to see whether your requests leave the PBX.
503 (Service Unavailable) means the server is temporarily unable to process the request because of overloading or maintenance. Wait, then run the check again. If the reply keeps coming back, contact your provider.
These meanings come from the standard, so they do not say which setting caused the reply on your system. Use the status commands and the capture above to find that out.
More guides in SIP Trunking.
Related guides
Frequently asked questions
- How do I make Asterisk check a trunk automatically?
- Set qualify_frequency in the trunk's [aor] section to a number of seconds above 0. The default is 0, which never qualifies, so Asterisk sends no automatic OPTIONS checks until you set it.
- How do I watch SIP trunk traffic live?
- Run `sngrep -d eth0 -O save.pcap port 5060 and udp` to capture live traffic and save it to a pcap file. Read a saved capture later with `sngrep -I file.pcap`. Replace eth0 with your network interface.
Sources
- RFC 3261 section 11 says the SIP method OPTIONS lets a user agent query another user agent (www.rfc-editor.org)
- The Asterisk CLI command pjsip show registrations lists all outbound registrations, and pj (docs.asterisk.org)
- The Asterisk PJSIP troubleshooting guide uses pjsip show endpoint <endpoint name>, pjsip s (docs.asterisk.org)
- Asterisk's documented trunk example registers with type=registration, outbound_auth=mytrun (docs.asterisk.org)
- In Asterisk res_pjsip, the [aor] option qualify_frequency sets the interval in seconds bet (docs.asterisk.org)
- In FreeSWITCH, the gateway parameter ping sends SIP OPTIONS to the gateway every N seconds (developer.signalwire.com)
- In the Kamailio dispatcher module, ds_ping_method defaults to OPTIONS and ds_ping_interval (kamailio.org)
- sngrep displays SIP call message flows in a terminal; sngrep -d eth0 -O save.pcap port 506 (github.com)