Asterisk puts wrong IP into From header

Hello.
There is a phone network (172.16.16.0/20 ) with SIP devices, which I cannot control or change thei settings.

That network has no registrar; all sip calls are peer-to-peer, so user names/phones are irrelevant, only IP adresses matter.

One of those devices, however, is on my territory, so I can replace it with asterisk server.

The server has two network interfaces, one for the phone network with adress 172.16.19.86, and one for my local home network with address 192.168.1.4.

When I make a call from my home network via asterisk, asterisk somewhy puts home network address to INVITE sent into phone network:

Via: SIP/2.0/UDP 172.16.19.86:5060;rport;branch=z9hG4bKPj9d2f1e95-4a1b-45e2-9d1d-003afc6c5404
From: "6002" <sip:6002@192.168.1.4>;tag=c0e0944e-5815-483e-a690-7de28001761f
To: <sip:172.16.28.10>
Contact: <sip:asterisk@172.16.19.86:5060>
<...>

IP address in From is 192.168.1.4, but it should be 172.16.19.86.
(As far as I understand how B2BUAs should behave)

I dont know why, but other devices answers with 486 Busy Here for such malformed INVITEs, and are working correctly if they see correct address in From. I verified that with sending hand-crafted packets. So keeping things as they are is not an option.

Peers in the phone network are called from dialplan with Dial command:

exten => _XXX_XXX_XXX_XXX,1,Dial(PJSIP/doorphone-network-trunk/sip:172.16.28.10:5060)

(ip is hardcoded for debugging purposes).

So the question is: is there a way to make asterisk put correct header in the From field?

The From header is not malformed.

The URI in the From header is not used for routing purposes within a call; that job is done by the Contact header. The actual specification says it is user provided, not that it is related to the originating machine.

486 is not an appropriate response for an unacceptable From URI. 403 or 603 would be more appropriate.

For full SIP compliance the domain part of the From header would be a domain name, not an IP address, but no-one seems to bother about complying with that guideline, and it is a very weak one. The From header URI is an address of record, not a routing address.

See “from_domain” in res_pjsip - Asterisk Documentation

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