Wrong IP address in FROM Header when using two eth interfaces


(Toshe2020) #1

I am running FreePBX 15.0.17.24 with Asterisk 17.9.3 with two ethernet interfaces, one with local network where all the client phones are in (eth0, 192.168.0.0/20) and one that is connected to the internet and therefore to the external SIP Server (eth1, 10.2.x.x/28).

Now I am facing the problem that SIP messages to internal client phones have the wrong IP address in their FROM-Header (10.2.x.x instead 192.168.0.0).

The SIP message from SIP Registrar for incoming call looks like:

<--- Received SIP request (1020 bytes) from UDP:SIPPROVIDERIP:5060 --->
INVITE sip:TARGETNUMBER@SIPPROVIDER;user=phone SIP/2.0
Via: SIP/2.0/UDP SIPPROVIDERIP:5060;branch=z9hG4bKpgrcno1020p0ufmuj990.1
To: <sip:TARGETNUMBER@SOURCEPROVIDER;user=phone>
From: <sip:SOURCENUMBER@SOURCEPROVIDER;user=phone>;tag=SDdk5a201-1249f1ca
Call-ID: SDdk5a201-343b023ee3b8844802dede39d628fe80-ct4u830
CSeq: 1 INVITE
Max-Forwards: 60
Contact: <sip:SOURCENUMBER@SIPPROVIDERIP:5060;transport=udp>
Date: Tue, 13 Apr 2021 11:45:48 GMT
Allow: INVITE, ACK, PRACK, CANCEL, BYE, OPTIONS, MESSAGE, NOTIFY, UPDATE, REGISTER, INFO, REFER, SUBSCRIBE
Supported: resource-priority
P-Asserted-Identity: <sip:SOURCENUMBER@SOURCEPROVIDER;user=phone>
P-Asserted-Identity: <tel:SOURCENUMBER>
Accept: application/sdp
P-Early-Media: supported
Content-Type: application/sdp
Content-Length: 205

v=0
o=- 1240461225 0 IN IP4 SIPPROVIDERIP
s=IMSS
c=IN IP4 SIPPROVIDERIP
t=0 0
m=audio 13942 RTP/AVP 9 8 0 110
a=rtpmap:110 telephone-event/8000
a=fmtp:110 0-15
a=sendrecv
a=maxptime:40
a=ptime:20

but the SIP message to clients phone looks like:

<--- Transmitting SIP request (731 bytes) to UDP:CLIENTIP:5066 --->
INVITE sip:INTERNALNUMBER@CLIENTIP:5066 SIP/2.0
Via: SIP/2.0/UDP 192.168.XX.YY:5060;rport;branch=z9hG4bKPj2fcfc11a-b046-4efd-b048-2db73b007c5c
From: "SOURCENUMBER" <sip:SOURCENUMBER0@10.2.NN.MM>;tag=acb76419-7bf2-4e1a-857c-5ad1f2f42208
To: <sip:INTERNALNUMBER@CLIENTIP>
Contact: <sip:SOURCENUMBER0@192.168.XX.YY:5060>
Call-ID: c32fda0f-2de2-4cab-86f6-bbf6035e6ee7
CSeq: 29826 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
P-Asserted-Identity: "SOURCENUMBER" <sip:SOURCENUMBER0@10.2.NN.MM>
Max-Forwards: 70
User-Agent: FPBX-15.0.17.24(17.9.3)
Content-Length:  0

Does anybody know how to set correct IP address for internal network?


#2

Advanced SIP Settings. Define external IP and local network.


#3

This should not be a problem. The host part of the From header is essentially just a name and I’m not aware of any IP phone, softphone or SIP app that checks this address or would attempt to contact it. If you still believe this is an issue, please post make / model / firmware version.

However,

is definitely a problem. With no SDP, voice cannot be transmitted. Possibly, this resulted from having no codecs enabled, or from misconfiguration of Asterisk. Why do you have Asterisk 17 on your system, and how did you get it? Note that it’s obsolete and in Security Fix Only.
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions
For a production system, I recommend Asterisk 16, unless you need a feature made available in 18.

Strangely, your provider is offering G.729 as first priority codec. That shouldn’t be an issue if your trunk disallows all but alaw and ulaw, but if not and Asterisk is also not configured properly for g729, it might be the cause of your trouble.

If you still have trouble, find the simplest thing that fails. Does *43 (echo test) work? Calling from one extension to another? Outbound calling?

At the Asterisk command prompt, type
pjsip set logger on
and/or
sip set debug on
according to which drivers you are using for trunk and/or extension. Make a failing test call, paste the Asterisk log for the call at pastebin.freepbx.org and post the link here.


(Toshe2020) #4

I already set local IP address and external IP address in Settings -> Asterisk SIP Settings -> General SIP Settings and SIP Settings (chan_pjsip) accordingly, but without effect.

Screenshot_2021-04-13_19-54-40_


(Toshe2020) #5

arielgrin, here are my chan_pjsip settings:

Screenshot_2021-04-13_19-56-40


(Toshe2020) #6

Calls are working fine, audio is available, both for outgoing and incoming calls, for internal and external calls as well as using echo test. The only issue with the wrong IP in FROM is that some of our softphones store that URI in their history and use this for checking their address book for known contacts. This means that it is not possible to call that number back because it then tries to call NUMBER@10.2.X.Y but that IP is not routed in our local network and the call will fail. If user is just entering NUMBER by hand in his softphone this will work, because softphone uses registered SIP server for making the call.

Softphones where we did have such issues are at least linphone and twinkle (both on linux).

Actually it is strange that the softphones don’t use CONTACT header because that one is correct, anyway I assume it is wrong that the FROM Header field is translated from external IP to wrong internal IP from client point of view.


#7

In my experience, after changing SIP Settings, you need to restart Asterisk for them to take effect.

In any case, I suspect that you don’t want the 10.x networks as local networks because you explained that those networks are connected to your VSP, not your phones, but I can be mistaken.

In the deploys I have using more than one ethernet interface, the only local networks that I have listed are those that can receive registrations for my phones, for example the local LAN, or the OpenVPN subnet, etc, but never the network that is used to connect to the provider, assuming that network is connected to a separate ethernet.


(Toshe2020) #8

ok so I removed 10.x networks from Settings -> Asterisk SIP Settings -> General SIP Settings and I also removed the entry in local network in chan_pjsip setting completely because lines added there have been added to /etc/asterisk/pjsip.transports.conf which results in those entries being duplicated there. I also changed subnet from short form (20) to long form (255.255.240.0).

Anyway, I still have the issues that the FROM header contains 10.x IP address whereas CONTACT header contains correct 192.X IP address :frowning:

I restarted asterisk using core restart now in asterisk CLI after saving my changes in WebGUI.


(Toshe2020) #9

Any other ideas? I am still facing this issue the the FROM header is having a wrong IP address (where as in CONTACT header it is correct!)