Asterisk within docker


#1

Hi,

I am running asterisk in docker exposing 5060 port and 10000-10010 for rtp. The docker is running in a host in local net 10.0.0.201 and the sip phones are also in 10.0.0.X. I have the transport like this —

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
local_net=172.22.0.2/16
external_media_address=10.0.0.201
external_signaling_address=10.0.0.201

I can register from the phone. But media fails to be established.
What should i do?

Thanks.


#2

I hope i have provided enough information for this. If any more information is needed please let me know.
Please help.


#3

Have you configured Asterisk and the client to restrict media to that port range? In Asterisk, you configure that in rtp.conf.

Can you get a packet capture of the INVITE transaction? You can do that with wireshark or in the Asterisk CLI with “pjsip set logger on”.


#4

Hi Joseph,

First of all i apologise for the delayed response. Actually I thought nobody is replying after one day and didnt revisit the forum.

Here is a more detailed conf and logs ----
docker-compose:

services:
asterisk15:
image: asterisk15:latest
container_name: asterisk15
hostname: asterisk15
restart: unless-stopped
stdin_open: true
ports:
- “5060:5060/udp”
- "10000-10010:10000-10010/udp"
networks:
astnet:
ipv4_address: 192.168.10.4

NOTE: the docker network type is the default “bridge”

In the rtp.conf

[general]
rtpstart=10000
rtpend=10010

the transport in pjsip.conf

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.10.0/8
external_media_address=10.0.0.201
external_signaling_address=10.0.0.201

The docker in running on host 10.0.0.201. The sip phone 1001 and 1002 are also running on 10.0.0.201

Here is the log after setting “pjsip set logger on”

asterisk15*CLI> pjsip set logger on
PJSIP Logging enabled
<— Received SIP request (758 bytes) from UDP:192.168.0.1:53921 —>
INVITE sip:1002@10.0.0.201 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.201:60390;branch=z9hG4bK-524287-1—fea2d47645b08c14;rport
Max-Forwards: 70
Contact: sip:1001@192.168.0.1:55566;rinstance=99b3721656576ad1
To: sip:1002@10.0.0.201
From: sip:1001@10.0.0.201;tag=023f0c04
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
CSeq: 1 INVITE
Allow: SUBSCRIBE, NOTIFY, INVITE, ACK, CANCEL, BYE, REFER, INFO, OPTIONS, MESSAGE
Content-Type: application/sdp
Supported: replaces
User-Agent: Bria 5 release 5.1.0 stamp 89373
Content-Length: 206

v=0
o=- 1518533195959320 1 IN IP4 10.0.0.201
s=Bria 5 release 5.1.0 stamp 89373
c=IN IP4 10.0.0.201
t=0 0
m=audio 62548 RTP/AVP 8 0 101
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv

<— Transmitting SIP response (519 bytes) to UDP:192.168.0.1:53921 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.0.0.201:60390;rport=53921;received=192.168.0.1;branch=z9hG4bK-524287-1—fea2d47645b08c14
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
From: sip:1001@10.0.0.201;tag=023f0c04
To: sip:1002@10.0.0.201;tag=z9hG4bK-524287-1—fea2d47645b08c14
CSeq: 1 INVITE
WWW-Authenticate: Digest realm=“asterisk”,nonce=“1518533205/26e2dfc6d843fcf5727a89b28e975746”,opaque=“5465cbb73307e332”,algorithm=md5,qop="auth"
Server: Asterisk PBX 15.2.0
Content-Length: 0

<— Received SIP request (337 bytes) from UDP:192.168.0.1:53921 —>
ACK sip:1002@10.0.0.201 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.201:60390;branch=z9hG4bK-524287-1—fea2d47645b08c14;rport
Max-Forwards: 70
To: sip:1002@10.0.0.201;tag=z9hG4bK-524287-1—fea2d47645b08c14
From: sip:1001@10.0.0.201;tag=023f0c04
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
CSeq: 1 ACK
Content-Length: 0

<— Received SIP request (1039 bytes) from UDP:192.168.0.1:53921 —>
INVITE sip:1002@10.0.0.201 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.201:60390;branch=z9hG4bK-524287-1—8a39c1718a84a123;rport
Max-Forwards: 70
Contact: sip:1001@192.168.0.1:55566;rinstance=99b3721656576ad1
To: sip:1002@10.0.0.201
From: sip:1001@10.0.0.201;tag=023f0c04
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
CSeq: 2 INVITE
Allow: SUBSCRIBE, NOTIFY, INVITE, ACK, CANCEL, BYE, REFER, INFO, OPTIONS, MESSAGE
Content-Type: application/sdp
Supported: replaces
User-Agent: Bria 5 release 5.1.0 stamp 89373
Authorization: Digest username=“1001”,realm=“asterisk”,nonce=“1518533205/26e2dfc6d843fcf5727a89b28e975746”,uri=“sip:1002@10.0.0.201”,response=“82cdca82a444dca5016c4b4a1798dca3”,cnonce=“336a448fd2e8ccf6b179f663f5fde342”,nc=00000001,qop=auth,algorithm=md5,opaque="5465cbb73307e332"
Content-Length: 206

v=0
o=- 1518533195959320 1 IN IP4 10.0.0.201
s=Bria 5 release 5.1.0 stamp 89373
c=IN IP4 10.0.0.201
t=0 0
m=audio 62548 RTP/AVP 8 0 101
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv

== Setting global variable ‘SIPDOMAIN’ to ‘10.0.0.201’
<— Transmitting SIP response (326 bytes) to UDP:192.168.0.1:53921 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.0.0.201:60390;rport=53921;received=192.168.0.1;branch=z9hG4bK-524287-1—8a39c1718a84a123
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
From: sip:1001@10.0.0.201;tag=023f0c04
To: sip:1002@10.0.0.201
CSeq: 2 INVITE
Server: Asterisk PBX 15.2.0
Content-Length: 0

-- Executing [1002@local:1] NoOp("PJSIP/1001-00000000", "") in new stack
-- Executing [1002@local:2] Verbose("PJSIP/1001-00000000", "1, ""Jon Doe" <1001> dialed."") in new stack

““Jon Doe” <1001> dialed.”
– Executing [1002@local:3] Set(“PJSIP/1001-00000000”, “CDR_PROP(disable)=1”) in new stack
– Executing [1002@local:4] Goto(“PJSIP/1001-00000000”, “internal-main,1002,1”) in new stack
– Goto (internal-main,1002,1)
– Executing [1002@internal-main:1] Verbose(“PJSIP/1001-00000000”, “1, “User 1001 dialed 1002.””) in new stack
"User 1001 dialed 1002."
– Executing [1002@internal-main:2] Set(“PJSIP/1001-00000000”, “DIALED_EXTEN=1002”) in new stack
– Executing [1002@internal-main:3] GotoIf(“PJSIP/1001-00000000”, “0?dialed-BUSY,1:”) in new stack
– Executing [1002@internal-main:4] Dial(“PJSIP/1001-00000000”, “PJSIP/1002,30”) in new stack
– Called PJSIP/1002
<— Transmitting SIP request (949 bytes) to UDP:192.168.0.1:40589 —>
INVITE sip:1002@192.168.0.1:40589;rinstance=a55a21f0a2d53ce2 SIP/2.0
Via: SIP/2.0/UDP 192.168.10.4:5060;rport;branch=z9hG4bKPj251d9796-937d-41ee-a521-7d89a4db74a3
From: “Jon Doe” sip:1001@192.168.10.4;tag=50f8e875-39a0-40c9-8e2d-f5e662cf3e44
To: sip:1002@192.168.0.1;rinstance=a55a21f0a2d53ce2
Contact: sip:asterisk@192.168.10.4:5060
Call-ID: 7dd3291f-e703-4ab0-a954-9e4d4a138e32
CSeq: 6264 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 15.2.0
Content-Type: application/sdp
Content-Length: 237

v=0
o=- 1401251911 1401251911 IN IP4 192.168.10.4
s=Asterisk
c=IN IP4 192.168.10.4
t=0 0
m=audio 10008 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Received SIP response (364 bytes) from UDP:192.168.0.1:40589 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.10.4:5060;rport=5060;branch=z9hG4bKPj251d9796-937d-41ee-a521-7d89a4db74a3;received=10.0.0.201
To: sip:1002@192.168.0.1;rinstance=a55a21f0a2d53ce2
From: “Jon Doe” sip:1001@192.168.10.4;tag=50f8e875-39a0-40c9-8e2d-f5e662cf3e44
Call-ID: 7dd3291f-e703-4ab0-a954-9e4d4a138e32
CSeq: 6264 INVITE
Content-Length: 0

<— Received SIP response (488 bytes) from UDP:192.168.0.1:40589 —>
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.10.4:5060;rport=5060;branch=z9hG4bKPj251d9796-937d-41ee-a521-7d89a4db74a3;received=10.0.0.201
Contact: sip:1002@192.168.0.1:40589
To: sip:1002@192.168.0.1;rinstance=a55a21f0a2d53ce2;tag=ae119224
From: "Jon Doe"sip:1001@192.168.10.4;tag=50f8e875-39a0-40c9-8e2d-f5e662cf3e44
Call-ID: 7dd3291f-e703-4ab0-a954-9e4d4a138e32
CSeq: 6264 INVITE
User-Agent: Bria 3 release 3.5.5 stamp 71243
Allow-Events: hold, talk
Content-Length: 0

-- PJSIP/1002-00000001 is ringing

<— Transmitting SIP response (513 bytes) to UDP:192.168.0.1:53921 —>
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 10.0.0.201:60390;rport=53921;received=192.168.0.1;branch=z9hG4bK-524287-1—8a39c1718a84a123
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
From: sip:1001@10.0.0.201;tag=023f0c04
To: sip:1002@10.0.0.201;tag=03e33564-5d15-4e9e-bbc8-b11df6b51c9f
CSeq: 2 INVITE
Server: Asterisk PBX 15.2.0
Contact: sip:192.168.10.4:5060
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Content-Length: 0

<— Received SIP response (809 bytes) from UDP:192.168.0.1:40589 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.10.4:5060;rport=5060;branch=z9hG4bKPj251d9796-937d-41ee-a521-7d89a4db74a3;received=10.0.0.201
Contact: sip:1002@192.168.0.1:40589
To: sip:1002@192.168.0.1;rinstance=a55a21f0a2d53ce2;tag=ae119224
From: "Jon Doe"sip:1001@192.168.10.4;tag=50f8e875-39a0-40c9-8e2d-f5e662cf3e44
Call-ID: 7dd3291f-e703-4ab0-a954-9e4d4a138e32
CSeq: 6264 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
Content-Type: application/sdp
Supported: replaces, eventlist
User-Agent: Bria 3 release 3.5.5 stamp 71243
Content-Length: 204

v=0
o=- 1518533199140469 3 IN IP4 10.0.0.201
s=Bria 3 release 3.5.5 stamp 71243
c=IN IP4 10.0.0.201
t=0 0
m=audio 52366 RTP/AVP 0 101
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv

   > 0x7fef4006f180 -- Strict RTP learning after remote address set to: 10.0.0.201:52366

<— Transmitting SIP request (421 bytes) to UDP:192.168.0.1:40589 —>
ACK sip:1002@192.168.0.1:40589 SIP/2.0
Via: SIP/2.0/UDP 192.168.10.4:5060;rport;branch=z9hG4bKPje4c7318a-1f3b-43bf-a90c-a9782bbd03c5
From: “Jon Doe” sip:1001@192.168.10.4;tag=50f8e875-39a0-40c9-8e2d-f5e662cf3e44
To: sip:1002@192.168.0.1;rinstance=a55a21f0a2d53ce2;tag=ae119224
Call-ID: 7dd3291f-e703-4ab0-a954-9e4d4a138e32
CSeq: 6264 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 15.2.0
Content-Length: 0

-- PJSIP/1002-00000001 answered PJSIP/1001-00000000
   > 0x7fef40060a40 -- Strict RTP learning after remote address set to: 10.0.0.201:62548

<— Transmitting SIP response (817 bytes) to UDP:192.168.0.1:53921 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.0.0.201:60390;rport=53921;received=192.168.0.1;branch=z9hG4bK-524287-1—8a39c1718a84a123
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
From: sip:1001@10.0.0.201;tag=023f0c04
To: sip:1002@10.0.0.201;tag=03e33564-5d15-4e9e-bbc8-b11df6b51c9f
CSeq: 2 INVITE
Server: Asterisk PBX 15.2.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Contact: sip:192.168.10.4:5060
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length: 227

v=0
o=- 263818264 3 IN IP4 192.168.10.4
s=Asterisk
c=IN IP4 192.168.10.4
t=0 0
m=audio 10006 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

-- Channel PJSIP/1002-00000001 joined 'simple_bridge' basic-bridge <2f67b2aa-8d9f-4d19-859d-d5196246e5bd>
-- Channel PJSIP/1001-00000000 joined 'simple_bridge' basic-bridge <2f67b2aa-8d9f-4d19-859d-d5196246e5bd>
   > Bridge 2f67b2aa-8d9f-4d19-859d-d5196246e5bd: switching from simple_bridge technology to native_rtp
   > Locally RTP bridged 'PJSIP/1001-00000000' and 'PJSIP/1002-00000001' in stack

<— Transmitting SIP response (817 bytes) to UDP:192.168.0.1:53921 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.0.0.201:60390;rport=53921;received=192.168.0.1;branch=z9hG4bK-524287-1—8a39c1718a84a123
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
From: sip:1001@10.0.0.201;tag=023f0c04
To: sip:1002@10.0.0.201;tag=03e33564-5d15-4e9e-bbc8-b11df6b51c9f
CSeq: 2 INVITE
Server: Asterisk PBX 15.2.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Contact: sip:192.168.10.4:5060
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length: 227

v=0
o=- 263818264 3 IN IP4 192.168.10.4
s=Asterisk
c=IN IP4 192.168.10.4
t=0 0
m=audio 10006 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

<— Transmitting SIP response (817 bytes) to UDP:192.168.0.1:53921 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.0.0.201:60390;rport=53921;received=192.168.0.1;branch=z9hG4bK-524287-1—8a39c1718a84a123
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
From: sip:1001@10.0.0.201;tag=023f0c04
To: sip:1002@10.0.0.201;tag=03e33564-5d15-4e9e-bbc8-b11df6b51c9f
CSeq: 2 INVITE
Server: Asterisk PBX 15.2.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Contact: sip:192.168.10.4:5060
Supported: 100rel, timer, replaces, norefersub
Content-Type: application/sdp
Content-Length: 227

v=0
o=- 263818264 3 IN IP4 192.168.10.4
s=Asterisk
c=IN IP4 192.168.10.4
t=0 0
m=audio 10006 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

NOTE: When there is no rtp detected by asterisk after some time it sends BYE but does not get any response –

<— Transmitting SIP request (421 bytes) to UDP:192.168.0.1:55566 —>
BYE sip:1001@192.168.0.1:55566;rinstance=99b3721656576ad1 SIP/2.0
Via: SIP/2.0/UDP 192.168.10.4:5060;rport;branch=z9hG4bKPjfd47ce99-150e-490b-8a97-082d99ff7c1e
From: sip:1002@10.0.0.201;tag=03e33564-5d15-4e9e-bbc8-b11df6b51c9f
To: sip:1001@10.0.0.201;tag=023f0c04
Call-ID: 89373MGMxOGYxNDYyMTA5Mjg3MTdlMWNkZWVmZGY2NDEyM2Q
CSeq: 26006 BYE
Max-Forwards: 70
User-Agent: Asterisk PBX 15.2.0
Content-Length: 0

If any more details is needed please let me know.

Thanks in advance.


#5

I’m a little confused by your network setup. You say that the docker host is 10.0.0.201 and the docker network is “bridged” but you’ve given your container a 192.168.10.4 address so there’s no natting.

The transport has local_net defined as 192.168.10.0/8 which will include all 192.x.x.x addresses.

Requests from the Bria phone for extension 1001 are coming from 192.168.0.1 but reporting 10.0.0.201 in the SDP. Requests to extension 1002 are also going to 192.168.0.1

So, why the 192 network at all? I’d pick one network and get it working, then if you need more than one, we can go from there.


#6

ok my apologies for the network masking. it should be 192.168.10.0/24.

the docker is run on a machine which is the host “10.0.0.201”.

But when docker is deployed, it has its own private network which is 192.168.10.0/24.

If i run the docker in network:host mode it works fine without the extra nat config in transport section.

But i wanted to avoid running docker in host mode.

And after i have corrected it, now it is working.

Thanks Joseph.