Asterisk answers with Status 401 Unauthorized

Hey!

I have a AsteriskNOW Server with Asterisk 11 and FreePBX 12. There is a problem with my SIP Provider. I hope I can explain it understandable.

Asterisk send an REGISTER to 217.0.23.68 (tel.t-online.de). 217.0.23.68 answers with OK, the peer is successfully registered.

Normally, the server again signaled over the same address without problems. Sometimes, however, there is the problem that the server answers from 217.0.23.100. Then Asterisk responds to INVITE with 401 unauthorized.

I can not make calls and receive calls.

Waiting for a new REGISTER does not resolve the problem. Only a “sip reload” helps further.

Some settings: allowguest=no; nat=no; srvlookup=no

What can I do? Any idea?

I have some more information:

After changing ip address the register works fine. But the qualify SIP Options ist always send to the old ip address - I mean, Asterisk hasn’t understood the change completely.

People could guess all day, you need to explain more about your setup. Network Topology, freepbx version.

It could be something as simple as using a STUN server, but who knows.

Okay, sure.

The asterisk server is local behind a NAT (dynamic ip address) and a software firewall. No ports are forwarded to the pbx.

externhost is resolved with a dyn dns service. Stun is used and set to stun.t-online.de.

With iptables ip addresses are filtered.

Asterisk 11.16.0
FreePBX 12.0.50.1

peer settings:
[email protected]
type=peer
secret=12345
qualify=yes
insecure=invite
host=tel.t-online.de
fromdomain=tel.t-online.de
dtmfmode=rfc2833
disallow=all
directmedia=no
context=from-trunk
allow=g722&alaw&gsm

I think the problem is, that after a ip address change the peer ip address (shown by Asterisk Info -> Peers) is not been updated.

Any more questions?