I was using freepbx, but because of some limits I installed kamailio on another machine. I want to have a route for outgoing calls to NGN(was peer friend siptrunk in freepbx), which handles call setups started from extensions registered on kamailio. and another route which send incoming calls to a freepbx ivr. how can I do that?
Kamailio controlled via config file. You can add if operator based on any info you want(source ip, destination number etc etc ) and choose for each own route.
You also can use already writed module like carrierroute https://kamailio.org/docs/modules/3.0.x/modules/carrierroute.html, which use prefix table for selection.