I recently contributed to the Kamailio open-source project by porting a tool from Python 2.x to 3.x. This tool creates a tree graph of all the routes defined in the Kamailio configuration file, which is useful for visualizing the connections between different routes. A sample route graph for the default Kamailio file is shown below. The default Kamailio file can be found here.
Main
|
\- REQINIT
|
\- NATDETECT
|
\- RELAY
|
\- WITHINDLG
| |
| \- DLGURI
| |
| \- NATMANAGE
| |
| \- RELAY
| |
| \- PRESENCE
| | |
| | \- TOVOICEMAIL
| | | |
| | | \- RELAY
| |
| \- RELAY
|
\- AUTH
|
\- SIPOUT
| |
| \- RELAY
|
\- PRESENCE
| |
| \- TOVOICEMAIL
| | |
| | \- RELAY
|
\- REGISTRAR
|
\- PSTN
| |
| \- RELAY
|
\- LOCATION
| |
| \- SIPOUT
| | |
| | \- RELAY
| |
| \- SIPOUT
| | |
| | \- RELAY
| |
| \- TOVOICEMAIL
| | |
| | \- RELAY
| |
| \- RELAY
Branch routes
-------------
MANAGE_BRANCH
|
\- NATMANAGE
Failure routes
--------------
MANAGE_FAILURE
|
\- NATMANAGE
|
\- TOVOICEMAIL
| |
| \- RELAY
Onreply routes
--------------
MANAGE_REPLY
|
\- NATMANAGE
Reply routes
--------------
reply
Event routes
--------------
xhttp:request
As you can see, the graph provides a helpful overview of the routes defined in the configuration file and their interconnections. This can greatly assist in understanding a complex Kamailio configuration file.
You can find the tool in the Kamailio GitHub repository here. To use this tool, simply run the following command:
python3 route_graph.py kamailio.cfg
If your configuration is distributed across multiple files, remember to consolidate all the settings into a single file before executing this command.Give it a try and let me know if you find it useful in the comments below. If you want to learn more about VoIP and other related technologies, I recommend subscribing to my blog.
Akash Gupta
Senior VoIP Engineer and AI Enthusiast

AI and VoIP Blog
Thank you for visiting the Blog. Hit the subscribe button to receive the next post right in your inbox. If you find this article helpful don’t forget to share your feedback in the comments and hit the like button. This will helps in knowing what topics resonate with you, allowing me to create more that keeps you informed.
Thank you for reading, and stay tuned for more insights and guides!

Leave a comment