Page tree
Skip to end of metadata
Go to start of metadata



If you are going to route traffic across your network, you need to ensure that you do not have a firewall blocking traffic on the specified network paths. Commonly firewalls are installed at egress points, where your local network connects to the internet. You may also run a firewall on the server itself. This is not always the case in some corporate environments. If you are not responsible for your network, you may wish to contact the group or individuals who are responsible for it.

Information they may need to enable traffic would include the port numbers. Various protocols use different ports for different things. Some you need bi-directional connectivity, some you only need outbound. Depending on your call scenario you may only need to allow connections that are initiated by your system. If you have any problems with protocols not working, it is recommended that you disable your firewall to the FreeSWITCH™ system, place a test call, and see if the problem persists. A misconfigured firewall is responsible for many common problems.

Typical Ports

FireWall PortsNetwork ProtocolApplication ProtocolDescription
1719UDPH.323 Gatekeeper RAS port
1720TCPH.323 Call Signaling
3478UDPSTUN serviceUsed for NAT traversal
3479UDPSTUN serviceUsed for NAT traversal
5002TCPMLP protocol server
5003UDPNeighborhood service
5060UDP & TCPSIP UASUsed for SIP signaling (Standard SIP Port, for default Internal Profile)
5070UDP & TCPSIP UASUsed for SIP signaling (For default "NAT" Profile)
5080UDP & TCPSIP UASUsed for SIP signaling (For default "External" Profile)
8021TCPESLUsed for mod_event_socket *
16384-32768UDPRTP/ RTCP multimedia streamingUsed for audio/video data in SIP and other protocols
5066TCPWebsocketUsed for WebRTC
7443TCPWebsocketUsed for WebRTC



Think carefully about opening the ESL port to the external world and change the default password. ESL allows any system commands to be run or even to crash FreeSWITCH for call recovery testing. Allowing public access is therefore a security risk.


Note that the ports may vary depending on which modules you have loaded and their configuration, for instance you may have more or fewer SIP profiles, and you may have changed many of the above ports including SIP,RTP,ESL etc.

Linux netfilter iptables




You must add the interface and port numbers for each sip_profile used in your FreeSWITCH installation.


The nf_conntrack_sip and nf_conntrack_h323 modules will watch unencrypted SIP/H323 and automatically open the firewall ports required for RTP if you are accepting packets with the RELATED state. SIP and H323 packets after the first packet will be in the ESTABLISHED state. If you allow any RELATED,ESTABLISHED packets before processing new/unknown packets, then your firewall will accept subsequent packets much sooner, resulting in lower CPU usage and latency.

This may only apply to packets on the standard ports (UDP/5060, TCP/5060, TCP/1720) as it requires that the firewall recognizes the SIP/H323 protocol the packets are using.

This is of course not possible for encrypted connections, as the firewall cannot look inside the VoIP packets to get the RTP IPs and ports. With the imperative of encrypted communications, these steps are necessary to allow traffic through the firewall.

Module options

You may need to adjust the following options in some configurations, e.g. setting sip_direct_media=0 for bypass media (either done by FreeSWITCH's bypass_media or by a gateway).

nf_conntrack_sipsip_direct_signallingExpect incoming calls from registrar only*0/11
nf_conntrack_sipsip_direct_mediaExpect Media streams between signalling endpoints only0/11
nf_conntrack_sipsip_timeoutTimeout for the master SIP sessionInteger3600
nf_conntrack_sipportsPort numbers of SIP servers*List of up to 8 port numbers (comma-separated) eg. 5060,5070,50805060
nf_conntrack_h323default_rrq_ttlUse this TTL if it's missing in RRQInteger300
nf_conntrack_h323gkrouted_onlyOnly accept calls from gatekeeperInteger1
nf_conntrack_h323callforward_filterOnly create call forwarding expectations if both endpoints are on different sides (determined by routing information)Integer1

Module options are given when loading the module, e.g. "modprobe nf_conntrack_sip ports=5060,5080" to use a non-default setting. Modules will need to be unloaded and reloaded to change their options.

The two most commonly used options are "ports" and "sip_direct_media".

You can check the current module parameter values by viewing the special files in /sys/module/nf_conntrack_sip/parameters/


If your distribution supports /etc/modules.conf:


open /etc/modules.conf in an editor

add the line:

options nf_conntrack_sip [options]

If your distribution supports /etc/modprobe.d/:


Create a file 50-nf_conntrack_sip.conf and open it in an editor

add the line:

options nf_conntrack_sip [options]

If your module is loaded using modprobe (eg. in rc.local):

modprobe nf_conntrack_sip [options] 


sip_direct_signalling=1 and gkrouted_only=1 will still allow all incoming calls if you have a rule such as "-p udp --dport 5060 -j ACCEPT" for the protocol, since you are explicitly allowing signaling instead of relying on the module.

Default values are taken from linux-source-2.6.26 on Debian 2010/02/26, and may vary in later versions.

Side effects

Invalid SIP packets may be silently dropped by iptables even if all packets are allowed (e.g. if they have no CSeq header). This should not be an issue for FreeSWITCH, since it only sends valid SIP packets.


This is a basic firewall setup using just IPTABLES on Debian Squeeze.

Back up your current iptables rules

iptables-save > ~/iptables.up.rules.vanilla

Create new rules

Example iptables rules  Expand source

Turn on the rules

iptables-restore < ~/iptables.fs.rules

The rules are now turned on. Test and make changes to your firewall as necessary.

Save the final rules

Once you are happy with your rules, save them.

iptables-save > /etc/iptables.up.rules

Load rules on boot