客戶有一個 Asterisk PBX 系統,設定了一個 SIP Trunk 與營運商系統連接,營運商將傳送大量通話至 Asterisk 的 from-internal 後再經由另一個 SIP Trunk 撥出。現客戶想對這些進線的電話所撥出的目的號碼,利用 Blacklist 模組做阻擋的控制。
系統環境:
編輯 /etc/asterisk/extensions_custom.conf,新增這幾行
; Below are used for blocking DID with Blacklist ; [my-from-internal-block-did] exten => _X.,1,Set(DID_NUM=${EXTEN}) exten => _X.,n,GotoIf($["${DB_EXISTS(blacklist/${DID_NUM})}" = "1"]?blacklisted) exten => _X.,n,Noop(=== Passing the call to from-internal ===) exten => _X.,n,Goto(from-internal,${EXTEN},1) exten => _X.,n(blacklisted),Noop(=== The destination number ${DID_NUM} is blocked by Blacklist ===) exten => _X.,n,Hangup(42) ;42 is causecode, which will return 503 response code exten => h,1,Hangup
要套用這設定,只要修改 SIP Trunk 的
... context=my-from-internal-block-did ...
TIPs:
Hangup(42) 這行可以在執行掛斷後傳回 503 回應碼(Service Unavailable)