Asterisk 服务器防火墙脚本允许来电的双向音频,但不允许拨出的音频?

Asterisk 服务器防火墙脚本允许来电的双向音频,但不允许拨出的音频?

我在直接连接到互联网的虚拟机上运行 Asterisk PBX,我真的想阻止脚本小子、l33t h4x0rz 和真正的黑客访问我的服务器。我现在保护通话账单的基本方法是使用 32 个字符的密码,但我更希望有一种方法来保护

我当前使用的防火墙脚本如下所示,但是,如果没有建立连接防火墙规则(提到的规则#1),我就无法在拨出电话时接收来自目标的传入音频:

#!/bin/bash

# first, clean up!
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD DROP # we're not a router
iptables -P OUTPUT ACCEPT

# don't allow invalid connections
iptables -A INPUT -m state --state INVALID -j DROP

# always allow connections that are already set up (MENTIONED RULE #1)
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# always accept ICMP
iptables -A INPUT -p icmp -j ACCEPT

# always accept traffic on these ports
#iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT

# always allow DNS traffic
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT

# allow return traffic to the PBX
iptables -A INPUT -p udp -m udp --dport 50000:65536 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT
iptables -A INPUT -p udp --destination-port 5060:5061 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 5060:5061 -j ACCEPT
iptables -A INPUT -m multiport -p udp --dports 10000:20000
iptables -A INPUT -m multiport -p tcp --dports 10000:20000

# IP addresses of the office
iptables -A INPUT -s 95.XXX.XXX.XXX/32 -j ACCEPT

# accept everything from the trunk IP's
iptables -A INPUT -s 195.XXX.XXX.XXX/32 -j ACCEPT
iptables -A INPUT -s 195.XXX.XXX.XXX/32 -j ACCEPT

# accept everything on localhost
iptables -A INPUT -i lo -j ACCEPT

# accept all outgoing traffic
iptables -A OUTPUT -j ACCEPT

# DROP everything else
#iptables -A INPUT -j DROP

我想知道我缺少什么防火墙规则才能使这一切正常工作。关于星号实际上需要哪些端口(传入和传出)的文档太少了。(包括返回端口)。

这里有没有防火墙/iptables 专家发现这个防火墙脚本存在重大问题?

令人沮丧的是,我找不到一个简单的防火墙解决方案,使我能够在互联网上的某个地方运行 PBX,该 PBX 的防火墙只能允许来自和到办公室、DNS 服务器和中继的连接(并且仅支持外部世界的 SSH(端口 22)和 ICMP 流量)。

希望通过这个问题,我们可以一劳永逸地解决这个问题。

答案1

有关于可用端口的完整文档。不清楚您为什么认为它不可用。

Asterisk 使用端口取决于所使用的技术/通道类型

对于 sip 协议,asterisk 使用 sip.conf 中描述的端口(默认 5060),对于 rtp 数据,使用 rtp.conf 中描述的端口(默认 10000-20000)。通常 sip 仅使用 udp 端口​​。TCP-sip 也可以使用 tcp 端口。

如果您在防火墙/NAT(非白色IP)后使用Aterisk,您还必须告知Aterisk有关外部IP地址的信息。有关更多信息,请参阅sip.conf.sample或互联网上的手册。

相关内容