Domain name in sip address

Hello all,

I’m fairly new to FreePBX. I have question regarding sip addresses. When I call one of my extensions my current setup shows the servers private IP in any of the local extensions sip address’s eg: [email protected].

This is causing a problem when I redial the sip address from call history. The server can only be reached from outside the network on its wan IP. The private IP that is sent with the call and stored in the call history does not work as expected. Having the Wan IP in the address would work but Ideally I want callers ID’s to show as {extension}@{domain name} eg: [email protected]

Is it possible to set this in FreePBX as I cannot find a way to do it. I have tried to the Outbound CID but this does not seem to work.

Any pointers would be very much appreciated.

pjsip
Asterisk 12.8.2
FreePBX 12.0.76.2

Without knowing your setup better its hard to give you a perfect answer.

But under your extension try changing Host from dynamic to the hostname you want to use.

But be careful that your firewall(s)/name resolution systems can properly and efficiently hairpin external hostnames back to local network hosts.

1 Like

Hi,

Thanks for the suggestion. I cannot find the ‘host’ option when I view an Extension in FreePBX panel. After some further searching it seems to be pointing to a setting called ‘fromdomain’ in sip.conf. I have added fromdomain=sip.domain.com to sip.conf and that does not seem to have any effect. It could be that I’m using pjsip? For example, I call 6004 from 6002 and the following shows as the incoming call ‘[email protected]’. I need it to show ‘[email protected]

look again :wink: , what does (from bash)

head -5 /etc/asterisk/sip.conf

return?

so if you are using pjsip please understand that sip is NOT pjsip so don’t pointlessly “f” with the sip configs.

I thinking (a guess) that sip and pjsip settings are completely different so my ‘fromdomain’ change should not have effect for pjsip.

Output from ‘head -5 /etc/asterisk/sip.conf’ gives:

;--------------------------------------------------------------------------------;
; Do NOT edit this file as it is auto-generated by FreePBX. All modifications to ;
; this file must be done via the web gui. There are alternative files to make ;
; custom modifications, details at: http://freepbx.org/configuration_files ;
;--------------------------------------------------------------------------------;

Looks like the settings that I add are being dropped when Asterisk is restarted.

I think we need more information to help you correctly. Can you provide an explanation of the network. To me right now it seems like you have a hosted PBX solution with multiple sites connected to it. But without really knowing this it makes helping you much harder.

Hi,

Yes, sorry. My setup is my own server (Ubuntu 14.04) that I have installed Asterisk and FreePBX. It is running on a cloud instance (Openstack) with one network interface. One private IP (10.0.5.174) and one Wan IP (x.x.x.x) are assigned. Traffic on the Wan side is filtered with a firewall.
All the extensions are numbered XXXX eg: 6004. When I call 6004 from 6002 or 6001, the incoming SIP address at 6004 is displayed as [email protected]. This is ok when all the sip clients are on the local network as the IP address can be resolved. If a client is outside the network on the internet, the sip address will not work as the 10.0.5.174 address cannot be resolved. If all outgoing calls contain a domain name that resolves to the Wan IP, things should work fine. [email protected] should work from the internet side. I have looked through the FreePBX interface and I cannot find anywhere that an outgoing call can be set to contain a domain name instead of an IP address. After searching as mentioned above, a ‘fromdomain’ option can be set that adds a domain name after the ‘@’ part of the sip address.

Thanks all for your help.

So this is probably a bit outside of the scope of this forum, but I think the issue you are facing is more architectural than configuration.

From what you have said thus far this is what I conclude your network to look like.

FreePBX (10.0.5.174) ---- FW ------- WAN ---- FW ---- SIP Client A (192.168.0.1)
|__FW SIP Client B (10.2.2.8)

In short you have Remote Users logging into the hosted PBX. So they are behind their own firewall etc.

If client A calls Client B, the problem is the Private IP Address of the FreePBX installation is showing Call List of the client, so when you goto Redial, it doesn’t have the correct address information.

If all of my assumptions are correct, you shouldn’t be resolving this from the Clients configuration. In stead you have two options.

  1. Dynamic WAN IP - then you must use a Firewall with ASA type capabilities. Meaning it can translate IP Addresses in the SIP/SDP Payload to the current WAN IP.

  2. Static IP - if you have a firewall with the above capabilities, then great. If not the other option is to configure it in the FreePBX. Under Settings -> Asterisk SIP Settings. You should look at the NAT Settings. Define your external address, local network (if you have any internal calls). Then also review RTP Port ranges and make sure are inline with your port forwarding rules on your firewall.

Thanks for the help. Much appreciated.

I have the External address set and Local networks set in FreePBX under Sip settings’. Port range is 10000-20000. I have removed the Local networks setting hoping that Asterisk would then use the External address and display it after the ‘@’ when a call is made instead of the Local network address. Without being able to set a WAN IP or domain name in the sip address when a call is made, call histories will not work on any of the clients if they are outside the local network. This must be a problem that many must experience but I cannot seem to find much info on the net about this. I could look at manipulating the IP in outgoing traffic using a firewall but this seems like a hack and not a solid solution.

Does anyone know why Asterisk is ignoring the WAN IP and uses the Local IP for addresses instead?

Personally I have used an SBC for controlling FEUs, but I agree there should be a way for this to work. Sorry I am out of ideas

Thanks very much for your help anyway!. I’ll continue trying to solve it and will post the solution if I find one.

Solved (with the help of an Asterisk expert). It turns out that pjsip was not respecting the IP nat configuration. Changed to chan_sip and it now works. The nat I am using is done by Openstack and not a router so that could be causing issues with pjsip detecting if nat is in use for a call or not.

Sorry for bumping old topic. I would like to share the solution if someone has this problem too, because switching to chan_sip was not an option for me and there is no “from domain” option in FreePBX 13.0.190.19 endpoint configuration.

You have to edit pjsip.endpoint_custom_post.conf to add “from_domain” option to your endpoint, like:
[1001](+)
from_domain=external IP address||domain name

Hello, this really works, but it’s FreePBX 15, the end of 2019, and this is still no standard option in the guy…
I will try to file a bug-report or feature-request…

For everybody trying and still not having success:

In SNG, you can use nano to edit the file pjsip.endpoint_custom_post.conf:

nano /etc/asterisk/pjsip.endpoint_custom_post.conf

Next, you add the following 2 lines to your config:

[1001](+)
from_domain=this.example.com

1001 is your extension-number, and this.example.com is your desired hostname. The (+) has to be in braces.

Now you can save the file and restart asterisk. I like to do it this way:

asterisk -rvvvv
core restart now

If you have multiple extensions where you want to have this functionality, you have to specify for every extension-number (maybe there is some functionality to specify all in one, if you do know if and how this works, please comment so I can add this to my code as well!)

Example for 5 extensions:

[1001](+)
from_domain=this.example.com

[1001](+)
from_domain=this.example.com

[1003](+)
from_domain=this.example.com

[1004](+)
from_domain=this.example.com

[1005](+)
from_domain=this.example.com

Reference:
https://wiki.asterisk.org/wiki/display/AST/Adding+to+an+existing+section
https://wiki.asterisk.org/wiki/display/AST/Sections+and+Settings
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Configuration+Files
https://wiki.asterisk.org/wiki/display/AST/Stopping+and+Restarting+Asterisk+From+The+CLI

You can use templates: Home - Asterisk Documentation
Based on your config you can create separate section:

[endpoints](!)   <== exclamation mark means this section will be template to which we can later refer
from_domain=my.domain.com

[1001](endpoints)   <== it will ADD to the section [1001] all parameters listed in template section [endpoints]
option=value

By the way I found that section type “transport” has an option “domain”, with description “Domain the transport comes from” my understanding of this it is default domain which Asterisk will put into “From” header for all outgoing calls. But tests on my local pc shows that it’s not working as expected and value which I put into domain parameter did not appeared in pjsip log

Hi!
I know i can use templates, but that still is very inconvenient.
I have posted the issue you describe right here: https://issues.freepbx.org/browse/FREEPBX-20865 .
It seems like they are not really interested in this issue and don’t get what is actually the issue…
If you like, you can upvote and comment on the issue, maybe it helps.

almost 2 years later… and this still seems to be an issue
we are considering an upgrade from fpbx13 to 16, but if we have to manually maintain all our endpoints (because yealink phones and chan_pjsip does not have a general from_domain) … that would be completely impractical

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