Asterisco ⟷ FreeSWITCH
É claro que suas necessidades podem ser diferentes, mas é um bom começo - tenho alguns servidores com uma conexão privada e talvez seja necessário adaptar as medidas de autenticação, mas isso deve ilustrar os fundamentos da comunicação de um lado para outro contexto, etc.
Asterisco
pjsip.conf
[tel]
type=transport
protocol=udp
bind=10.8.0.2 # set asterisk's IP -- bind to this address
[acl]
type=acl
deny=0.0.0.0/0
permit=10.8.0.3/32 # allow only calls from freeswitch who is on 10.8.0.3 see above deny
[fs]
type=identify
endpoint=fs
match=10.8.0.3 # identify/auth traffic from freeswitch by its IP
[fs]
type=endpoint # set options for endpoint we identified just above
trust_id_inbound=yes
trust_id_outbound=yes
aors=fs
context=from-internal ## WHERE DO CALLS FROM FREESWITCH TO ASTERISK GO?
allow=!all,g722,ulaw
transport=tel
[fs]
type=aor
contact=sip:10.8.0.3 # address-of-record to find freeswitch so can dial to fs without it registering with us (this is fed up to [fs] type=endpoint via its aors above so calls to Dial(PJSIP/1234@fs) dials 1234 on FreeSWITCH 10.8.0.3)
extensions.conf
[from-internal]
include = toFreeSWITCH
[toFreeSWITCH]
exten = _N11!,1,Dial(PJSIP/${EXTEN}@fs)
exten = _0!,1,Dial(PJSIP/${EXTEN}@fs)
exten = _3XX,1,Dial(PJSIP/${EXTEN}@fs)
exten = _1NXXNXXXXXX,1,Dial(PJSIP/${EXTEN}@fs)
exten = _508NXXXXXX,1,Dial(PJSIP/${EXTEN}@fs)
exten = _774NXXXXXX,1,Dial(PJSIP/${EXTEN}@fs)
FreeSWITCH
conf / autoload_configs / acl.conf.xml
adicione isso dentro de <network-lists>
:
<list name="asterisk" default="deny">
<node type="allow" cidr="10.8.0.2/32"/>
</list>
conf / sip_profiles / asterisk.xml
<profile name="asterisk">
<gateways>
<gateway name="asterisk">
<param name="username" value="freeswitch"/>
<param name="realm" value="your-asterisk-domain"/>
<param name="password" value="unused-but-required-field"/>
<param name="from-domain" value="your-asterisk-domain"/>
<param name="proxy" value="10.8.0.2"/><!-- ASTERISK ADDRESS -->
<param name="register" value="false"/><!-- INSTEAD WE SET AOR IN PJSIP.CONF -->
<param name="cid-type" value="pid"/>
<param name="rfc-5626" value="true"/>
</gateway>
</gateways>
<settings>
<param name="apply-inbound-acl" value="asterisk"/>
<param name="auth-calls" value="false"/>
<param name="context" value="public"/><!-- WHERE DO CALLS FROM ASTERISK COME INTO? -->
<param name="rtp-ip" value="10.8.0.3"/><!-- this FreeSWITCH MEDIA IP -->
<param name="sip-ip" value="10.8.0.3"/><!-- this FreeSWITCH SIP IP -->
</settings>
</profile>
dialplan.xml
adaptar e adicionar dentro de um plano de discagem :
<extension name="to-asterisk">
<condition field="destination_number" expression="^([2-9]11|1?[2-9]\d{2}[2-9]\d{6}|3\d{2})$">
<action application="set" data="dialed_extension=$1"/>
<action application="export" data="dialed_extension=$1"/>
<action application="set" data="call_timeout=30"/>
<action application="set" data="hangup_after_bridge=true"/>
<action application="set" data="continue_on_fail=true"/>
<action application="export" data="rtp_secure_media=false"/>
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>