Linux – How to route/forward/connect incoming SIP call through other SIP provider to a phone number

forwardinglinuxsipvoip

I have 2 VOIP SIP accounts. One is for a landline (incoming). The other should be purely outgoing and allows for calls to my mobile phone. Basically I want to connect the landline to my mobile phone. With VOIP on my mobile phone, call quality is often bad, and generally, data connections (voice) never seem to be as good as a voice connection. Also, battery usage is a lot higher.

So I want to set up a server/(program on a linux server) to listen on the incoming VOIP account, and then use the other VOIP account to phone my mobile.

If possible:

  • the original caller id should be displayed
  • the outgoing VOIP account should only be used (connected) when a call needs to be forwarded so I can use the same account on another place (not at the same time)

I did set something similar up on my DSL router (FritzBox) losing the caller id and also having the added DSL delay, so I would prefer a solution running on a linux host with better connection (less latency).

Is that possible at all? What solution would I need?

Best Answer

The original context of your question is decidedly off-topic for Server Fault (it does sound like you're trying to do this for home use), and this is somewhat esoteric even if it were in the context of a business/corporate phone system, but it's an interesting problem so I'll take a swing at it.

The way it sounds to me is that you have two SIP accounts, SIP1 and SIP2.
You receive an incoming call on SIP1 and want to forward it to your cell phone via SIP2.

I'll start by saying that you really need a VOIP PBX to do this easily. You can probably hack something together with SIP proxies and the like, but a PBX is a far better solution.
I'm using the FreePBX installable distribution but there are lots of other options based around Asterisk/FreePBX out there.


To do what you want you would need to go through the following steps:

  1. Configure Asterisk to connect to both SIP accounts
  2. Create an extension and call-forward it to your cell phone.
  3. Create an inbound route from SIP1 and point it at that extension.
  4. Create an outbound route through SIP2 to handle all outgoing calls.

When you receive a call the system will call your cell phone through the SIP2 account.
If the caller ID needs customizing you can do that with some minor Asterisk hackery.

Making it so you can use SIP2 from other locations is a bit trickier -- the PBX won't unregister from a provider. You would need to create another device/user account and connect your phone to your PBX in order to make outbound calls using SIP2 from other locations. (The call would go to your PBX, and then be placed over the SIP2 outbound route.)


Rather than going through all of these awful gyrations you should really shell out some cash for a SIP Trunk Provider (Ask Google. I use VoicePulse's business services and they've been quite good). This will let you have one or more phone numbers and multiple channels (simultaneous calls) on one SIP account registration.
The PBX administration bits then become much more conventional (the inbound/outbound routing is symmetric and all you need to worry about are your device/user accounts).