K
K
kruft2014-05-25 05:49:50
Asterisk
kruft, 2014-05-25 05:49:50

SIP session with peer behind NAT after changing active uplink on router?

There is the following configuration: a
local network, the router (Mikrotik) of which is connected to the Internet with two uplinks (1 - main, 2 - reserve). Inside the local network there is a server with Asterisk (works via udp), which is registered with a higher SIP provider (Rostelecom) to receive incoming calls. All port-forwards on the router are configured - under normal conditions, everything works correctly (audibility in both directions, incoming/outgoing calls work, etc.).
However, when the active uplink on the router is changed to a backup one (when the main one crashes), a problem arises: although the intranet Asterisk is forced to re-register with the sip provider (in order to expose its new external address), INVITE requests from the provider continue to come (or try to come) to old external address, because old sip session with t.z. provider is still active, and the provider supports up to 2 connections with the same details from different places and considers a new session from a backup IP just a 2nd connection.
After the switch (with the replacement of routes, the forced termination of tcp connections and the clearing of the conntrack table on the router, the audibility in the asterisk-> provider direction disappears for a while until the old sip session dies out at the latter due to timeout (the asterisk sends outgoing RTP packets to the provider already from a new active external address, the ISP considers them invalid and discards them.) The worst option: when after a short time the main uplink comes to life and the router switches back, the one-way hearing period doubles.
Question: what can we do for our part (on Asterisk or the router) , so that the described situation does not occur, i.e. how to prevent a hanging SIP session after an uplink change?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max, 2014-05-25
@Fandal

Asterisk has such a parameter as externip (more details here: voip.rus.net/tiki-index.php?page=Asterisk+SIP+externip)
plus, for order:
localnet=192.168.2.0/255.255.255.0
localnet=10.5 .1.0/255.255.255.192
etc. - for these subnets, exnetnip will not be substituted in the
ps extertip SIP packet and localnet`s are specified in the [general] context in sip.conf
Should help for correct registration with the provider.

S
Shapeshifter, 2014-07-25
@Shapeshifter

The most reliable thing is to ask the SIP provider for a second trunk so that registration from the second external IP goes to it and you don’t even need to tear anything, just fix the dialplan a little.
And so - well, you will make a script with a ping of the first gateway of the Internet provider and on a connection break - changing externip in the asterisk and sip reload, and returning back when restored, but what's the point?
The provider, as you say, considers new packages to be invalid (although I don’t understand why?).

D
Dmitry Kovalev, 2015-10-25
@aqua_gen

Good afternoon. Can you give me your Mikrotik config?
I have the same task, I seem to have set everything up, only registration on the server provider goes only through the first channel of the Internet. Plus, there was a failure, it seems as if the router wraps the registration package back to the aster. Although it's great to register on another asterisk that works on a non-standard port.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question