Routing based on outbound sip-trunk ip

hello!

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

2 nics

1.1.1.1
2.2.2.2

1.1.1.1 should originate calls by using sip.domain.org
2.2.2.2 should originate calls by using othersip.domain.org

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 othersip.domain.org it should use eth1 (2.2.2.2).

I haven’t tested it, but something like:

route add -host othersip.domain.org 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 othersip.domain.org 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

Show
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 sipserver.firstdomain.org on nic2 with public ipaddress 1.1.1.1

i originate a call to sipserver.seconddomain.org on nic3 with public ipaddress 2.2.2.2

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.