Opensips is a Sip Express Router software. It lets you route phone calls to different media servers. The solutions discussed in this tutorial uses a MySQL database to route phone calls based on rules loaded in a DB table.
Opensips is the example here, but Kamalio, another Sip Express Router software solution can be substituted with only a very few modifications.
The most important features of this solutions are:
1) Easily modified routes.
2) Fail over in case a route goes down.
This solution doesn't cover load balancing. This guide also assumes that you have Opensips and MySQL already installed and working.
Setting up either is outside the scope of this article. Its best to add dynamic routing to your setup after you have tested that the routes work, otherwise you may be fighting unresolved NAT or other issues and not know it.