Asterisk and Fritzbox connection [SOLVED]

Dear all,

I have a working Asterisk server on my intel nuc at my home.
As modem/router I am using a Fritzbox 7590 with the last 7 series firmware and my ISP voip telephony is working perfectly.
I want to use Fritzbox as a “gateway” of Asterisk server for outgoing and incoming calls through the ISP voip line.
How to do it?

I tried to in this way, but it doesn’t work:

On Fritzbox I created a new IP telephone device with the following credentials:

registrar=fritz.box or 192.168.2.1
username=asterisk01
password=password01

On my Asterisk server (Lan ip 192.168.2.81) I edited sip.conf and extensions.conf as following

This is my sip.conf

[general]
allowguest=no
alwaysauthreject=yes
prematuremedia=no
progressinband=yes

register=> asterisk01:password01@192.168.2.1

[FritzBS]
type=friend
context=incoming_TIM_BS
allow=alaw,ulaw
secret=password01
host=192.168.2.1
fromdomain=192.168.2.1
insecure=invite
qualify=yes

[matejcell]
type=friend
host=dynamic
secret=password02
context=internal
disallow=all
allow=alaw
qualify=yes

This in my extensions.conf

[internal]

exten=> 1000,1,NoOp()
same => n,Dial(SIP/matejcell,60)
same => n,Hangup()

exten => _X.,1,NoOp()
same => n,GoTo(outgoing,${EXTEN},1)

[outgoing_TIM_BS]

exten => _X.,1,NoOp()
same  => n,Dial(SIP/FritzBS/${EXTEN},60)
same  => n,Playtones(congestion)
same  => n,hangup()

[incoming_TIM_BS]

exten => _X.,1,NoOp()
same  => n,Goto(internal,1000,1)
same  => n,Playtones(congestion)
same  => n,hangup()

Now, my softphone with extension 1000 rings when there is an incoming call to the landline number of the Fritzbox, but cannot make an outbound call through the same landline calling for example number “187”: I get the following log,

“sip set debug peer matejcell”:


<--- SIP read from UDP:192.168.2.7:8871 --->
INVITE sip:187@192.168.2.81 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.7:8871;branch=z9hG4bKP4twcbwbMLMTG2Z0;rport
Contact: <sip:matejcell@192.168.2.7:8871>
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.81>;tag=175B244754F4E0B7B26F15DDB9774931
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER, UPDATE
Supported: replaces, path
To: <sip:187@192.168.2.81>
Content-Type: application/sdp
Call-ID: 50220F47A91FA94932453027792773083ADB5243
CSeq: 1 INVITE
User-Agent: Acrobits Softphone Business/3.8.11
Content-Length: 305

v=0
o=- 8543841730 22507 IN IP4 172.26.170.170
s=dwwbhez
c=IN IP4 192.168.2.7
t=0 0
m=audio 13998 RTP/AVP 103 101
a=rtpmap:101 telephone-event/8000
a=rtpmap:103 opus/48000/2
a=fmtp:101 0-15
a=fmtp:103 maxplaybackrate=16000;maxaveragebitrate=24000;useinbandfec=1;usedtx=1
a=ptime:20
a=sendrecv
<------------->
--- (13 headers 12 lines) ---
Sending to 192.168.2.7:8871 (no NAT)
Sending to 192.168.2.7:8871 (no NAT)
Using INVITE request as basis request - 50220F47A91FA94932453027792773083ADB5243
Found peer 'matejcell' for 'Matej Cell IP' from 192.168.2.7:8871

<--- Reliably Transmitting (no NAT) to 192.168.2.7:8871 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.2.7:8871;branch=z9hG4bKP4twcbwbMLMTG2Z0;received=192.168.2.7;rport=8871
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.81>;tag=175B244754F4E0B7B26F15DDB9774931
To: <sip:187@192.168.2.81>;tag=as555beb87
Call-ID: 50220F47A91FA94932453027792773083ADB5243
CSeq: 1 INVITE
Server: Asterisk PBX 15.6.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="13b63adf"
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog '50220F47A91FA94932453027792773083ADB5243' in 6400 ms (Method: INVITE)

<--- SIP read from UDP:192.168.2.7:8871 --->
ACK sip:187@192.168.2.81 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.7:8871;branch=z9hG4bKP4twcbwbMLMTG2Z0;rport
Max-Forwards: 70
Call-ID: 50220F47A91FA94932453027792773083ADB5243
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.81>;tag=175B244754F4E0B7B26F15DDB9774931
To: <sip:187@192.168.2.81>;tag=as555beb87
CSeq: 1 ACK
User-Agent: Acrobits Softphone Business/3.8.11
Content-Length: 0

<------------->
--- (9 headers 0 lines) ---

<--- SIP read from UDP:192.168.2.7:8871 --->
INVITE sip:187@192.168.2.81 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.7:8871;branch=z9hG4bKxHpazRQqwXIZPKc2;rport
Contact: <sip:matejcell@192.168.2.7:8871>
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.81>;tag=175B244754F4E0B7B26F15DDB9774931
Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER, UPDATE
Supported: replaces, path
To: <sip:187@192.168.2.81>
Content-Type: application/sdp
Call-ID: 50220F47A91FA94932453027792773083ADB5243
CSeq: 2 INVITE
Authorization: Digest username="matejcell",realm="asterisk",algorithm=MD5,uri="sip:187@192.168.2.81",nonce="13b63adf",response="bb194cbac4e6412998bfabcc92a17aeb"
User-Agent: Acrobits Softphone Business/3.8.11
Content-Length: 305

v=0
o=- 8543841730 22507 IN IP4 172.26.170.170
s=dwwbhez
c=IN IP4 192.168.2.7
t=0 0
m=audio 13998 RTP/AVP 103 101
a=rtpmap:101 telephone-event/8000
a=rtpmap:103 opus/48000/2
a=fmtp:101 0-15
a=fmtp:103 maxplaybackrate=16000;maxaveragebitrate=24000;useinbandfec=1;usedtx=1
a=ptime:20
a=sendrecv
<------------->
--- (14 headers 12 lines) ---
Sending to 192.168.2.7:8871 (no NAT)
Using INVITE request as basis request - 50220F47A91FA94932453027792773083ADB5243
Found peer 'matejcell' for 'Matej Cell IP' from 192.168.2.7:8871
  == Using SIP RTP CoS mark 5
Found RTP audio format 103
Found RTP audio format 101
Found audio description format telephone-event for ID 101
Found audio description format opus for ID 103
Capabilities: us - (opus), peer - audio=(opus)/video=(nothing)/text=(nothing), combined - (opus)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 192.168.2.7:13998
Looking for 187 in cellulari (domain 192.168.2.81)
sip_route_dump: route/path hop: <sip:matejcell@192.168.2.7:8871>

<--- Transmitting (no NAT) to 192.168.2.7:8871 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.2.7:8871;branch=z9hG4bKxHpazRQqwXIZPKc2;received=192.168.2.7;rport=8871
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.81>;tag=175B244754F4E0B7B26F15DDB9774931
To: <sip:187@192.168.2.81>
Call-ID: 50220F47A91FA94932453027792773083ADB5243
CSeq: 2 INVITE
Server: Asterisk PBX 15.6.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:187@192.168.2.81:5060>
Content-Length: 0


<------------>
    -- Executing [187@cellulari:1] NoOp("SIP/matejcell-000000a7", "") in new stack
    -- Executing [187@cellulari:2] Goto("SIP/matejcell-000000a7", "outgoing_TIM_BS,187,1") in new stack
    -- Goto (outgoing_TIM_BS,187,1)
    -- Executing [187@outgoing_TIM_BS:1] NoOp("SIP/matejcell-000000a7", "") in new stack
    -- Executing [187@outgoing_TIM_BS:2] Dial("SIP/matejcell-000000a7", "SIP/FritzBS/187,60") in new stack
  == Using SIP RTP CoS mark 5
    -- Called SIP/FritzBS/187

<--- SIP read from UDP:192.168.2.7:8871 --->
CANCEL sip:187@192.168.2.81 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.7:8871;branch=z9hG4bKxHpazRQqwXIZPKc2;rport
Call-ID: 50220F47A91FA94932453027792773083ADB5243
To: <sip:187@192.168.2.81>
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.81>;tag=175B244754F4E0B7B26F15DDB9774931
CSeq: 2 CANCEL
Authorization: Digest username="matejcell",realm="asterisk",algorithm=MD5,uri="sip:187@192.168.2.81",nonce="13b63adf",response="e0a1f6abac721931b2d8a249a53079a8"
Max-Forwards: 70
User-Agent: Acrobits Softphone Business/3.8.11
Content-Length: 0

sip set debug peer Fritz:

  == Using SIP RTP CoS mark 5
    -- Executing [187@cellulari:1] NoOp("SIP/matejcell-000000a9", "") in new stack
    -- Executing [187@cellulari:2] Goto("SIP/matejcell-000000a9", "outgoing_TIM_BS,187,1") in new stack
    -- Goto (outgoing_TIM_BS,187,1)
    -- Executing [187@outgoing_TIM_BS:1] NoOp("SIP/matejcell-000000a9", "") in new stack
    -- Executing [187@outgoing_TIM_BS:2] Dial("SIP/matejcell-000000a9", "SIP/FritzBS/187,60") in new stack
  == Using SIP RTP CoS mark 5
Audio is at 19330
Adding codec ulaw to SDP
Adding codec alaw to SDP
Adding codec gsm to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 192.168.2.1:5060:
INVITE sip:187@192.168.2.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.81:5060;branch=z9hG4bK2c5c6d8c
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.1>;tag=as30099b45
To: <sip:187@192.168.2.1>
Contact: <sip:Matej%20Cell%20IP@192.168.2.81:5060>
Call-ID: 454d73757683ac95002ed6683443c9d6@192.168.2.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX 15.6.0
Date: Thu, 09 May 2019 20:18:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1592957180 1592957180 IN IP4 192.168.2.81
s=Asterisk PBX 15.6.0
c=IN IP4 192.168.2.81
t=0 0
m=audio 19330 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
    -- Called SIP/FritzBS/187
Retransmitting #1 (no NAT) to 192.168.2.1:5060:
INVITE sip:187@192.168.2.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.81:5060;branch=z9hG4bK2c5c6d8c
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.1>;tag=as30099b45
To: <sip:187@192.168.2.1>
Contact: <sip:Matej%20Cell%20IP@192.168.2.81:5060>
Call-ID: 454d73757683ac95002ed6683443c9d6@192.168.2.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX 15.6.0
Date: Thu, 09 May 2019 20:18:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1592957180 1592957180 IN IP4 192.168.2.81
s=Asterisk PBX 15.6.0
c=IN IP4 192.168.2.81
t=0 0
m=audio 19330 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
Retransmitting #2 (no NAT) to 192.168.2.1:5060:
INVITE sip:187@192.168.2.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.81:5060;branch=z9hG4bK2c5c6d8c
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.1>;tag=as30099b45
To: <sip:187@192.168.2.1>
Contact: <sip:Matej%20Cell%20IP@192.168.2.81:5060>
Call-ID: 454d73757683ac95002ed6683443c9d6@192.168.2.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX 15.6.0
Date: Thu, 09 May 2019 20:18:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1592957180 1592957180 IN IP4 192.168.2.81
s=Asterisk PBX 15.6.0
c=IN IP4 192.168.2.81
t=0 0
m=audio 19330 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
Retransmitting #3 (no NAT) to 192.168.2.1:5060:
INVITE sip:187@192.168.2.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.81:5060;branch=z9hG4bK2c5c6d8c
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.1>;tag=as30099b45
To: <sip:187@192.168.2.1>
Contact: <sip:Matej%20Cell%20IP@192.168.2.81:5060>
Call-ID: 454d73757683ac95002ed6683443c9d6@192.168.2.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX 15.6.0
Date: Thu, 09 May 2019 20:18:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1592957180 1592957180 IN IP4 192.168.2.81
s=Asterisk PBX 15.6.0
c=IN IP4 192.168.2.81
t=0 0
m=audio 19330 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
Retransmitting #4 (no NAT) to 192.168.2.1:5060:
INVITE sip:187@192.168.2.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.81:5060;branch=z9hG4bK2c5c6d8c
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.1>;tag=as30099b45
To: <sip:187@192.168.2.1>
Contact: <sip:Matej%20Cell%20IP@192.168.2.81:5060>
Call-ID: 454d73757683ac95002ed6683443c9d6@192.168.2.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX 15.6.0
Date: Thu, 09 May 2019 20:18:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1592957180 1592957180 IN IP4 192.168.2.81
s=Asterisk PBX 15.6.0
c=IN IP4 192.168.2.81
t=0 0
m=audio 19330 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
Retransmitting #5 (no NAT) to 192.168.2.1:5060:
INVITE sip:187@192.168.2.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.81:5060;branch=z9hG4bK2c5c6d8c
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.1>;tag=as30099b45
To: <sip:187@192.168.2.1>
Contact: <sip:Matej%20Cell%20IP@192.168.2.81:5060>
Call-ID: 454d73757683ac95002ed6683443c9d6@192.168.2.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX 15.6.0
Date: Thu, 09 May 2019 20:18:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1592957180 1592957180 IN IP4 192.168.2.81
s=Asterisk PBX 15.6.0
c=IN IP4 192.168.2.81
t=0 0
m=audio 19330 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
Retransmitting #6 (no NAT) to 192.168.2.1:5060:
INVITE sip:187@192.168.2.1 SIP/2.0
Via: SIP/2.0/UDP 192.168.2.81:5060;branch=z9hG4bK2c5c6d8c
Max-Forwards: 70
From: "Matej Cell IP" <sip:Matej%20Cell%20IP@192.168.2.1>;tag=as30099b45
To: <sip:187@192.168.2.1>
Contact: <sip:Matej%20Cell%20IP@192.168.2.81:5060>
Call-ID: 454d73757683ac95002ed6683443c9d6@192.168.2.1
CSeq: 102 INVITE
User-Agent: Asterisk PBX 15.6.0
Date: Thu, 09 May 2019 20:18:55 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 286

v=0
o=root 1592957180 1592957180 IN IP4 192.168.2.81
s=Asterisk PBX 15.6.0
c=IN IP4 192.168.2.81
t=0 0
m=audio 19330 RTP/AVP 0 8 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv

---
[May  9 22:19:02] WARNING[4705]: chan_sip.c:4072 retrans_pkt: Retransmission timeout reached on transmission 454d73757683ac95002ed6683443c9d6@192.168.2.1 for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 6400ms with no response
[May  9 22:19:02] WARNING[4705]: chan_sip.c:4096 retrans_pkt: Hanging up call 454d73757683ac95002ed6683443c9d6@192.168.2.1 - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [187@outgoing_TIM_BS:3] PlayTones("SIP/matejcell-000000a9", "congestion") in new stack
    -- Executing [187@outgoing_TIM_BS:4] Hangup("SIP/matejcell-000000a9", "") in new stack
  == Spawn extension (outgoing_TIM_BS, 187, 4) exited non-zero on 'SIP/matejcell-000000a9'
Really destroying SIP dialog '454d73757683ac95002ed6683443c9d6@192.168.2.1' Method: INVITE

Where is the problem??

Thank you

UP UP UP please, thanks!!

Dear all,

Thanks to jcolp and johnkiniston help, here it is a working configuration of an asterisk server connected to a Fritzbox (acting as a voip gateway for asterisk server).

FIrst you need to configure a new Telephone IP device on Fritzbox/Telephony. Take note of the username, password and Fritzbox IP address (like 192.168.1.1)

Access your linux server: cd /etc/asterisk and edit “sip.conf” and “extensions.conf” as follows:

sip.conf

[general]
allowguest=no
alwaysauthreject=yes
prematuremedia=no
progressinband=yes

register => username_of_ip_telephone_device_on_fritzbox:password@fritzbox_ip_address/username_of_ip_telephone_device_on_fritzbox

[username_of_ip_telephone_device_on_fritzbox]
type=friend
context=incoming_TIM_BS
allow=all
defaultuser=username_of_ip_telephone_device_on_fritzbox
fromuser=username_of_ip_telephone_device_on_fritzbox
fromdomain=fritzbox_ip_address
secret=password
host=fritzbox_ip_address
insecure=invite
qualify=yes

[mobile01]
type=friend
host=dynamic
secret=password
context=internal
disallow=all
allow=opus
qualify=yes

Extensions.conf

[internal]

exten => 1000,1,NoOp()
same  => n,Dial(SIP/mobile01,60)
same  => n,Hangup()

exten => _X.,1,NoOp()
same  => n,GoTo(outgoing_TIM_BS,${EXTEN},1)

[outgoing_TIM_BS]

exten => _X.,1,NoOp()
same  => n,Dial(SIP/${EXTEN}@username_of_ip_telephone_device_on_fritzbox)
same  => n,Playtones(congestion)
same  => n,hangup()

[incoming_TIM_BS]

exten => username_of_ip_telephone_device_on_fritzbox,1,NoOp()
same  => n,GoTo(internal,1000,1)
same  => n,Playtones(congestion)
same  => n,hangup()

Access asterisk console “sudo asterisk -rvvv” and enter “sip reload” and “dialplan reload”

Have fun!!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.