You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Asterisk+FreePBX禁止员工将通话转接至手机号的方案咨询

Got it, let's sort this out for you. You need to stop employees from transferring incoming calls to mobile numbers, but still let them dial mobiles directly — that’s a common requirement, and totally doable with FreePBX + Asterisk. Here are three solid methods to make this work:

Method 1: Custom Dialplan via FreePBX Custom Contexts

This is a flexible approach that lets you fine-tune exactly what gets blocked during transfers:

  • Head to FreePBX → Admin → Custom Contexts and create a new context (name it something like restrict-transfer-to-mobile).
  • Paste this dialplan code into the context (adjust the number patterns to match your region's mobile prefixes — example uses Chinese mobile numbers):
    exten => _1[358]XXXXXXXXX,1,GotoIf($["${TRANSFERER}"!=""]?block:allow)
    exten => _1[358]XXXXXXXXX,n(block),Playback(privacy-you-are-not-authorized)&Hangup()
    exten => _1[358]XXXXXXXXX,n(allow),Dial(SIP/${EXTEN},20)
    
    # Add rules for numbers with country code too
    exten => _+861[358]XXXXXXXXX,1,GotoIf($["${TRANSFERER}"!=""]?block:allow)
    exten => _+861[358]XXXXXXXXX,n(block),Playback(privacy-you-are-not-authorized)&Hangup()
    exten => _+861[358]XXXXXXXXX,n(allow),Dial(SIP/${EXTEN},20)
    
    The TRANSFERER variable checks if the call is being transferred by a user — if yes, it blocks the mobile number; if it's a direct dial, it proceeds normally.
  • Assign this context to your employees' extensions: Go to FreePBX → Applications → Extensions, edit the target extension, switch to the Advanced tab, and set the Context to your new custom context (or add it to Include Contexts if you want to keep existing rules).
  • Reload FreePBX config with fwconsole reload and test.
Method 2: Use FreePBX's Context Restrictions Module

If you prefer a GUI-based approach without editing code, the Context Restrictions module is perfect:

  • First, install the module: Go to FreePBX → Admin → Module Admin, search for "Context Restrictions", install it, and enable it.
  • Create a restriction rule: Navigate to Applications → Context Restrictions → Add Rule
    • Name it something clear like "Block Transfer to Mobile"
    • Set Restriction Type to "Transfer"
    • Add your mobile number patterns under Dial Patterns (e.g., _1[358]XXXXXXXXX, _+861[358]XXXXXXXXX)
    • Set Action to "Block" and pick a warning prompt (like "privacy-you-are-not-authorized")
  • Assign the rule to your employees: Go to Applications → Context Restrictions → Assign Rules, select the extensions you want to restrict, and link them to your new rule.
  • Apply the config and test the transfer functionality.
Method 3: Direct Asterisk Config Edit (For Advanced Users)

If you're comfortable editing Asterisk files directly, modify extensions_custom.conf (never edit core files like extensions.conf directly — FreePBX will overwrite them):

  • Open the file with your favorite editor: nano /etc/asterisk/extensions_custom.conf
  • Add this code to the [from-internal-custom] section (adjust number patterns as needed):
    [from-internal-custom]
    exten => _1[358]XXXXXXXXX,1,GotoIf($["${TRANSFERER}"!=""]?10:20)
    exten => _1[358]XXXXXXXXX,10,Playback(privacy-you-are-not-authorized)
    exten => _1[358]XXXXXXXXX,11,Hangup()
    exten => _1[358]XXXXXXXXX,20,Dial(SIP/${EXTEN},20)
    
    # Add country code variant
    exten => _+861[358]XXXXXXXXX,1,GotoIf($["${TRANSFERER}"!=""]?10:20)
    exten => _+861[358]XXXXXXXXX,10,Playback(privacy-you-are-not-authorized)
    exten => _+861[358]XXXXXXXXX,11,Hangup()
    exten => _+861[358]XXXXXXXXX,20,Dial(SIP/${EXTEN},20)
    
  • Save the file and restart Asterisk: fwconsole restart

Quick Tips

  • Always test both scenarios: Try transferring an incoming call to a mobile (should be blocked) and dialing a mobile directly (should work).
  • Adjust the number patterns to match your region's mobile formats — for example, US numbers would use _1[2-9]XX[2-9]XXXXXX.
  • If you need to block international mobiles, add patterns for those country codes too.

内容的提问来源于stack exchange,提问作者okamigo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:00:45