Problems with the Request-Line at SIP-Invite

Phone A ---------> PBX <------------Asterisk <-------Phone B

Hello guys,

so here is the situation: I use asterisk to register at a sip-proxy (test.abs.ntx) that has the domain abc.com. This works fine. Phone A works (inbound and outbound calls possible), whereas Phone B only works for inbound calls. Phone B’s outbound calls get rejected by the PBX, because of authentication problems (Status 407 Proxy Authenticication Required). Comparing Phone A’s and Phone B’s sip invite messages (via wireshark) shows, that Phone A requests a line at abc.com, whereas Phone B requests a line at test.abs.ntx (first line in Phone A’s Invite and Phone B’s Invite code section see below). So my assumption is, that the authenticication error is only a result of the different line requests and not a root-cause itself. And finally the question:

What do I need to do, to change Phone B’s request-line to abc.com? My guess is, that I messed up the sip.conf. :confused:

Phone A’s Register:

REGISTER sip:abc.com SIP/2.0
Authorization: Digest username="Milchmann_N",realm="abc.com",nonce="fe3680a8e909d311",response="db1582fc8735db4fd25ca310a311038b",uri="sip:abc.com",qop=auth,cnonce="bdc2cd94e909d311",nc=00000002,algorithm=MD5
Via: SIP/2.0/UDP 10.124.239.42:5060;branch=z9hG4bK-B318A8EB;rport
From: <sip:Milchmann_N@abc.com>;epid=0050c26a5027;tag=3365402349
To: <sip:Milchmann_N@abc.com>
Call-ID: b4930e8ae909d311ad660050c26a5027@10.124.239.42
CSeq: 1040 REGISTER
Contact: <sip:Milchmann_N@10.124.239.42:5060;transport=UDP>;expires=120
Content-Length: 0
Expires: 120
Max-Forwards: 70
User-Agent: (innovaphone IP150/9.00 hotfix31 [9.061333/9061333/101])
Allow-Events: reg,dialog,message-summary,presence

Phone B’s Register:

REGISTER sip:abc.com SIP/2.0
Via: SIP/2.0/UDP 10.124.239.47:60346;branch=z9hG4bK265bcd76;rport
From: <sip:IP3_Sample1@abc.com>;tag=as45d15dcd
To: <sip:IP3_Sample1@abc.com>
Call-ID: 07d272883df27db63a193b5b6ba99d62@127.0.0.1
CSeq: 102 REGISTER
User-Agent: PhoneIP
Max-Forwards: 70
Expires: 300
Contact: <sip:301@10.124.239.47:60346>
Event: registration
Content-Length: 0

Phone A’s Invite:

[code]INVITE sip:301@abc.com;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.124.239.42:5060;branch=z9hG4bK-B318A8EC;rport
From: sip:Milchmann_N@abc.com;epid=0050c26a5027;tag=3365402350
To: sip:301@abc.com;user=phone
Call-ID: 18372b47e909d311ad660050c26a5027@10.124.239.42
CSeq: 6160440 INVITE
Contact: sip:Milchmann_N@10.124.239.42:5060;transport=UDP
Allow: REGISTER,SUBSCRIBE,NOTIFY,INVITE,ACK,PRACK,OPTIONS,BYE,CANCEL,REFER,INFO,UPDATE,PUBLISH
Content-Length: 256
Content-Type: application/sdp
Max-Forwards: 63
Supported: 100rel,replaces,privacy,timer,from-change,histinfo,answermode
User-Agent: (innovaphone IP150/9.00 hotfix31 [9.061333/9061333/101])
P-Preferred-Identity: sip:164@abc.com;user=phone
P-Sig-Options: Overlap-Dialing

v=0
o=- 5 1 IN IP4 10.124.239.42
s=-
t=0 0
m=audio 16394 RTP/AVP 18 4 8 0 101 13
c=IN IP4 10.124.239.42
a=rtpmap:101 telephone-event/8000
a=fmtp:18 annexa=yes
a=fmtp:18 annexb=no
a=fmtp:101 0-15
a=ptime:60
a=silenceSupp:off - - - -
a=sendrecv[/code]

Phone B’s Invite:

[code]INVITE sip:164@test.abs.ntx:5060;user=phone SIP/2.0
Via: SIP/2.0/UDP 10.124.239.47:60346;branch=z9hG4bK4e699522;rport
From: “Phone IP” sip:IP3_Sample1@abc.com;tag=as1da1cf97
To: sip:164@test.abs.ntx:5060;user=phone
Contact: sip:IP3_Sample1@10.124.239.47:60346
Call-ID: 1abc3dda5fb802eb035a1f755e62ab3c@abc.com
CSeq: 104 INVITE
User-Agent: PhoneIP
Max-Forwards: 70
Proxy-Authorization: Digest username=“IP3_Sample1”, realm=“abc.com”, algorithm=MD5, uri=“sip:164@test.abs.ntx:5060;user=phone”, nonce=“fe3680a8e909d311”, response=“c4e5a66511a2dc19402bccb3bf60306f”, qop=auth, cnonce=“44dd240b”, nc=00000001
Date: Mon, 01 Jan 2007 00:42:16 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces
Content-Type: application/sdp
Content-Length: 266

v=0
o=root 18488 18490 IN IP4 10.124.239.47
s=session
c=IN IP4 10.124.239.47
t=0 0
m=audio 10600 RTP/AVP 8 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv
[/code]

Sip.conf

[general]
register=>IP3_Sample1@abc.com:IP3@test.abs.ntx:5060/301
registerattempts=3
registertimeout=5
language=en
pedantic=yes
usereqphone=yes
useragent=PhoneIP
srvlookup=no
allowguest=yes
bindport=60346
context=active
disallow=all
allow=alaw,ulaw
realm=abc.com

[to_sip_proxy]
type=peer
context=incoming
fromdomain=abc.com    
fromuser=IP3_Sample1 
host=test.abs.ntx   
dtmfmode=rfc2833    
disallow=all     
allow=alaw,ulaw 
username=IP3_Sample1
secret=IP3     
insecure=invite
canreinvite=yes
port=5060      
               
[301]     
type=peer 
context=outgoing
username=onboard
callerid="IP3_Sample1" <301>
host=dynamic                
dtmfmode=rfc2833            
qualify=100     
disallow=all    
allow=alaw,ulaw
canreinvite=no 
port=60348     
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.0.0.0

extension.conf

[outgoing]
include => test
include => dial_from_phoneapp

[dial_from_phoneapp]
include => speeddial
include => parkedcalls

exten => ${PHONENUMBER},1,Hangup(403)

exten => _X.,1,Verbose(Outgoing Call form ${CALLERID(name)} to SIP/${EXTEN}@to_sip_proxy.)
exten => _X.,n,Set(GLOBAL(REDIALING)=${EXTEN})
exten => _X.,n,ExecIf($["${atx}" = "on"],Dial,SIP/${EXTEN}@to_sip_proxy,,gHKT)
exten => _X.,n,ExecIf($["${atx}" = "off"],Dial,SIP/${EXTEN}@to_sip_proxy,,gH)

exten => _X!,1,Verbose(Outgoing Call form ${CALLERID(name)} to SIP/${EXTEN}@to_sip_proxy.)
exten => _X!,n,Set(GLOBAL(REDIALING)=${EXTEN})
exten => _X!,n,ExecIf($["${atx}" = "on"],Dial,SIP/${EXTEN}@to_sip_proxy,,gHKT)
exten => _X!,n,ExecIf($["${atx}" = "off"],Dial,SIP/${EXTEN}@to_sip_proxy,,gH)

Thx for your help.
Henning

You have no sip.conf entry for 164, and you do have allowguest=true. 164 is making calls in unregistered mode (as could a phone fraudster).

You also have options that are deprecated or not supported in current versions of Asterisk.

Thanks David for the fast response.

I forgot to mention, that I use asterisk 1.4.42.

At the moment I don’t worry about fraudster, this will be a next step. What I don’t understand is, how to make my settings that Phone B requests a line at abc.com. So here is what I figured out so far (please correct me if I have misunderstood something:

Phone B registers at the domain abc.com, because of the register command in sip.conf.

register=>IP3_Sample1@abc.com:IP3@test.abs.ntx:5060/301
register=>username@fromdomain:secret@host:port/ext

But when Phone B tries to call another sip-client (Phone A) it sends a Invite msg like this…

INVITE sip:164@test.abs.ntx:5060;user=phone SIP/2.0

…and is rejected by the PBX.

Whereas Phone A is able to call Phone B, thus passing the PBX authentication request. I “cloned” the settings of both phones, it does not change anything, therefore I guess it has something to do with my asterisk settings, because the sip invite message gets altered somehow (see above). The correct Invite-Msg would have to look like this (compare Phone A in post 1)

INVITE sip:301@abc.com;user=phone SIP/2.0

I thought the sip.conf parameter fromdomain sets the domain part of the “sip identity” (“CallerID” username@fromdomain).

So why is the fromdomain-part of my sip identity my host paramter (test.abs.ntx) instead of my fromdomain parameter (abc.com)? Do you have any ideas?

regards
Henning

From domain sets the value in the From header, not the request, and applies to outgoing legs. For something that registers, that comes crom the Contact header in the REGISTER response. However you will not get one for 164, as you are missin sip.conf entries for it, so the phone will use whatever its fallback strategy is.

As the phone is registering, the Asterisk fromdomain won’t even control its From header.

Hello David,

thanks for the hint regarding the header’s parameter FROM and TO that helped. Unforunatly, I have to rephrase my problem now.

I have a softphone and asterisk running on the same pc. The softphone registers at the local asterisk. Asterisk registers at an external PBX. I am trying to call a second phone, that is externally registerd at the PBX under extension 164, therefore I don’t need an entry in the asterisk’s sip.conf for 164.

external Phone No.164 registered at ----> external PBX <----- Asterisk registered at external PBX <------ softphone No. 301

So what I want to accomplish is:

  1. external phone registers at external PBX (extension 164) color=#40FFBF[/color]

  2. Asterisk registers at external PBX color=#00FFBF[/color]
    register=>Phone@abc.com:secret:username@test.abs.ntx:5060/301

  3. Softphone registers at Asterisk color=#00FFBF[/color]

  4. Softphone calls Astrerisk (extension XY) color=#00FFBF[/color]
    exten => _X!,n,Dial(SIP/${EXTEN}@to_sip_proxy,gH)

  5. Asterisk routes / forwards the call to external PBX [color=#FFBF00](done and fail)[/color]
    a) call reaches external PBX
    b) call is rejected (Status 407), because of the To-Parameter in the SIP-Header.

  6. external PBX forwards call to final target (external Phone) color=#FF0000[/color]

The Asterisk internal SIP-traces show that the To-Parameter changes, when the dialplan actually uses the dial-app. So Asterisk calls the external PBX with the To-Param sip:164@test.abs.ntx:5060;user=phone, but the paramater should be sip:164@abc.com:5060;user=phone instead.

What do I have to modify, that the TO-parameter is abc.com instead of test.abs.ntx?

[code][general]
register=>Phone@abc.com:secret:username@test.abs.ntx:5060/301
pedantic=yes
allowguest=yes
bindport=60346
context=noreg
disallow=all
allow=alaw,ulaw

[to_sip_proxy]
type=peer
context=incoming
username=username
secret=secret
fromdomain=abc.com
fromuser=Phone
host=test.abs.ntx
insecure=invite
canreinvite=no
port=5060

[301]
type=peer
context=outgoing
host=dynamic
qualify=100
canreinvite=no
port=60348
[/code]

I think you need a proxy; Asterisk is a back to back user agent.

Normal SIP systems route on the request URI, not on the To header.

Thanks David,

you pointed me in the right direction:

Old sip.conf that caused trouble:

host=test.abs.com
fromdomain=abc.com

New and working sip.conf

host=abc.com
fromdomain=abc.com
outboundproxy=test.abs.com

So as I assumend the authentication error was not the root cause of my problems, but that my old sip.conf made asterisk to request a wrong line in its invite messages (test.abs.com instead of abc.com).

Problem solved. :smile:

best regards and have a nice weekend
Henning