Routing based on outbound sip-trunk ip


im having some questions regarding routing of ips. I have 2 sip-trunks which should be used by different external ips.

2 nics should originate calls by using should originate calls by using

how should this be configured in network routing table?

/ Marcus

What operating system are you using?

Can you confirm that the IP address of the SIP service is the given and you want to look up the interface based no that?

im using centos 5.5 with webmin.

to both sip-trunks it is a static ip and ns name.

so if originating call to it should use eth1 (

I haven’t tested it, but something like:

route add -host gw dev eth1

This needs including in your startup scripts, after the interface are up.

dev eth1 should not be needed if you have:

route add -host dev eth1

earlier in the startup script.

If resolves to multiple addresses, you will need to list them individually, or specify a -net type address that covers them all.

Knowing why you want to do this, might result in a cleaner solution.

itsa an asteriskserver that has

nic for lan
nic for dedicated sip-trunk to voip provider
and third nic should be connected to internet connected to second voip-provider.

i cannot use second voipprovider through the dedicated sip-trunk becauce its locked with first voip-provider, they are also our internetprovider so its a physical port for sip-trunk.

/ Marcus

ifconfig and
route -n

Asterisk was not really meant to be used with multiple NICs. You not only need to take care of the routing on the machine, to make sure not only SIP but also RTP traffic uses the right interface, but you also need to convince asterisk to put the right IPs inside SIP messages. You can at most use 2 different IPs with asterisk ( via localnet/externip directives ) so there is no way you will be able to use 3 NIC cards.

It is probably much easier to just put a second box for the the other provider and to trunk between the 2 boxes via SIP or IAX2. Alternatively you could put more intelligent routing SIP software on the same box as asterisk and take care of the routing without second box.

ok, thanks for the reply

so if one does not set bindadress should it not use the nics ipadress by default?

i found this info:

“The bindaddr setting is used to bind SIP to a specific NIC by its IP address. If you have only one NIC, then SIP will bind to the NIC. If you have multiple NICs, SIP will use all the NICs by default.”

I would have 1 nic for local network
1 nic directly to internet with public ip
1 nic directly to internet with public ip

/ MArcus

I believe the problem that is being raised here is that, the SDP contains the raw IP address. I’m not sure if it will use a host name for this.

I only answered the routing question.

lets say i have 3 nics where 2 is connected with public internet ips.

i originate a call to on nic2 with public ipaddress

i originate a call to on nic3 with public ipaddress

i have not defined external ip on asterisk installation.

what will happen?

It will look up the host name and use the first IP address associated with that.

which hostname do you mean?

if i have two different network interfaces (eth0 and eth1),

and every NIC is connected to certain ISP (eth0 is connected to ISP1 and eth1 is connected to ISP2 ),

is there a way to make eth1 as an automatic backup for eth0 in case of the ISP1 is down?

He’s asked this (more correctly) as a new thread.