freeswitch的ACL规则

 

 

概述

freeswitch是一款好用的VOIP开源软交换平台。

VOIP公共网络中的安全问题是最重要的问题,我们必须对网络端口的访问权限做出限制。

ACL全称Access Control List,意为访问控制列表,是一个权限(或规则)列表,列表定义了允许哪些网络实体访问目标对象。

环境

centos:CentOS  release 7.0 (Final)或以上版本

freeswitch:v1.8.7

GCC:4.8.5

acl规则配置

acl规则的配置文件${conf_dir}/autoload_configs/acl.conf.xml,默认配置如下。

<configuration name="acl.conf" description="Network Lists">

  <network-lists>

    <!--     These ACLs are automatically created on startup.

     rfc1918.auto  - RFC1918 Space

     nat.auto      - RFC1918 Excluding your local lan.

     localnet.auto - ACL for your local lan.

     loopback.auto - ACL for your local lan.    -->

 

    <list name="lan" default="allow">

      <node type="deny" cidr="192.168.42.0/24"/>

      <node type="allow" cidr="192.168.42.42/32"/>

    </list>

 

    <!--    This will traverse the directory adding all users

    with the cidr= tag to this ACL, when this ACL matches

    the users variables and params apply as if they

    digest authenticated.    -->

    <list name="domains" default="deny">

      <!-- domain= is special it scans the domain from the directory to build the ACL -->

      <node type="allow" domain="$${domain}"/>

      <!-- use cidr= if you wish to allow ip ranges to this domains acl. -->

      <!-- <node type="allow" cidr="192.168.0.0/24"/> -->

    </list>

 

  </network-lists>

</configuration>

allow表示允许,deny表示拒绝。

acl.conf.xml文件中配置的list名称,可以用于呼叫中的acl鉴权。

该文件有修改时,可以使用命令刷新内存中的acl规则。

reloadacl reloadxml

但是该命令不会刷新新增的acl列表,新增acl列表需要重启fs才能生效。

预设acl规则

fs内置的acl预设规则项(Pre-defined ACLs)。

预设的acl规则项包括如下,可以当作内置变量直接使用。

rfc1918.auto         RFC 1918 Space

nat.auto               RFC 1918, excluding your local LAN

localnet.auto        ACL for your local LAN

loopback.auto      ACL for your local LAN

wan.auto              公网地址

sip配置项

fs支持的sip配置项主要在sip_profile下的配置文件中使用,作用于该端口的所有呼叫控制acl。

apply-inbound-acl,呼入acl规则。

apply-register-acl,注册acl规则。

apply-proxy-acl,代理acl规则。

apply-candidate-acl,webrtc的ice框架下可选媒体地址acl规则。

auth-calls,账户鉴权acl规则,包括inbound和register。

示例如下。

配置conf/sip_profile/external.xml如下,则从5080端口呼入的呼叫来源IP都要符合“inbound-acl”规则。

<param name="apply-inbound-acl" value="inbound-acl"/>

配置conf/sip_profile/internal.xml如下,则从5060端口注册的消息来源IP都要符合“register-acl”规则。

<param name="apply-register-acl" value="register-acl"/>

配置conf/directory/default/10011.xml如下,则10011账户的注册/呼叫消息来源IP都要符合“auth-calls-acl”规则。

<param name="auth-acl" value="auth-calls-acl"/>

呼叫acl配置示例

如果我们希望对呼叫进行acl控制,有俩种常用方案。

方案一,配置conf/sip_profile/external.xml如下,则5080端口呼入的呼叫来源IP都要符合“inbound-acl-001”规则。

<param name="apply-inbound-acl" value="inbound-acl-001"/>

方案二,配置conf/dialplan/test001.xml如下,则所有进入拨号计划“foo-hosts-calls”的呼叫来源IP都要符合“list_foo”规则。

<extension name="foo-hosts-calls">

  <condition field="${acl(${network_addr} list_foo)}" expression="true"/>

  <condition field="destination_number" expression="(.*)">

    <action application="bridge" data="sofia/switchbox/$1@myapp.signalwire.com:5060"/>

  </condition>

</extension>

配置“${acl(${network_addr} list_foo)}”中的acl为fs的app接口,acl接口的作用是测试ip是否符合“list_foo”规则。

总结

对于公共网络中的VOIP服务,不管如何强调安全性都不为过,linux服务器本身的防护墙和fs服务的acl规则都要正确配置,尽可能的预防和减少sip扫描的威胁。

 

空空如常

求真得真

posted @ 2022-10-13 11:59  求真得真  阅读(1040)  评论(0编辑  收藏  举报