How to globaly edit pjsip.endpoint.conf

Hello,

I need to configure my FreePBX server so that it replies to the register request coming from the phone on the same port as the register request comes in. I know that setting force_rport=yes under an extension would do it. But since I have many extensions, I wanted to see if there is a way I can globally set force_rport=yes? I tried adding line “force_rport=yes” in pjsip.endpoint.conf via CLI, but it does not save it since the file gets overwritten by the configuration from FreePBX GUI. Is there a way to configure this file using GUI?

Thank you.

You can put your change into
/etc/asterisk/pjsip.endpoint_custom.conf

However, something is fishy. Normally, pjsip will recognize that your extension is behind a NAT and do the right thing. Is there something unusual about your network setup? Also, it’s strange that the extension is not sending the rport tag in the Via header – is that a setting you can change, perhaps globally in EPM?

Extension is sending the rport tag in the via header and pjsip is responding to that port however the UDP packet comes with a different source port and the reply goes to the same port as is specified with the rport tag in the via header. Please see below, i have erased the IP addresses for security reasons. Below the udp source port is 53772, but the sip server responds to the request on port 5060. When I put force_rport=yes, it starts replying to the same port as it was sent on.

Register request:
image

Reply from the SIP server:

There is no way to set force_rport as a global setting. It must be set per endpoint.

So the best way to update all your current extensions:

  1. Go into Bulk Handler. Do an export of all your extensions
  2. Edit the csv file to set the force_rport setting to yes on all your extensions
  3. Save csv and the import via Bulk Handler to import the csv and it will update all your current extensions to have force_rport=yes
  4. Always set up new extensions with force_rport=yes

The other option it to create a template that has the setting in it but you still have to make each endpoint inherit that template to use. So six or half dozen really.

Normally, it is not necessary to use force_rport. Many clients send the rport tag by default and most others have a setting to enable it. Turning this on is IMO cleaner than force_rport, because the resulting SIP is RFC compliant.

In addition, pjsip has logic to recognize when a client is behind a NAT, which causes it to act as if the rport parameter is present.

In your case, the rport tag is not present AND either the client or some router/firewall rewrote the Via header to contain the client’s public IP address AND the port number in Via does not reflect the port from which the request was sent. The combination of all three of these issues causes the registration to fail.

What client device(s) are you using? Do they have an ‘rport’ setting? Have you tried turning it on?

Do you know why the request’s Via header has a public IP? Possibly, it’s a NAT setting in the client; try turning that off. Or, it may be a SIP ALG in the router/firewall through which the client device is connected, which usually should also be disabled.

If you are using EPM, client settings changes can be made in the template and will automatically apply to all extensions.

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