Registering on behalf of another device

I’m trying to achieve something a bit unusual. In a nutshell, I have a device which isn’t able to send out a REGISTER, but everything else works great. This device (A) is located at 172.31.254.255

So I have created device (B) located at 172.31.254.144 which sends out a registration on behalf of device A. It works…it registers as shown below. The “contact” header from B tells Asterisk that it can find this device at 172.31.254.255 (A’s address), and the response VIA line indicates that IP was accepted. (Though the ;receive= acknowledges the SIP connection is from B’s IP). As shown here:


<--- Received SIP request (429 bytes) from TCP:172.31.254.144:51560 --->
REGISTER sip:mydomain.com SIP/2.0
Via: SIP/2.0/UDP 172.31.254.255:5070;branch=z9hG4bK_MyApp_BrCn1
Max-Forwards: 10
To: "MyApp" <sip:260@172.31.254.255:5070;user=260;transport=udp>
From: "MyApp" <sip:260@172.31.254.255:5070;user=260;transport=udp>
Call-ID: 114e453e924f4166b2b0f3466dc18725@172.31.254.255
CSeq: 1 REGISTER
Contact: "MyApp" <sip:260@172.31.254.255:5070;user=260;transport=udp>
User-Agent: MyAgent
Content-Length: 0


<--- Transmitting SIP response (526 bytes) to TCP:172.31.254.144:51560 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 172.31.254.255:5070;rport=51560;received=172.31.254.144;branch=z9hG4bK_MyApp_BrCn1
Call-ID: 114e453e924f4166b2b0f3466dc18725@172.31.254.255
From: "MyApp" <sip:260@172.31.254.255;user=260>
To: "MyApp" <sip:260@172.31.254.255;user=260>;tag=z9hG4bK_MyApp_BrCn1
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1750783419/7358cfd27cc5e69b8caa211f36cebaa9",opaque="1830235d01074e0d",algorithm=MD5,qop="auth"
Server: AsteriskPBX-16.0.40.4(20.0)
Content-Length:  0

The problem is that when I ask Asterisk to show the PJSIP using the CLI it says:

Contact: 260/sip:260@172.31.254.144:33704;user=260; db6f255a30 NonQual nan

So it would seem that Asterisk/PJSIP is using the source IP from the TCP connection used for SIP registration, and ignoring the contact header’s IP. I thought the SIP standard meant that PJSIP had to use the contact IP…(which matches the VIA line’s IP). Is there some way to force Asterisk/PJSIP to use the “contact” header line’s IP instead? (RFC 5923 may explain what I’m seeing, but still want a solution)

*** NOTE *** Please take it as a given that device A can’t register. This is an unusual use case, and I don’t want to get into the details of why. I just want to solve the problem as I’ve described. I’m sure someone wants to reply “fix A”…

You haven’t provided the underlying PJSIP endpoint configuration. I’m guessing you have “rewrite_contact” set to “yes” which would cause the Contact to be rewritten and the connection to be reused.

for your endpoint why attempt to fake registration? Just set a static contact for device A.

[devicea]
type=endpoint
aors=devicea

[devicea]
type=aor
contact=sip:172.31.254.255
qualify_frequency=60

That wasn’t an option for this environment, but certainly a good work around in general.