Asterisk trunk SIP

asterisksiptrunk

I have a problem with trunk SIP when I connect my Asterisk to my provider and the Internet connection is lost, the trunk SIP will be unreachable, the problem consist is all local extension are disconnected until the Internet connection will be up or I deactivate the trunk.

The second problem was sometimes, the Internet connection will be up and the trunk still down until I make asterisk -rx "reload".

The same problem was detected if I make a system reboot, the trunk will be reachable only if I reload asterisk.

Any solution for this problem?

Note: My asterisk version is 1.8.15 (certificate version)

[general]
vmexten=*97
faxdetect=yes
context=from-sip-external
callerid=Unknown
notifyringing=yes
notifyhold=yes
tos_sip=cs3
tos_audio=ef
tos_video=af41
alwaysauthreject=yes
useragent=MyIPBX
disallow=all
allow=ulaw
allow=alaw
allow=gsm
language=fr
jbenable=no
rtptimeout=30
maxexpiry=3600
allowguest=yes
defaultexpiry=120
minexpiry=60
srvlookup=no
registerattempts=0
registertimeout=20
notifyhold=yes
g726nonstandard=no
t38pt_udptl=yes
videosupport=no
maxcallbitrate=384
canreinvite=no
rtpholdtimeout=300
rtpkeepalive=0
checkmwi=10
notifyringing=yes
register=myippiuser:myippisecret@ippi.fr

[100]
secret=pass100
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
type=friend
nat=yes
port=5060
qualify=yes
dial=SIP/100
mailbox=100@default
permit=0.0.0.0/0.0.0.0
callcounter=yes
faxdetect=no

[101]
secret=pass101
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
type=friend
nat=yes
port=5060
qualify=yes
dial=SIP/101
mailbox=101@default
permit=0.0.0.0/0.0.0.0
callcounter=yes
faxdetect=no

[ippi_trunk]
username=myippiuser
type=peer
secret=myippisecret
qualify=yes
nat=yes
insecure=invite,port
host=ippi.fr
fromuser=myippiuser
fromdomain=ippi.fr
dtmfmode=rfc2833
context=from-trunk
canreinvite=no
authname=myippiuser

Best Answer

The Asterisk will be blocked, all sip endpoint was down, if the internet connection is down, because the server is not able to resolve the trunk host name address via DNS.

It's a known bug in Asterisk 1.8, The solution consist to add ip address of your provider in hosts file and give the priority for resolution hostname by dns in the first if internet connection is up otherwise resolve the name using hosts file.

# /etc/hosts
# I have added this line
ip_provider dns_name_provider

Then I changed the order of hosts: option in nsswitch.conf file:

#/etc/nsswitch.conf
# Just I changed the order of dns files
.
.
.
hosts:      dns files