Asterisk/OpenSER Incoming Call Problem

The Setup:

I have two asterisk servers, AsterA and AsterB, and one OpenSER server acting as a proxy. Both AsterA and AsterB are connected to Ser as sip clients. On the asterisk servers I have defined a SIP trunk.

The idea is that users/extensions on AsterA should be able to reach users/extensions on AsterB via Ser.

The Problem:

My extension numbers on AsterA range from 201 to 220. On AsterB I also have the same range of extensions, 201 to 220. When user 205 on AsterA places a call to user 201 on AsterB, he gets a network congestion message. Looking at the sip packets in Asterisk CLI, I get a “Forbidden” message from AsterB.

Here’s the interesting bit:
When I create a user/extension on AsterA that does not exist on AsterB, like 401, I do not get this problem and the call goes through just fine. Apparently, the problem has to do with the fact that I am using the same list of extensions on both asterisk servers.

Detailed Configuration:

All three servers are on the same network.

IP Address of AsterA: 192.168.0.9
IP Address of AsterB: 192.168.0.14
IP Address of SER: 192.168.0.15

To dial out from either asterisk server using the SIP trunk: 91 must be entered before the number

SER must know which server the call is meant for, so the following codes are used by SER to distinguish between calls for AsterA and AsterB:

AsterA: 52
AsterB: 51

Example 1: If 205 on AsterA wants to call 201 on AsterB, he must dial 9151201
Example 2: If 201 on AsterB wants to call 205 on AsterA, he must dial 9152205

I have insecure=invite in both sip.conf files, for AsterA and AsterB

Below are the sip packets I picked up at AsterA (192.168.0.9) when 9152201 was dialed by extension 205 at AsterB (192.168.0.14)

<-- SIP read from 192.168.0.15:5060:
INVITE sip:201@192.168.0.9 SIP/2.0
Record-Route: sip:192.168.0.15;lr=on;ftag=as0ebc5aac
Via: SIP/2.0/UDP 192.168.0.15;branch=z9hG4bKbb71.5d6dc223.0
Via: SIP/2.0/UDP 192.168.0.14:5060;branch=z9hG4bK3170503d;rport=5060
From: “205” sip:205@192.168.0.14;tag=as0ebc5aac
To: sip:52201@192.168.0.15
Contact: sip:205@192.168.0.14
Call-ID: 3f282c4a48f8ec96669305565da7980a@192.168.0.14
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Max-Forwards: 69
Date: Thu, 30 Nov 2006 11:25:31 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Content-Type: application/sdp
Content-Length: 238

v=0
o=root 9000 9000 IN IP4 192.168.0.14
s=session
c=IN IP4 192.168.0.14
t=0 0
m=audio 19704 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -

— (15 headers 11 lines) —
Using INVITE request as basis request - 3f282c4a48f8ec96669305565da7980a@192.168.0.14
Sending to 192.168.0.15 : 5060 (non-NAT)
Reliably Transmitting (no NAT) to 192.168.0.15:5060:
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.0.15;branch=z9hG4bKbb71.5d6dc223.0;received=192.168.0.15
Via: SIP/2.0/UDP 192.168.0.14:5060;branch=z9hG4bK3170503d;rport=5060
From: “205” sip:205@192.168.0.14;tag=as0ebc5aac
To: sip:52201@192.168.0.15;tag=as2a7b6cfc
Call-ID: 3f282c4a48f8ec96669305565da7980a@192.168.0.14
CSeq: 102 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="1371cb5b"
Content-Length: 0


Scheduling destruction of call ‘3f282c4a48f8ec96669305565da7980a@192.168.0.14’ in 15000 ms
Found user ‘205’
<-- SIP read from 192.168.0.15:5060:
ACK sip:201@192.168.0.9 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15;branch=z9hG4bKbb71.5d6dc223.0
From: “205” sip:205@192.168.0.14;tag=as0ebc5aac
Call-ID: 3f282c4a48f8ec96669305565da7980a@192.168.0.14
To: sip:52201@192.168.0.15;tag=as2a7b6cfc
CSeq: 102 ACK
User-Agent: OpenSer (1.1.0-notls (i386/linux))
Content-Length: 0

— (8 headers 0 lines) —

<-- SIP read from 192.168.0.15:5060:
INVITE sip:201@192.168.0.9 SIP/2.0
Record-Route: sip:192.168.0.15;lr=on;ftag=as0ebc5aac
Via: SIP/2.0/UDP 192.168.0.15;branch=z9hG4bKcb71.18308a81.0
Via: SIP/2.0/UDP 192.168.0.14:5060;branch=z9hG4bK73fc192a;rport=5060
From: “205” sip:205@192.168.0.14;tag=as0ebc5aac
To: sip:52201@192.168.0.15
Contact: sip:205@192.168.0.14
Call-ID: 3f282c4a48f8ec96669305565da7980a@192.168.0.14
CSeq: 103 INVITE
User-Agent: Asterisk PBX
Max-Forwards: 69
Proxy-Authorization: Digest username=“bf51”, realm=“asterisk”, algorithm=MD5, uri="sip:52201@192.168.0.15", nonce=“1371cb5b”, response=“8ecd1a24c31a02fc938308a0f5c48924”, opaque=""
Date: Thu, 30 Nov 2006 11:25:31 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Content-Type: application/sdp
Content-Length: 238

v=0
o=root 9000 9001 IN IP4 192.168.0.14
s=session
c=IN IP4 192.168.0.14
t=0 0
m=audio 19704 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -

— (16 headers 11 lines) —
Using INVITE request as basis request - 3f282c4a48f8ec96669305565da7980a@192.168.0.14
Sending to 192.168.0.15 : 5060 (non-NAT)
Found user '205’
Reliably Transmitting (no NAT) to 192.168.0.15:5060:
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.0.15;branch=z9hG4bKcb71.18308a81.0;received=192.168.0.15
Via: SIP/2.0/UDP 192.168.0.14:5060;branch=z9hG4bK73fc192a;rport=5060
From: “205” sip:205@192.168.0.14;tag=as0ebc5aac
To: sip:52201@192.168.0.15;tag=as2a7b6cfc
Call-ID: 3f282c4a48f8ec96669305565da7980a@192.168.0.14
CSeq: 103 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Content-Length: 0


<-- SIP read from 192.168.0.15:5060:
ACK sip:201@192.168.0.9 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15;branch=z9hG4bKcb71.18308a81.0
From: “205” sip:205@192.168.0.14;tag=as0ebc5aac
Call-ID: 3f282c4a48f8ec96669305565da7980a@192.168.0.14
To: sip:52201@192.168.0.15;tag=as2a7b6cfc
CSeq: 103 ACK
User-Agent: OpenSer (1.1.0-notls (i386/linux))
Content-Length: 0

— (8 headers 0 lines) —
Destroying call ‘3f282c4a48f8ec96669305565da7980a@192.168.0.14’