PfSense VoIP Configuration

How to configure pfSense firewall for VoIP

pfSense is a free and open source firewall and router that also features unified threat management, load balancing, multi WAN, and more.


Configure Ports

Configure your SIP and RTP ports. SIP port is the default 5060 and RTP is between 10000 and 65335.

Configure the WAN IP Address

Asterisk Example - Also be sure to specify "externip" or "externhost" in sip.conf. externhost configured to a dyndns.org account that resolves to my WAN ip address.

Configure NAT

Asterisk Example - Make sure you have "nat=yes" and "canreinvite=yes" in sip.conf

Configure your local network

Make sure you have localnet setup to correspond with your local network in sip.conf. You can use the RFC1918 method or CIDR method.

localnet=192.168.1.0/24
Configure your SIP context

In your SIP provider's context in sip.conf, make sure you have "outboundproxy=192.168.1.1", replacing 192.168.1.1 with whatever your pfSense running siproxd ip address is.

[sipconvergence]
type=peer
user=phone
host=SEE VOICEHOST CONTROL PANEL FOR DETAILS
outboundproxy=192.168.1.1
fromdomain=SEE VOICEHOST CONTROL PANEL FOR DETAILS
fromuser=<censored>
secret=<censored>
username=<censored>
insecure=very
context=ivr
authname=<censored>
canreinvite=yes

Please note that if you don't use a PBX like Aterisk and use a softphone to connect, you will use your pfSense ip address for the proxy instead of sip.sipconvergence.co.uk

Configure pfSense firewall/nat rules
RTP

Add a NAT rule for RTP. This is essential or you will have no audio or one way audio in your calls. Also change the NAT IP to whatever your Asterisk server is and change the description to something that makes sense for you.

Interface: WAN
Protocol: UDP
External port range: From: 10000
External port range: To: 65335
NAT IP: 192.168.1.50
Local Port: 10000
Description: Hosted PBX - RTP
Enable Auto-add a firewall rule to permit traffic through this NAT rule
SIP

Add a NAT rule for SIP. This is essential or you won't be able to receive calls and you may have trouble registering with your SIP provider. Also change the NAT IP to whatever your Asterisk server is and change the description to something that makes sense for you.

Interface: WAN
Protocol: UDP
External port range: From: 5060
External port range: To: 5060
NAT IP: 192.168.1.50
Local Port: 6000
Description: Hosted PBX - SIP
Enable Auto-add a firewall rule to permit traffic through this NAT rule
The SIP Proxy siproxd
Install siproxd

Go to the pfSense web UI and going to System -> Packages. Hit the "+" button to the right of siproxd and let pfSense install the SIP proxy.

Configure siproxd

Go back to the main pfSense web UI page then go to Services -> siproxd. It may be under Services -> SIP Proxy as well. siproxd configured, be sure to change your "Outbound Proxy Hostname" to the hostname or IP (IP in my case) to your sip provider. Options not specified, leave blank or default.

Inbound Interface: LAN
Outbound Interface: WAN
Enable RTP Proxy: Enable
RTP Port Range (lower): 7070
RTP Port Range (upper): 7080
Outbound Proxy Hostname: xx.xx.xx.xx
Summary

Basically when you make a call your asterisk box will talk to the SIP proxy, the SIP proxy will then talk to your VoIP provider. When you receive a call your VoIP provider will talk directly with your asterisk box (this is important for setting "externip" or "externhost" in sip.conf).

QoS (Traffic Shaping) Traffic shaping can be enabled to allow n simultaneous 64kbps calls to happen and guarantee bandwidth. Please refer to http://doc.pfsense.org/index.php/Traffic_Shaping_Guide for traffic shaping help.

Broadband Connection Fault Checklist

Initial Broadband fault checks for VoiceHost ADSL and FTTC connections
  1. Check the router is set to an 'Always on' connection and not 'On demand'.
  2. If you have ADSL try changing the ADSL Micro Filter, the most common cause of intermittent connections is a faulty filter. If you have FTTC please skip this step.
  3. Please ensure that you change the RJ-11 lead between the microfilter/FTTC faceplate and the router/modem.
  4. Make sure your router is connected to the BT Master Socket and no telephone extension leads are used between the wall and the router. Only use the supplied modem cable directly into the BT master socket.
  5. You can also try disconnecting any additional devices connected to the phone line such as fax machines, Sky Box, Red Care alarm, Credit Card terminal/Paying Device, telephone extension leads, etc. to avoid any possible interferences coming from these devices.
  6.  Swap the router out for a replacement.
  7. Noises on the telephone line can cause disconnections in the broadband signal. In order to identify if this is the case please try a Quiet Line Test.
  8. Connect only a phone, preferably a corded one, directly to the phone socket and dial 17070. It is recommended that you disconnect all devices from the line, such as ADSL routers, phones, faxes, credit card terminals, Sky Boxes and alarm systems.
    Once prompted, select option 2, and then observe the line for any cracklings, noises, interferences or clicks.
    If you do hear noises on the line, please contact the line provider and inform them that your line is experiencing high noise on the line and this is affecting your broadband signal.
    If you are still experiencing disconnects after carrying out the above checks please contact the support department to carry out further fault diagnostics on the line.

NOTE: It may require an engineer visit to resolve the issue, therefore it is important to carry out the above checks to rule out any equipment faults on site. Any engineer visits that do not find a fault within the provider network are chargeable.

SIP ALG and why it should be disabled on most routers

What is SIP ALG?

SIP ALG stands for Application Layer Gateway and is common in all many commercial routers. Its purpose is to prevent some of the problems caused by router firewalls by inspecting VoIP traffic (packets) and if necessary modifying it.

Many routers have SIP ALG turned on by default.

There are various solutions for SIP clients behind NAT, some of them in the client side (STUN, TURN, ICE), others are in the server side (Proxy RTP as RtpProxy, MediaProxy).

Generally speaking, ALG works typically in the client side LAN router or gateway. In some scenarios, some client-side solutions are not valid, for example, STUN with symmetrical NAT router. If the SIP proxy doesn't provide a server-side NAT solution, then an ALG solution could have a place.

An ALG understands the protocol used by the specific applications that it supports (in this case SIP) and does a protocol packet-inspection of traffic through it. A NAT router with a built-in SIP ALG can re-write information within the SIP messages (SIP headers and SDP body) making signalling and audio traffic between the client behind NAT and the SIP endpoint possible.

How can it affect VoIP?

Even though SIP ALG is intended to assist users who have phones on private IP addresses (Class C 192.168.X.X), in many cases it is implemented poorly and actually causes more problems than it solves. SIP ALG modifies SIP packets in unexpected ways, corrupting them and making them unreadable. This can give you unexpected behaviour, such as phones not registering and incoming calls failing.

Therefore if you are experiencing problems we recommend that you check your router settings and turn SIP ALG off if it is enabled.

  • Lack of incoming calls: When a UA is switched on it sends a REGISTER request to the proxy in order to be localisable and receive any incoming calls. This REGISTER is modified by the ALG feature (if not the user wouldn't be reachable by the proxy since it indicated a private IP in REGISTER "Contact" header). Common routers just maintain the UDP "connection" open for a while (30-60 seconds) so after that time the port forwarding is ended and incoming packets are discarded by the router. Many SIP proxies maintain the UDP keepalive by sending OPTIONS or NOTIFY messages to the UA, but they just do it when the UA has been detected as NAT'd during the registration. A SIP ALG router rewrites the REGISTER request to the proxy doesn't detect the NAT and doesn't maintain the keepalive (so incoming calls will be not possible).
  • Breaking SIP signalling: Many of the actual common routers with inbuilt SIP ALG modify SIP headers and the SDP body incorrectly, breaking SIP and making communication just impossible. Some of them do a whole replacing by searching a private address in all SIP headers and body and replacing them with the router public mapped address (for example, replacing the private address if it appears in "Call-ID" header, which makes no sense at all). Many SIP ALG routers corrupt the SIP message when writing into it (i.e. missed semi-colon ";" in header parameters). Writing incorrect port values greater than 65536 is also common in many of these routers.
  • Disallows server-side solutions: Even if you don't need a client-side NAT solution (your SIP proxy gives you a server NAT solution), if your router has SIP ALG enabled that breaks SIP signalling, it will make communication with your proxy impossible.

I have disabled SIP ALG but I'm still experiencing problems...

If you are still having problems after disabling SIP ALG, please check your firewall configuration.


I can't disable SIP-ALG? How to Circumnavigate any networking vendors broken implementation of SIP ALG
  • Enable TLS on SIP Endpoints, VoiceHost supports TLS which masks SIP signalling from the prying eyes of ALG functionality.
  • Enable IPv6 on SIP Endpoints. Practically this is not a realistic option for users requiring mobility but for static locations, this does remove the requirement (Must be supported by your ISP). Most Internet providers do not fully support pure IPv6
  • Change you Router Obviously a last resort if all else fails.

How do I turn off SIP ALG?
Most home/residential routers have a web interface. Typically this is 192.168.1.1 but you just check your default gateway by typing ipconfig in Windows command prompt or ifconfig on Linux systems from any connected device on the same LAN.
If your router does not have a web interface you will most likely need a Telnet client to login.
If you don't have a telnet client installed we recommend Smartty (smartty.sysprogs.com)
Connect in telnet to the IPv4 address of your gateway and hit enter again.
Asus Routers

Disable the option SIP Passthrough under Advanced Settings / WAN -> NAT Passthrough.
If your router doesn't have this option SIP ALG may be disabled via Telnet.

nvram get nf_sip 
(It should return a "1")

nvram set nf_sip=0 
nvram commit
Reboot

AVM Fritz!Box
SIP ALG cannot be disabled. (See above on how to get around this)
Barracuda Firewalls
Go to Firewall > Firewall Rules > Custom FirewallAccess Rules
Click the "Disabled" check box next to any rules named LAN-2-INTERNET-SIP and INTERNET-2-LAN-SIP
This disables SIP ALG.
Billion
Navigate to the web interface
-> Select Configuration
-> Select NAT
-> Select ALG
-> Disable SIP ALG
BT (Homehubs)
SIP ALG cannot be disabled in the settings of BT HomeHubs but can be disabled with BT Business Hub versions 3 and higher.
Cisco RV Range
(RV082, RV016, RV042, RV042G, RV325)
-> Go to System Summary and ensure that the firmware is up to date (1.1.1.06 or later).
-> f needed, update firmware by going to System Management > Firmware Upgrade.
-> Go to Firewall > General.
-> Ensure that Firewall and Remote Management are enabled (checked).
-> Ensure that the following are disabled (unchecked):
-> SPI (Stateful Packet Inspection)
-> DoS (Denial of Service)
-> Block WAN Request
-> SIP ALG
-> Click Save.
-> Browse to IPADDRESS/f_general_hidden.htm.
-> Set UDP Timeout to 300 seconds.
-> Go to Firewall > Access Rules.
-> Whitelist VoiceHost IP ranges
Save all changes.
D-Link
In 'Advanced' settings --> 'Application Level Gateway (ALG) Configuration' un-tick the 'SIP' option.
DD-WRT
No ALG function available - Consider using a public STUN server
DrayTek

DrayTek Vigor 2760 devices, the option can be found in the regular interface at Network -> NAT -> ALG.

If your device does not have a web interface then you'll need a telnet client.

You will be prompted to provide a username and/or password. These are the same credentials used to access the router's web interface.

Afterwards, type in these commands:

sys sip_alg 0
sys commit

On Draytek Vigor2750 and Vigor2130 please use these commands instead:

kmodule_ctl nf_nat_sip disable
kmodule_ctl nf_conntrack_sip disable

EE

Huawei E5330

Navigate to the web interface
Click Settings.
Enter the required username and password, then click Log In. 
Note: The default username and password is admin.
Click the Security dropdown.
Click SIP ALG Settings.
Untick the Enable SIP ALG box.
Click Apply.

Fortinet

Fortigate:

Disabling the SIP ALG in a VoIP profile
SIP is enabled by default in a VoIP profile. If you are just using the VoIP profile for SCCP you can use the following command to disable SIP in the VoIP profile.

config voip profile
edit VoIP_Pro_2
config sip
set status disable
end

Huawei

The SIP ALG setting is usually found in the Security menu.

  1. Vodafone / Huawei (HHG2500)
  2. TalkTalk / Huawei (HG633) 
  3. EE / Huawei (E5330)
Juniper

Type the following into the CLI
To check if currently enabled or disabled run show security alg status | match sip
To disable run:

configure
set security alg sip disable
commit

Linksys:
Check for a SIP ALG option in the Administration tab under 'Advanced'.
You should also disable the SPI Firewall option.
Mikrotik
Disable SIP Helper.
Netgear

Look for a 'SIP ALG' checkbox in 'WAN' settings.

Under 'NAT Filtering' uncheck the option 'SIP ALG'
Port Scan and DoS Protection should also be disabled.
Disable STUN in VoIP phone's settings.

openwrt
No ALG feature - Consider using a public STUN server
PfSense
https://www.voicehost.co.uk/help/pfsense-voip-configuration
SonicWALL Firewall
Under the VoIP tab, the option 'Enable Consistent NAT' should be enabled and 'Enable SIP Transformations' unchecked.
Detailed instructions can be found here: https://www.voicehost.co.uk/help/sonicwall-configuration
Speedtouch

To disable SIP ALG you need to telnet into your Speedtouch router and type the following:

-> connection unbind application=SIP port=5060
-> saveall

TalkTalk

2017/18 See Huawei (HG633)

  1. Navigate to the web interface
  2. Select 'Port Forwarding' from the menu
  3. Uncheck SIP-ALG from the ALG section at the bottom of the page.
Technicolor / Thompson
TG588 TG589 TG582 DWA0120
Open Command Prompt – “Start” → “Run” → type “cmd” and press “Enter”.
In Command Prompt, type “telnet 192.168.1.254” and press enter. 192.168.1.254 is the default IP address of the router. If you are running on Windows 7/8/8.1/10, you might need to install the telnet client from “Control Panel” → “Programs and Features” → “Turn Windows features on and off”.
The default username is “Administrator”, and there is no default password, leave blank.
Type “connection unbind application=SIP port=5060” and press “Enter”.
Type “ saveall ” and press “Enter”.
Type “exit” and press “Enter” to exit the telnet session.
Tomato
Depending on the version of Tomato, SIP ALG can be found under Advanced then Conntrack/Netfilter in the Tracking/NAT Helpers section. If you find SIP checked then SIP ALG is enabled. Uncheck it to disable it.
TP-Link
Navigate to your routers web interface.
The default username is admin and the default password is admin.
On the left, click on Advanced Setup and then click on NAT and then click on ALG.
Uncheck the box by SIP Enabled. (Some TP firmware shows this as SIP Transformations which is the same thing).
Click Save/Apply.
UBEE Gateways
Go to Advanced > Options.
Disable (uncheck) SIP.
Disable (uncheck) RTSP.
Click Apply.
Ubiquiti

Use the configuration tree if supported: system -> conntrack -> modules -> sip -> disable

Alternatively, you can SSH into the device and run the following commands:

configure
set system conntrack modules sip disable
commit
save
exit

Virgin SuperHub
SIP ALG cannot be disabled in the settings of SuperHubs.
Please see our workarounds at the top of the page.
Vodafone
2018 Onwards - See Huawei (HHG2500)
Vyatta / Brocade:

Type the following into the CLI

configure
set system conntrack modules sip disable
commit
save
exit

Watchguard Firewall
Detailed instructions can be found here: https://www.voicehost.co.uk/help/watchguard-firewall-sip-configuration
ZyXEL

Under Network or Advanced -> ALG un-tick the options Enable SIP ALG and Enable SIP Transformations.
Telnet commands must be used to disable SIP ALG with some other Zyxel routers.

  1. Telnet into the router.
  2. Select menu items 24 then 8.
  3. To display the current SIP ALG status run the following command:
  4. ip nat service sip active
  5. To turn off SIP ALG:
  6. ip nat service sip active 0
ZyXEL (ZyWALL USG Routers)
Go to Settings > Configuration > Network > ALG.
Disable SIP ALG.
Turn ON Enable SIP Transformations.
Turn OFF Enable Configure SIP Inactivity Timeout.

Broadband Network General Settings

Broadband - General configuration settings for the VoiceHost Broadband Network
 ADSL2+ SoADSLFTTC SoGEA & G.FastFTTP
Line typeAnnex A + M: Analogue/Raw Copper (PSTN)VDSL2: Analogue/Raw Copper (PSTN)Full Fibre
EncapsulationPPPoAPPPoEPPPoE
MultiplexingVC-Mux
IPv4Static x 1 included (see below if >1 required)
IPv6/64 Enabled by default
ATMVPI: 0
VCI: 38
N/AN/A
VLANN/A101 for routers with built-in VDSL2 modemsN/A
MTU1492
AuthenticationVOICEHOST PROVIDED
DNS - Domain Name Servers
 NameIPv4 addressIPv6 address
PrimaryVoiceHost (Private)xx.xxx.xx.xxxxxxx:xx:xxx:xxxx
SecondaryVoiceHost (Private)xx.xxx.xx.xxxxxxx:xx:xxx:xxxx
PrimaryCloudflare (Public)1.1.1.12606:4700:4700::1111
SecondaryCloudflare (Public)1.0.0.12606:4700:4700::1001
PrimaryGoogle DNS (Public)8.8.8.82001:4860:4860::8888
SecondaryGoogle DNS (Public)8.8.4.42001:4860:4860::8844
Unmanaged SMTP relay for sending Email:

Relay SMTP access is granted only for email sent using VoiceHost internet connections and does not require a username or password, this is an unmanaged service and faults regarding email failure are not supported.

The relay domain addresses are:

  • relay.ukdsl.co
  • relay.voicehostdsl.com
  • relay.newbreedbb.co.uk
Speed Test Servers

Speedtest tools calculate a snapshot of the connection speed to our network AS31472:

  • Download - The maximum currently available bandwidth downstream
  • Upload - The maximum currently available bandwidth upstream
  • Ping - <150 ms is preferred for QoS
  • Jitter - <30 ms is preferred for QoS

You should ensure that no other devices are using the connection during the test and you are connected directly into the primary router.

Reverse DNS and SPF:

Reverse DNS is IP address to domain name mapping - the opposite of forward (normal) DNS which maps domain names to IP addresses. Please contact support if you require reverse DNS as you may require this in order to send emails and have them accepted by other networks.

Sender Policy Framework (SPF) is an email validation system designed to prevent email spam by detecting email spoofing, a common vulnerability, by verifying sender IP addresses. If your domain does not have an SPF record, you will also need to add this as some recipient domains may reject messages from your users because they cannot validate that the messages come from an authorised mail server.

Additional IPv4 addressing and IPv6:

Subject to approval based on RIPE guidelines and RFC2050 (Section 2.1), VoiceHost can offer additional static IPv4 subnets to its broadband customers on all products.
Please contact support for further details.

IPv6 is disabled by default but can be enable IPv6 via your account control panel.