Q: 外線 SIP Trunk 撥入後進入 Follow Me 轉到外部的手機號碼,手機接起會沒有聽到聲音
A: 如果 Asterisk 放在 LAN 端,先檢查 sip_nat.conf 的外部 IP 是否正確,確認沒問題,問題一樣發生時,步驟如下:
FreePBX > Tools > Asterisk SIP Settings
在最後一行加上
progressinband = yes
Q: 如何避免 CDR 檔案 Master.csv 持續增大
A:可以使用 logrotate 服務或者使用以下 SHELL
asterisk-cdr-rollover.sh:
reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)Callstack:
at User:alang/Private_Zone/Asterisk_進階安裝篇/Asterisk_Q&A
MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException: reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown.
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptVar expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptVar.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Evaluate (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state, Boolean evaluateProperties) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptAccess.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptCall expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptCall.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptSequence expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptSequence.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptReturnScope expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
Q: 設定 sendmail
A:註: 此法尚未有實作
Edit /etc/aliases file and add a “root: username_to_forward_to” to forward all ‘root’ messages to your personal email address. Put in the full email address if it is not on the asterisk system itself.
Then run
/usr/bin/newaliases
to restart the service.
If emails are not received you must set up masquerading in sendmail. These still may be rejected if the email server requires the source of the email to also resolve to the same DNS that sendmail is masquerading as.
To enable this, add the following lines to the /etc/mail/sendmail.mc file:
MASQUERADE_AS(domain.com)dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(domain.com)dnl
Put a “dnl” in front of the line ”EXPOSED_USER (`root’) dnl”. This enables host masquerading for root as well which is disabled by default.
Update the Sendmail configuration files using the m4 macro processor to generate a new sendmail.cf file by executing the following command:
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
To get the Sendmail macro file, the sendmail-cf package must be installed on the system.
After creating a new /etc/mail/sendmail.cf file, restart Sendmail for the changes to take effect. To do this, use the following command:
# service sendmail restart
# nano /etc/asterisk/vm_general.inc
change serveremail=vm@asterisk to whom ever you want it to appear voicemail emails are coming from.
NOTE: If you are installing on a LAN or do not have a domain resolving to the IP of the VPS, Sendmail will hang for a couple minutes everytime you reboot. To prevent this your VPS hostname should end with .local or .localhost. So, for example, instead of naming the VPS hostname 'powerpbx' it should be named 'powerpbx.local'. The manual method is to edit your /etc/hosts file. There should be 2 lines.
127.0.0.1 localhost.localdomain localhost
yourIPaddress yourhostname.local yourhostname yourhostname
Q: 如何設定 logrotate
A:編輯 /etc/logrotate.d/asterisk
/var/log/asterisk/messages /var/log/asterisk/*log /var/log/asterisk/full {
missingok
notifempty
sharedscripts
create 0640 asterisk asterisk
postrotate
/usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
endscript
}
Q: 外線撥入後約 15 sec 會自動掛斷,且出現錯誤訊息:
[2012-02-29 16:41:42] WARNING[2713] chan_sip.c: Maximum retries exceeded on transmission 3c417d294417b1ff2139128123697520@sip2sip.info for seqno 103 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
[2012-02-29 16:41:42] WARNING[2713] chan_sip.c: Hanging up call 3c417d294417b1ff2139128123697520@sip2sip.info - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions ).
A: 這問題通常發生在 Asterisk 主機放在 NAT 網路環境,請依序檢查這幾項:
- 檢查 sip.conf 的 externip, localnet 是否正確,以及 firewall 啟用 5060(UDP), 10000-20000(UDP) 的 port forwarding。
- 檢查 canreinvite=no
- Asterisk 執行重新開機
- 更換其他的 firewall,pfsense 2.0.1 已確認有此問題,請參閱此篇討論,或執行下述步驟即可獲解決。
- Firewall > NAT > Port Forward 新增 5060(UDP) 與 10000-20000(UDP) 的 port forward 規則。
- Firewall > NAT > Outbound,選擇 Manual Outbound NAT rule generation (AON) 模式,並且新增規則:
- Interface = WAN
- Source = <Asterisk's IP>/32 ; netmask 為 32 表示為 single IP
- Source Port = any
- Destination = any
- Destination Port = any
- NAT address = any
- NAT Port = any
- Static Port = yes ;重要
- NOTE:
- 模式 Auto NAT 切換到 Static NAT 後,系統會自動新增 3 個 rule,這不可刪除,否則 LAN 上網會有問題。
- Static NAT Rule for Asterisk 必須在上方,否則無法被優先套用。
- pfsense 套用新設定後,Asterisk 需要重啟機器。
- 如果撥入時是透過 SIP Provider,與 SIP Provider 端可能也會有關系,例如 CCNet 就會發生這問題,但換成 sip2sip.info 後就不會。
- 其他非 pfsense 的 Firewall,設定時需要注意 Automatic NAT & Static NAT 的項目,此問題通常發生在 automatic NAT 模式下。