Changes

Jump to: navigation, search

VoIP Firewall

1,793 bytes added, 21 January
Explain the options when using NAT, as ALGs are notoriously error prone
[[File:Snom710.png|link=:Category:VoIP|Go to the VoIP Category]]
 
Allowing appropriate SIP and RTP packets through a firewall is the key to reliable VoIP communication. It may be possible to achieve reliability using SIP Keep-Alive packets (every 120 seconds or so) and relying on phones using UDP hole punching for the audio channel, but firewall rules are more certain to work.
 
This is what we suggest firewall-wise for VoIP customers:
 
Avoid using NAT where possible. HoweverIf using NAT, somethe options are to tell the phone what its public IP address is (either by explicit configuration, or by specifying a STUN server to use - e.g. ''stun.aa.net.uk''), or to use a SIP Application Layer Gateway to rewrite SIP packets on the fly. Some NAT gateways provide an adequate SIP ALG (e.g. Technicolor TG582), and some devices provide NAT that works with the new call server (e.g. FireBrick FB2700 and many simple NAT routers). If NAT works, then well done, but if not we cannot guarantee to be able to make it work.
 
{| class="wikitable"
|}
 
Customers should add all IPs above to their firewall rules even if you don't see traffic from or to them. This is a fairly large number of addresses but it means we can expand our platform over time as well as accommodate hosting our equipment in diverse datacentres.
 
'''SIP''' is the call routing information that creates and manages calls. If incoming SIP packets are blocked, incoming calls will fail. In practice if you allow port 5060 from the outside world you'll see attacks and possibly receive spam phone calls. We do not recommend leaving 5060 open unless you really know what you are doing. Phones rarely use ports as low as 5060 for media.
 
'''RTP''' is the actual media (e.g., the audio). On our platform the RTP will come from the same call server IP address as the SIP control messages. On most phones you can configure which ports to uselisten on for RTP, so you can restrict this range further. Note that RTP actually uses 2 consecutive port numbers, you should specify an even number and RTP will also use that port number +1. For example, on a Snom Phone the default range for inbound RTP is 49152 to 65534, so the firewall needs to allow the destination port number range 49152 to 65535. As another example, Grandstream phones and ATAs tend to default to usinglisten on 5004 as the RTP port, so you need to allow destination ports 5004-5005 through the firewall.
 
On routers which need one rule per IP address range you can halve the number of firewall rules needed as long as the source IP address ranges for SIP and RTP are the same and that the RTP port range you specify includes 5060.
 
=Example consumer router config=
The following example is for an AAISP-supplied ZyXEL router. It assumes you have locked down the destination RTP port range on clients to ports 5000-5098. Because the Custom Destination Port range covers port 5060 we get away with half the rules - 6, rather than 12!
{| class="wikitable"
!colspan="7"|Firewall Rules on the AAISP VoIP Platform
 
=NAT=
Avoid using NAT where possible. However, some NAT gateways provide an adequate SIP ALG (e.g. Technicolor TG582), and some devices provide NAT that works with the new call server (e.g. FireBrick 2500/2700 and many simple NAT routers). Using a STUN server (e.g. ''stun.aa.net.uk''} is another possible solution. If NAT works, then well done, but if not we cannot guarantee to be able to make it work. See: [[VoIP NAT]]
 
If you have 2 phones behind a NAT router, they cannot have the same SIP port number, nor the same RTP port range (if they both used port number for SIP of 5060 then when an incoming call came in to external port 5060, NAT wouldn't know which phone to send it to).
 
As an example with 2 phones, the first phone uses inbound SIP port 5060 and incoming RTP ports 5062-5068, and the second phone uses inbound SIP port 5040 and incoming RTP ports 5042-5048. Using iptables, the required rules would be like:
 
/sbin/iptables -t nat -A PREROUTING -i eth0 -m udp -p udp -s 81.187.30.0/24 --dport 5060:5069 -j DNAT --to-destination 192.168.1.12
/sbin/iptables -t nat -A PREROUTING -i eth0 -m udp -p udp -s 81.187.30.0/24 --dport 5040:5049 -j DNAT --to-destination 192.168.1.13
 
See: [[VoIP NAT]]
 
=Further VoIP Security=
379
edits

Navigation menu