Outgoing calls fail after a while

I have a home server with asterisk (24.0.0). My internet provider is Deutsche Telekom (fiber-optic connection). I noticed, that making a outgoing call fails after some time (a few days?). My IP address has not (!) changed in the meantime. Restarting asterisk makes it work again.

A guess from a search engine is that it might be caused by a DNS-SRV-Loadbalancer. But how can I fix the problem?

Parts of my pjsip.conf:

[...]

[telekom-reg-677]
type=registration
transport=transport-telekom-tls
outbound_auth=telekom-auth-677
server_uri=sip:tel.t-online.de
client_uri=sip:+49712xxxxxxx@tel.t-online.de
line=yes
endpoint=telekom-677
contact_user=+49712xxxxxxx
retry_interval=60
forbidden_retry_interval=300
expiration=480
auth_rejection_permanent=false

[telekom-677]
type=endpoint
transport=transport-telekom-tls
context=telekom
disallow=all
allow=g722,alaw,ulaw
outbound_auth=telekom-auth-677
identify_by=username
media_encryption=sdes
rtp_symmetric=yes
direct_media=no
from_user=+49712xxxxxxx
from_domain=tel.t-online.de
aors=telekom-all-aor
trust_id_inbound=yes
force_rport=yes
rewrite_contact=yes
timers=yes
timers_min_se=90

Here is the log:

    -- Executing [0162xxxxxxx@telefone:1] Dial("PJSIP/buero-oben-00000023", "PJSIP/telekom-677/sip:0162xxxxxxx@tel.t-online.de,60") in new stack
    -- Called PJSIP/telekom-677/sip:0162xxxxxxx@tel.t-online.de
<--- Transmitting SIP request (1074 bytes) to TLS:217.0.146.198:5061 --->
INVITE sip:0162xxxxxxx@tel.t-online.de SIP/2.0
Via: SIP/2.0/TLS 10.10.0.3:5061;rport;branch=z9hG4bKPjff265fa6-0065-4c44-af68-b3e3533590a1;alias
From: <sip:+49712xxxxxxx@tel.t-online.de>;tag=1263e151-6e4b-4fa9-a576-7a53cf321937
To: <sip:0162xxxxxxx@tel.t-online.de>
Contact: <sip:+49712xxxxxxx@10.10.0.3:5061;transport=TLS>
Call-ID: 10552dab-8db0-4730-be0d-2fcd61300501
CSeq: 28794 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, INFO, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 24.0.0
Content-Type: application/sdp
Content-Length:   362

v=0
o=- 659477935 659477935 IN IP4 10.10.0.3
s=Asterisk
c=IN IP4 10.10.0.3
t=0 0
m=audio 30094 RTP/SAVP 9 8 0 101
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:oH5ptntz8/xynOzsn6a8nBX4ZmcrqignvXUCi6XD
a=rtpmap:9 G722/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:140
a=sendrecv

<--- Received SIP response (329 bytes) from TLS:217.0.146.198:5061 --->
SIP/2.0 100 Trying
Via: SIP/2.0/TLS 10.10.0.3:5061;rport;branch=z9hG4bKPjff265fa6-0065-4c44-af68-b3e3533590a1;alias
From: <sip:+49712xxxxxxx@tel.t-online.de>;tag=1263e151-6e4b-4fa9-a576-7a53cf321937
To: <sip:0162xxxxxxx@tel.t-online.de>
Call-ID: 10552dab-8db0-4730-be0d-2fcd61300501
CSeq: 28794 INVITE
Content-Length: 0


<--- Received SIP response (436 bytes) from TLS:217.0.146.198:5061 --->
SIP/2.0 403 Forbidden
Via: SIP/2.0/TLS 10.10.0.3:5061;received=93.236.61.174;rport=34477;branch=z9hG4bKPjff265fa6-0065-4c44-af68-b3e3533590a1;alias
From: <sip:+49712xxxxxxx@tel.t-online.de>;tag=1263e151-6e4b-4fa9-a576-7a53cf321937
To: <sip:0162xxxxxxx@tel.t-online.de>;tag=mavodi-0-264-d5b-1-0-_022AEBB55836-1633-2c400700-c2a208-6af55cdb-c6977
Call-ID: 10552dab-8db0-4730-be0d-2fcd61300501
CSeq: 28794 INVITE
Content-Length: 0


<--- Transmitting SIP request (478 bytes) to TLS:217.0.146.198:5061 --->
ACK sip:0162xxxxxxx@tel.t-online.de SIP/2.0
Via: SIP/2.0/TLS 10.10.0.3:5061;rport;branch=z9hG4bKPjff265fa6-0065-4c44-af68-b3e3533590a1;alias
From: <sip:+49712xxxxxxx@tel.t-online.de>;tag=1263e151-6e4b-4fa9-a576-7a53cf321937
To: <sip:0162xxxxxxx@tel.t-online.de>;tag=mavodi-0-264-d5b-1-0-_022AEBB55836-1633-2c400700-c2a208-6af55cdb-c6977
Call-ID: 10552dab-8db0-4730-be0d-2fcd61300501
CSeq: 28794 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 24.0.0
Content-Length:  0


  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [0162xxxxxxx@telefone:2] Hangup("PJSIP/buero-oben-00000023", "") in new stack
  == Spawn extension (telefone, 0162xxxxxxx, 2) exited non-zero on 'PJSIP/buero-oben-00000023'
<--- Transmitting SIP response (387 bytes) to TCP:10.30.0.9:50926 --->
SIP/2.0 403 Forbidden
Via: SIP/2.0/TCP 10.30.0.9:50926;rport=50926;received=10.30.0.9;branch=z9hG4bK1145210133;alias
Call-ID: 1774330590-49121-9@BA.DA.A.J
From: "BĂĽro oben" <sip:buero-oben@hornet.lan>;tag=173446358
To: <sip:0162xxxxxxx@hornet.lan>;tag=1a8aefe1-c074-4a6d-8310-98b9213a7543
CSeq: 31 INVITE
Server: Asterisk PBX 24.0.0
Reason: Q.850;cause=21
Content-Length:  0


<--- Received SIP request (322 bytes) from TCP:10.30.0.9:50926 --->
ACK sip:0162xxxxxxx@hornet.lan SIP/2.0
Via: SIP/2.0/TCP 10.30.0.9:50926;branch=z9hG4bK1145210133;rport;alias
From: "BĂĽro oben" <sip:buero-oben@hornet.lan>;tag=173446358
To: <sip:0162xxxxxxx@hornet.lan>;tag=1a8aefe1-c074-4a6d-8310-98b9213a7543
Call-ID: 1774330590-49121-9@BA.DA.A.J
CSeq: 31 ACK
Content-Length: 0

You probably need to contact your provider for an explanation of their refusal, however, your Via header looks wrong, and I think you have failed to set the external signalling address on the transport.

Why? Because of the local IP?

Why? How can I do it correctly?

transport looks like this:

[transport-telekom-tls]
type=transport
protocol=tls
bind=0.0.0.0:5061
ca_list_file=/etc/ssl/certs/ca-certificates.crt
method=tlsv1_2
verify_server=true
local_net=10.10.0.0/23
local_net=10.30.0.0/24
external_signaling_address=myhost.mydomain.com
external_media_address=myhost.mydomain.com
allow_reload=yes

myhost.mydomain.com is a public dynamic dns entry. But I accidentially set a local IP on my local dns for it. I fixed that now. Let’s see how things turn out now.

Yes. But I’m not convinced that this is the real problem, and I think you will need your provider to explain that, as they are the ones declaring an error.

Hi,

I think the idea regarding the SRV record is correct. I’ve observed problems when multiple DNS resolvers are used.

During registration, the first resolver resolves to IP A. When sending an INVITE or OPTIONS request, a different resolver resolves to IP B. The provider returns a 403 error because you are not registered on server B.

This error occurs with Deutsche Telekom when DNS resolution is attempted via both Telekom DNS and, for example, Google DNS.

With Deutsche Telekom, it’s best to use the DNS server that the router receives upon dialing in (there are several).

Not that it helps, given that some providers impose this restriction anyway, but SIP registration isn’t supposed to be about authenticating for outgoing calls. It is supposed to be about saying where to send incoming calls, and the authentication only relates to the validity of that destination, and doesn’t reflect an ongoing login.

Unfortunately, as caveated above, some providers do treat it as a login, and some may treat it as a login only to one instance of the their front end.

I would investigate DNS resolution first, especially if the problem appears after a few days.

There are a few things worth checking:

1. Check DNS-SRV resolution

If Deutsche Telekom uses multiple SIP servers, make sure Asterisk consistently resolves the provider’s SIP records through the same DNS resolver. Different DNS resolvers returning different server IPs could cause REGISTER requests to reach one server and INVITE requests to another.

Check the SRV and A records using:

dig SRV _sips._tcp.tel.t-online.de
dig A tel.t-online.de

Use the actual SRV hostname configured or documented by your provider if it differs.

2. Verify external signaling address

Your SIP trace shows a private IP (10.10.0.3) in the Via and Contact headers.

Your PJSIP transport should advertise the correct public IP or publicly resolvable hostname:

[transport-telekom-tls]
type=transport
protocol=tls
bind=0.0.0.0:5061
local_net=10.10.0.0/23
local_net=10.30.0.0/24
external_signaling_address=YOUR_PUBLIC_IP
external_media_address=YOUR_PUBLIC_IP

Make sure your local DNS does not resolve the public hostname to a private IP. Also verify the advertised address from an external network.

3. Check registration and SIP logs

When the issue occurs, before restarting Asterisk, run:

asterisk -rx "pjsip show registrations"
asterisk -rx "pjsip show endpoints"

Enable SIP logging:

asterisk -rvvvvv
pjsip set logger on

Compare the destination IP of REGISTER and INVITE requests and check the provider’s response.

4. Verify with your provider

A 403 response is generated by the remote SIP server in this trace. Ask Deutsche Telekom whether the INVITE is rejected because of registration state, source IP, authentication, or a different backend server.

My first suspicion would be inconsistent DNS-SRV resolution, particularly if multiple DNS resolvers are configured. I would investigate that before changing authentication or registration timers.

This is the case with Deutsche Telekom. They have different platforms and at least one behaves this way. They expect that calls go through the same IP address that you’re registered to. I haven’t found language in an RFC to state this has to be the case, so it’s kind of a quirk/requirement of their platform. Others have solved this by adding an explicit host mapping to their system which always resolves to the same IP address and then regularly updating it.