原作:Alang
本頁瀏覽人數:23247
本文參考
http://www.dd-wrt.com/phpBB2/viewtopic.php?t=43787
- Vendor:ASUS WL-520GU
- CPU:BCM5354 240 MHz
- RAM:16MB SDR 16bit
- FLASH:4MB
- USB:2.0 x1
- Official Firmware: 3.0.0.8
- 超迷你 USB Flash Drive 4GB 一個
軔體版本:DD-WRT V24-sp2 (10/10/09) mini-usb-ftp
IP PBX: Asterisk v1.4 and v1.6
GUI Asterisk-GUI 2.0 (svn-44045)
下載官方 www.dd-wrt.com 的 Firmware
下載路徑:Path: Downloads > stable > dd-wrt.v24 SP1 > Consumer > Asus > WL520GU > dd-wrt.v24_mini_asus.trx
下載 tft2.exe 工具
http://www.dd-wrt.com/dd-wrtv2/downl...TFTP/tftp2.exe
下載 ASUS 舊版本 2.0.0.8 firmware
http://support.asus.com/download/dow...Language=zh-tw
注意!
由於這次使用的機器是比較後期買的,原廠的 firmware 版本也較新,版號是 3.0.0.8,然而在這版本一直無法刷 DD-WRT 的 firmware,所以必須先將機器上的 ASUS firmware 從 3.0.0.8 降到 2.0.0.8,之後才能刷 third-party firmware。
變更原廠 firmware 直接使用 Web UI 的軔體更新即可。
確認 firmware 版本降至 2.0.0.8 後,繼續以下步驟。
1. 使機器進入 Firmware Restoration Mode
機器拔掉電源 > 按住背後的 reset 鈕 > 接上電源 > 約 3 秒鐘,電源燈號出現慢-閃狀態,放掉 reset 鈕 > 電源燈號持續出現慢-閃
2. 使用一部電腦,並將有線網路接上機器的任一個 LAN port,設定網卡 IP 位址為 192.168.1.10,網路遮罩 255.255.255.0
注意!
不要使用無線網路連接機器作以下的操作。
3. 執行 tftp2.exe,Server 輸入 192.168.1.1,Password 空白,File 選擇 dd-wrt.v24_mini_asus.trx 檔案位置,按下 Upgrade
若一切順利,約幾秒鐘後就完成軔體更新,
4. 機器的電源重開,電腦的網卡 IP 改為 DHCP,若一切順利,IP 會是 192.168.1.xx,開啟瀏覽器輸入 http://192.168.1.1,預設登入帳號 root; 密碼 admin。
注意!
若機器電源重開後,系統完全無法運作,且電源指示燈出現慢-閃狀態,請重複刷軔體的步驟。
參考連結:
ASUS WL-520GU Successful flash!
DD-WRT with USB on the WL-520gU
Asus WL-520GU
1. DD-WRT stable 版本並不支援 USB,所以為了要能掛上 USB drive,必須作軔體升級。
從官方下載可支援 USB 的升級軔體
下載路徑:downloads > others > eko > BrainSlayer-V24-preSP2 > 10-10-09-r13064 (選擇最新版) > broadcom > dd-wrt.v24_usb_generic.bin
升級方式很簡單,登入管理網頁,Administration > Firmware Upgrade > 選擇檔案 dd-wrt.v24_usb_generic.bin > Upgrade
注意!
升級軔體後,原來所作的設定及管理帳號密碼都會保留。
2. 在機器重新開機後,開啟 USB 支援功能
登入管理網頁 > Services > USB >
Core USB Support <Enable>
USB 2.0 Support <Enable>
USB Storage Support <Enable>
ext2/ext3 File System Support <Enable>
儲存並套用設定。
3. 格式化 USB drive
由於 DD-WRT 預設是不支援格式化指令 fdisk,所以必須用另一部 Linux 電腦來對 USB drive 作格式化。如果你沒有現成的 Linux 系統可用,可以下載 Ubuntu, Knoppix 等 Linux Live-CD 來用。
USB drive(4GB) 磁區規劃:
格式化指令用法:
#>mke2fs -j -m 1 -L Optware /dev/sd1 #>mke2fs -j -m 1 -L Shared /dev/sd3 #>mke2fs -j -m 1 -L Data /dev/sd4 #>mkswap /dev/sd2
格式化都完成後,就可以將 USB drive 從電腦上拔出,然後接在 ASUS 的機器後面的 USB port,接著繼續下面步驟。
4. 設定 DD-WRT 自動掛載 USB drive
再一次確認機器上得 USB Support 功能有開啟(第 2 項),當 USB drive 接入後,系統應該會自動偵測到,但不會自動掛載那些磁區。
如何檢查機器是否有偵測到 USB drive,登入機器的 SSH,然後執行指令
#>dmesg
...
...
ip_nat_pptp version 1.5 loaded
hub.c: new USB device 00:03.1-1, assigned address 3
Vendor: Ut165 Model: USB2FlashStorage Rev: 0.00
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sda: 7897088 512-byte hdwr sectors (4043 MB)
sda: Write Protect is off
/dev/scsi/host0/bus0/target0/lun0: p1 p2 p3 p4
USB device connected to the SCSI subsystem
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 3
ip_nat_pptp version 1.5 unloaded
ip_conntrack_pptp version 1.9 unloaded
ip_conntrack_pptp version 1.9 loaded
ip_nat_pptp version 1.5 loaded
註:黃底文字就是 USB drive 硬體訊息。
再一次確認 DD-WRT 的 USB drive 的各磁區
root@DD-WRT:~# ls -l /dev/scsi/host0/bus0/target0/lun0 brw------- 1 root root 8, 0 Jan 1 1970 disc brw------- 1 root root 8, 1 Jan 1 1970 part1 brw------- 1 root root 8, 2 Jan 1 1970 part2 brw------- 1 root root 8, 3 Jan 1 1970 part3 brw------- 1 root root 8, 4 Jan 1 1970 part4
註:part 1-4 就是對應 USB drive 的 4 個磁區。
手動掛載 USB drive 的磁區 1,3,4,第二個 SWAP 磁區暫不用掛載,後續會有啟用程序,執行
# mkdir /jffs/usb-disk
# mount /dev/scsi/host0/bus0/target0/lun0/part1 /opt
# mount /dev/scsi/host0/bus0/target0/lun0/part3 /jffs/usb-disk
# mount /dev/scsi/host0/bus0/target0/lun0/part4 /mnt/
# mount rootfs on / type rootfs (rw) /dev/root on / type squashfs (ro) none on /dev type devfs (rw) proc on /proc type proc (rw) ramfs on /tmp type ramfs (rw) devpts on /proc/bus/usb type usbfs (rw) /dev/mtdblock/4 on /jffs type jffs2 (rw) /dev/scsi/host0/bus0/target0/lun0/part1 on /opt type ext3 (rw) /dev/scsi/host0/bus0/target0/lun0/part3 on /jffs/usb-disk type ext3 (rw) /dev/scsi/host0/bus0/target0/lun0/part4 on /mnt type ext3 (rw)
設定以上磁區在機器重開機後會自動掛載,步驟是
登入管理網頁 > Administration > Commands,在文字框填入以下內容
sleep 10 && mount /dev/scsi/host0/bus0/target0/lun0/part1 /opt sleep 10 && mount /dev/scsi/host0/bus0/target0/lun0/part3 /jffs/usb-disk sleep 10 && mount /dev/scsi/host0/bus0/target0/lun0/part4 /mnt
按 Save Startup 儲存設定檔,然後重開機器,在以 SSH 登入,以 mount 指令檢查自動掛載 USB drive 是否正常。
# mount rootfs on / type rootfs (rw) /dev/root on / type squashfs (ro) none on /dev type devfs (rw) proc on /proc type proc (rw) ramfs on /tmp type ramfs (rw) devpts on /proc/bus/usb type usbfs (rw) /dev/mtdblock/4 on /jffs type jffs2 (rw) /dev/scsi/host0/bus0/target0/lun0/part1 on /opt type ext3 (rw) /dev/scsi/host0/bus0/target0/lun0/part3 on /jffs/usb-disk type ext3 (rw) /dev/scsi/host0/bus0/target0/lun0/part4 on /mnt type ext3 (rw)
這裡是線上安裝一些必要的指令集和函式庫
關於 Optware 更多資訊,參考 http://www.dd-wrt.com/wiki/index.php/Optware
1. 更新 ipkg 的套件庫資訊
#> ipkg update Downloading http://downloads.openwrt.org/whiterussian/packages/Packages ... Connecting to downloads.openwrt.org (78.24.191.177:80) Packages 100% |*********************************************************| 143k 00:00:00 ETA Done. Updated list of available packages in /jffs/usr/lib/ipkg/lists/whiterussian Downloading http://downloads.openwrt.org/whiterussian/packages/non-free/Packages ... Connecting to downloads.openwrt.org (78.24.191.177:80) Packages 100% |*********************************************************| 568 --:--:-- ETA Done. Updated list of available packages in /jffs/usr/lib/ipkg/lists/non-free Downloading http://downloads.openwrt.org/backports/rc5/Packages ... Connecting to downloads.openwrt.org (78.24.191.177:80) Packages 100% |*********************************************************| 98390 00:00:00 ETA Done. Updated list of available packages in /jffs/usr/lib/ipkg/lists/backports
2. 安裝 optware
# cd /tmp
# wget http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
# sh optware-install.sh Checking system config ... Using 10.1.1.254 as default gateway. Using the following nameserver(s): nameserver 192.168.1.1 Installing package uclibc-opt_0.9.28-13_mipsel.ipk ... Some newer versions of DD-WRT does not show download progress bar, so just be patient - or check STATUS -> BANDWIDTH tab for download activity in your routers Web-GUI, and then still wait a minute or two. Connecting to ipkg.nslu2-linux.org (140.211.169.169:80) uclibc-opt_0.9.28-13 100% |*********************************************************| 832k 00:00:00 ETA Updating /opt/etc/ld.so.cache Installing package ipkg-opt_0.99.163-10_mipsel.ipk ... ...
註:完成後,可以檢查 /opt 目錄多了一些目錄和指令集。
3. 安裝 busybox
# /opt/bin/ipkg-opt install busybox-base
# /opt/bin/ipkg-opt install busybox
# /opt/bin/ipkg-opt install busybox-links
確認 SWAP 磁區已經格式化正確格式,如果不確定,可以用這指令再做一次
# /opt/bin/busybox mkswap /dev/scsi/host0/bus0/target0/lun0/part2
啟用 SWAP 磁區,並用指令 free 檢查
# /opt/bin/busybox swapon /dev/scsi/host0/bus0/target0/lun0/part2
# free total used free shared buffers Mem: 13004 12560 444 0 3548 Swap: 127864 0 127864 Total: 140868 12560 128308
設定 DD-WRT 重開機後會自動啟用 SWAP,步驟
登入管理網頁 > Administration > Commands > Startup 編輯,接著內容的下方填入
sleep 10 && /opt/bin/busybox swapon /dev/scsi/host0/bus0/target0/lun0/part2
按 Save Startup 儲存,機器會自動重新開機,然後在以 SSH 登入,執行指令 free 驗證是否自動啟用了 SWAP。
Notes: 到這裡 DD-WRT 的系統環境算是已經完成了所有初始化的設定,接著以下步驟才是本篇的重點章節 - 安裝 Asterisk,看倌們!繼續再看下去。
安裝 Asterisk 主程式 1.4
# /opt/bin/ipkg-opt --tmp-dir /tmp install asterisk14
安裝 ulaw 語音檔
# /opt/bin/ipkg-opt --tmp-dir /tmp install asterisk14-moh-freeplay-ulaw
# /opt/bin/ipkg-opt --tmp-dir /tmp install asterisk14-core-sounds-en-ulaw
# /opt/bin/ipkg-opt --tmp-dir /tmp install asterisk14-extra-sounds-en-ulaw
注意!
在安裝 asterisk14-extra-sounds-en-ulaw 時,因為這個檔案比較大(約12.8MB),系統的暫存區 /tmp 可能不夠用,因此一直無法成功安裝,並且在 /tmp 被填滿後還會使機器自動重開機,這時可以將安裝的暫存目錄改到 USB drive 目錄可以用 /jffs/usb-disk/tmp。
# mkdir /jffs/usb-disk/tmp
# /opt/bin/ipkg-opt --tmp-dir /jffs/usb-disk/tmp install asterisk14-extra-sounds-en-ulaw
安裝完成。
註:若要安裝 Asterisk 1.6,請參考以下說明,否則跳過此。
// 若已經安裝 Asterisk-GUI,請先行移除 # /opt/bin/ipkg-opt remove asterisk-gui // 若已經安裝 Asterisk 1.4,請先執行移除 # /opt/etc/init.d/S50asterisk stop # /opt/bin/ipkg-opt remove -recursive asterisk14-extra-sounds-en-ulaw # /opt/bin/ipkg-opt remove -recursive asterisk14-core-sounds-en-ulaw # /opt/bin/ipkg-opt remove -recursive asterisk14-moh-freeplay-ulaw # /opt/bin/ipkg-opt remove -recursive asterisk14 # cd /opt/etc # rm -rf asterisk # cd /opt/var/lib # rm -rf asterisk # cd /opt/var/log # rm -rf asterisk # cd ~ # /opt/bin/ipkg-opt install asterisk16 # /opt/bin/ipkg-opt install asterisk-addons
由於 Asterisk 可以用哪些功能取決於載入的模組,預設環境會啟用所有模組,然而,機器的硬體資源有限,必須載入部份的基礎模組,而其餘都將它們關閉。
啟動或關閉模組,只要編輯 modules.conf 設定檔即可。
# vi /opt/etc/asterisk/modules.conf
; ; Asterisk configuration file ; ; Module Loader configuration file By Leif Madsen of www.leifmadsen.com ; Descriptions and some modules added by Bill Weidman [modules] autoload=no ; Resources — ;load => res_adsi.so ; ADSI Resource ;load => res_agi.so ; Asterisk Gateway Interface (AGI) ;load => res_config_mysql.so ; MySQL Configuration ;load => res_config_odbc.so ; ODBC Configuration ;load => res_crypto.so ; Cryptographic Digital Signatures load => res_features.so ; Call Parking Resource ;load => res_indications.so ; Indications Configuration ;load => res_monitor.so ; Call Monitoring Resource load => res_musiconhold.so ; Music On Hold Resource ;load => res_odbc.so ; ODBC Resource ; PBX — ;load => pbx_ael.so ; Asterisk Extension Language Compiler - Requires ? load => pbx_config.so ; Text Extension Configuration Requires N/A ;load => pbx_dundi.so ; Do a DUNDi lookup of a phone number. - Requires res_crypto.so ;load => pbx_functions.so ; Builtin dialplan functions - Requires N/A ;load => pbx_loopback.so ; Loopback Dialplan Switch - Requires N/A ;load => pbx_realtime.so ; Realtime Dialplan Switch - Requires N/A ;load => pbx_spool.so ; Outgoing Spool Support Requires - N/A ; Functions — load => func_callerid.so ; Gets or sets Caller*ID data on the channel. - Requires ? ;load => func_enum.s ; ENUMLOOKUP and TXTCIDNAME functions - Requres ? ;load => func_uri.so ; URI encode/decode functions - Requires ? load => func_logic.so ; Logical dialplan functions ; Database Call Detail Records — ;load => cdr_addon_mysql.so ; Mysql CDR Backend - Requires ? ;load => cdr_csv.so ; Comma Separated Values CDR Backend - Requires N/A ;load => cdr_custom.so ; Customizable Comma Separated Values CDR Backend - Requires N/A ;load => cdr_manager.so ; Asterisk Call Manager CDR Backend - Requires N/A ;load => cdr_odbc.so ; ODBC CDR Backend - Requires N/A ;load => cdr_pgsql.so ; PostgreSQL CDR Backend - Requires N/A ;load => cdr_sqlite.so ; SQLite CDR Backend - Requires N/A ; Channels — ;load => chan_agent.so ; Agent Proxy Channel - Requires res_features.so, res_monitor.so, res_musiconhold.so ;load => chan_features.so ; Provides summary information on feature channels- Requires N/A load => chan_iax2.so ; Inter Asterisk eXchange (Ver 2) - Requires res_crypto.so, res_features.so ;load => chan_local.so ; Show status of local channels- Requires N/A ;load => chan_mgcp.so ; Media Gateway Control Protocol (MGCP) - Requires res_features.so ;load => chan_modem.so ; Generic Voice Modem Driver - Requires N/A ;load => chan_modem_aopen.so ; A/Open (Rockwell Chipset) ITU-2 VoiceMod- Requires chan_modem.so ;load => chan_modem_bestdata.so ; BestData (Conexant V.90 Chipset) VoiceModem - Requires chan_modem.so ;load => chan_modem_i4l.so ; ISDN4Linux Emulated Modem Driver - Requires chan_modem.so ;load => chan_oss.so ; OSS Console Channel Driver - Requires N/A ;load => chan_phone.so ; Linux Telephony API Support - Requires N/A load => chan_sip.so ; Session Initiation Protocol (SIP) - Requires res_features.so ;load => chan_skinny.so ; Skinny Client Control Protocol (Skinny) - Requires res_features.so ;load => chan_zap.so ; Zapata Telephony w/PRI - Requires ? ; Codecs — ;load => codec_adpcm.so ; Adaptive Differential PCM Coder/Decoder - Requires N/A load => codec_alaw.so ; A-law Coder/Decoder - Requires N/A ;load => codec_a_mu.so ; A-law and Mulaw direct Coder/Decoder - Requires N/A ;load => codec_g723.so ; G.723 Codect Translator - Requires N/A ;load => codec_g726.so ; ITU G.726-32kbps G726 Transcoder - Requires N/A ;load => codec_g729.so ; G729/PCM16 (signed linear) Codec Translator - Requires N/A ;load => codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translat - Requires N/A ;load => codec_ilbc.so ; iLBC/PCM16 (signed linear) Codec Translat - Requires N/A ;load => codec_lpc10.so ; LPC10 2.4kbps (signed linear) Voice Codec Translat - Requires N/A ;load => codec_speex.so ; Speex/PCM16 (signed linear) Codec Translat - Requires N/A ;load => codec_ulaw.so ; Mu-law Coder/Decoder - Requires N/A ; Formats — ;load => format_au.so ; Sun Microsystems AU format (signed linear) - Requires N/A ;load => format_g723.so ; Raw G.723 data - Requires N/A ;load => format_g726.so ; Raw G.726 (16/24/32/40kbps) data - Requires N/A ;load => format_g729.so ; Raw G729 data - Requires N/A ;load => format_gsm.so ; Raw GSM data - Requires N/A ;load => format_h263.so ; Raw h263 data - Requires N/A ;load => format_ilbc.so ; Raw iLBC data - Requires N/A ;load => format_jpeg.so ; JPEG (Joint Picture Experts Group) Image - Requires N/A ;load => format_mp3.so ; MP3 - Requires N/A ;load => format_pcm_alaw.so ; Raw aLaw 8khz PCM Audio support - Requires N/A load => format_pcm.so ; Raw uLaw 8khz Audio support (PCM) - Requires N/A ;load => format_sln.so ; Raw Signed Linear Audio support (SLN) - Requires N/A ;load => format_vox.so ; Dialogic VOX (ADPCM) File Format - Requires N/A ;load => format_wav_gsm.so ; Microsoft WAV format (Proprietary GSM) - Requires N/A load => format_wav.so ; Microsoft WAV format (8000hz Signed Linear) - Requires N/A ; Applications — ;load => app_addon_sql_mysql.so ; Do several mySQLy things - Requires ? ;load => app_adsiprog.so ; Asterisk ADSI Programming Application - Requires res_adsi.so ;load => app_alarmreceiver.so ; Alarm Receiver for Asterisk - Requires N/A ;load => app_authenticate.so ; Authentication Application - Requires N/A ;load => app_cdr.so ; Tell Asterisk to not maintain a CDR for the current call - Requires N/A ;load => app_chanisavail.so ; Check if channel is available - Requires N/A ;load => app_chanspy.so ; Listen to the audio of an active channel - Requires N/A ;load => app_controlplayback.so ; Play a file with fast forward and rewind - Requires N/A ;load => app_curl.so ; ? - Requires N/A ;load => app_cut.so ; The application Cut is deprecated. - Requires N/A ;load => app_db.so ; Database access functions for Asterisk - Requires N/A load => app_dial.so ; Dialing Application - Requires res_features.so, res_musiconhold.so ;load => app_dictate.so ; Virtual Dictation Machine - Requires N/A ;load => app_directed_pickup.so ; Directed Call Pickup Application - Requres ? ;load => app_directory.so ; Provide directory of voicemail extensions - Requires N/A ;load => app_disa.so ; Allows someone from outside an "internal" system dialtone - Requires N/A ;load => app_dumpchan.so ; Dump Info About The Calling Channel - Requires N/A load => app_echo.so ; Echo audio read from channel back to the channel - Requires N/A ;load => app_enumlookup.so ; EnumLookup is deprecated. Use ENUMLOOKUP() function - Requires N/A ;load => app_eval.so ; Reevaluates strings - Requires N/A ;load => app_exec.so ; Allows an arbitrary application to be invoked even when not hardcoded into the dialplan. - Requires N/A ;load => app_externalivr.so ; External IVR Interface Application - Requires ? ;load => app_festival.so ; Simple Festival Interface - Requires N/A ;load => app_flash.so ; Flashes a Zap Trunk - Requires ? ;load => app_forkcdr.so ; Fork The CDR into 2 separate entities. - Requires N/A ;load => app_getcpeid.so ; Obtains and displays ADSI CPE ID and other info in order to properly setup zapata.conf for on-hook operations. ;load => app_groupcount.so ; Deprecated, please use the function GroupCount - Requires N/A ;load => app_hasnewvoicemail.so ; Indicator whether a voice mailbox has messages in a given folder. - Requires N/A ;load => app_ices.so ; Encode and Stream via icecast and ices - Requires N/A ;load => app_image.so ; Sends an image on a channel. - Requires N/A ;load => app_intercom.so ; Obsolete - does not load ;load => app_lookupblacklist.so ; Look up Caller*ID name/number from blacklist database - Requires N/A ;load => app_lookupcidname.so ; Look up CallerID Name from local database - Requires N/A load => app_macro.so ; Macro Handling Application - Requires N/A ;load => app_math.so ; Basic Math Functions - Requires N/A ;load => app_md5.so ; MD5 checksum applications - Requires N/A ;load => app_meetme.so ; MeetMe conference bridge - Requires ? ;load => app_milliwatt.so ; Generate a Constant 1000Hz tone at 0dbm (mu-law) - Requires N/A load => app_mixmonitor.so ; Records the audio on the current channel to the specified file. - Requires ? ;load => app_mp3.so ; Play an MP3 file or stream - Requires N/A ;load => app_nbscat.so ; Play an NBS local stream - Requires N/A ;load => app_page.so ; Places outbound calls and dumps them into a conference bridge, muted - Requires ? ;load => app_parkandannounce.so ; Call Parking and Announce Application - Requires res_features.so load => app_playback.so ; Sound File Playback Application - Requires N/A ;load => app_privacy.so ; Require phone number to be entered, if no CallerID sent - Requires N/A ;load => app_queue.so ; Queue handling applications - Requires res_features.so, res_monitor.so, res_musiconhold.so ;load => app_random.so ; Conditionally branches, based upon a probability - Requires N/A ;load => app_read.so ; Reads a #-terminated string of digits - Requires N/A ;load => app_readfile.so ; Stores output of file into a variable - Requires N/A ;load => app_realtime.so ; Use RealTime config handler to read data into channel variables. - Requires N/A ;load => app_record.so ; Record to a file - Requires N/A ;load => app_rxfax.so ; Receive a FAX to a file - Requires ? ;load => app_saycountpl.so ; Polish counting grammar - Requires ? ;load => app_sayunixtime.so ; Says a specified time in a custom format - Requires N/A ;load => app_senddtmf.so ; Sends arbitrary DTMF digits - Requires N/A ;load => app_sendtext.so ; Sends text to current channel (callee). - Requires N/A load => app_setcallerid.so ; Set Caller*ID on a call to a new value. - Requires N/A ;load => app_setcdruserfield.so ; Append to the CDR user field - Requires N/A ;load => app_setcidname.so ; SetCIDName deprecated in favor of the function CALLERID(name) - Requires N/A ;load => app_setcidnum.so ; SetCIDNum deprecated in favor of the function CALLERID(number) - Requires N/A ;load => app_setrdnis.so ; SetRDNIS deprecated in favor of the function CALLERID(rdnis) - Requires N/A ;load => app_settransfercapability.so ; Set ISDN Transfer Capability - Requires N/A ;load => app_sms.so ; SMS/PSTN handler - Requires N/A ;load => app_softhangup.so ; Hangs up the requested channel - Requires N/A ;load => app_stack.so ; Stack routines - Requires ? ;load => app_striplsd.so ; Deprecated - Requires N/A ;load => app_substring.so ; Deprecated - Requires N/A ;load => app_system.so ; Execute a system command - Requires N/A ;load => app_talkdetect.so ; Playback with Talk Detection - Requires N/A ;load => app_test.so ; Interface Test Application - Requires N/A ;load => app_transfer.so ; Transfer caller to remote extension - Requires N/A ;load => app_txfax.so ; Trivial FAX Transmit Application - Requires ? ;load => app_txtcidname.so ; The TXTCIDName deprecated in favor of the TXTCIDNAME dialplan function - Requires N/A ;load => app_url.so ; Send URL Applications - Requires N/A ;load => app_userevent.so ; Send an arbitrary event to the manager interface - Requires N/A ;load => app_verbose.so ; Send arbitrary text to verbose output - Requires N/A ;load => app_voicemail.so ; Comedian Mail (Voicemail System) - Requires res_adsi.so ;load => app_waitforring.so ; Waits until first ring after specified time - Requires N/A ;load => app_waitforsilence.so ; Waits for silence of specified time - Requires N/A ;load => app_while.so ; While Loops and Conditional Execution - Requires N/A ;load => app_zapateller.so ; Block Telemarketers with Special Information Tone - Requires N/A ;load => app_zapbarge.so ; Barges in on a specified zap channel - Requires ? ;load => app_zapras.so ; Executes a RAS server using pppd on the given channel - Requires ? ;load => app_zapscan.so ; Scan Zap channels to monitor calls - Requires ? [global] chan_modem.so=yes
註:autoload 必須是 no,要關閉模組項,就在前方加上 ; 分號。
啟動 Asterisk
# asterisk 背景執行
# asterisk -vvvc 前景執行,且自動進入 CLI 模式
檢查載入的模組
CLI>module show Module Description Use Count res_features.so Call Features Resource 0 res_musiconhold.so Music On Hold Resource 0 pbx_config.so Text Extension Configuration 0 func_callerid.so Caller ID related dialplan function 0 func_logic.so Logical dialplan functions 0 chan_iax2.so Inter Asterisk eXchange (Ver 2) 0 chan_sip.so Session Initiation Protocol (SIP) 0 codec_alaw.so A-law Coder/Decoder 0 format_pcm.so Raw/Sun uLaw/ALaw 8KHz (PCM,PCMA,AU), G. 0 format_wav.so Microsoft WAV format (8000Hz Signed Line 0 app_dial.so Dialing Application 0 app_echo.so Simple Echo Application 0 app_macro.so Extension Macros 0 app_mixmonitor.so Mixed Audio Monitoring Application 0 app_playback.so Sound File Playback Application 0 app_setcallerid.so Set CallerID Application 0 16 modules loaded
檢查機器的記憶體使用狀況
# free total used free shared buffers Mem: 13004 12240 764 0 1128 Swap: 127864 0 127864 Total: 140868 12240 128628
雖然已經停用了許多模組,看來這款機器內建的 16MB RAM 在運行 Asterisk 後會很吃力。
另外,眼尖的朋友應該會看到 total 好像少了幾 MB 的記憶體,這是因為 DD-WRT 會利用些許記憶體用在 ramdisk,系統在運行中所需要的暫存檔都會使用這個 ramdisk。
設定自動啟動 Asterisk 程序
# mkdir /opt/etc/init.d
# vi /opt/etc/init.d/S50asterisk
#!/bin/sh case $1 in start) if [ -f /opt/var/lib/asterisk/astdb ]; then cp /opt/var/lib/asterisk/astdb /opt/var/lib/asterisk/astdata fi if [ ! -f /var/lib/asterisk/astdb ]; then mkdir -p /var/lib/asterisk/ if [ -f /opt/var/lib/asterisk/astdata ]; then cp /opt/var/lib/asterisk/astdata /var/lib/asterisk/astdb else touch /var/lib/asterisk/astdb fi fi if [ -f /opt/var/lib/asterisk/astdb ]; then rm /opt/var/lib/asterisk/astdb ln -s /var/lib/asterisk/astdb /opt/var/lib/asterisk/astdb fi /opt/sbin/asterisk -q if [ -f /var/lib/asterisk/astdb ]; then chmod 755 /var/lib/ chmod 755 /var/lib/asterisk/ fi ;; stop) if [ -n "`pidof asterisk`" ]; then /opt/sbin/asterisk -r -x 'stop now' fi if [ -f /var/lib/asterisk/astdb ]; then cp /var/lib/asterisk/astdb /opt/var/lib/asterisk/astdata fi ;; *) echo "usage: $0 (start|stop)" exit 1 esac exit 0
# chmod 755 /opt/etc/init.d/S50asterisk
# vi /opt/etc/optware.startup
#!/bin/sh # ( export PATH=/opt/bin:/opt/sbin:$PATH # Insert whatever it takes to mount the USB drive here # # Start all init scripts in /opt/etc/init.d # executing them in numerical order. # for i in /opt/etc/init.d/S??* ; do # Ignore dangling symlinks (if any). [ ! -f "$i" ] && continue case "$i" in *.sh) # Source shell script for speed. ( trap - INT QUIT TSTP set start . $i ) ;; *) # No sh extension, so fork subprocess. $i start ;; esac done ) > /tmp/optware_startup.log 2>&1
#chmod 755 /opt/etc/optware.startup
設定 DD-WRT 重開機後會自動啟動 Asterisk,步驟
登入管理網頁 > Administration > Commands > Startup 編輯,接著內容的下方填入
/opt/etc/config/optware.startup
設定 Asterisk 自動關閉程序
# cp /opt/etc/init.d/S50asterisk /opt/etc/init.d/K50asterisk
# vi /opt/etc/config/optware.shutdown
#!/bin/sh # # Insert whatever it takes to mount the USB drive here # # Start all init scripts in /opt/etc/init.d # executing them in numerical order. # for i in /opt/etc/init.d/K??* ; do # Ignore dangling symlinks (if any). [ ! -f "$i" ] && continue case "$i" in *.sh) # Source shell script for speed. ( trap - INT QUIT TSTP set stop . $i ) ;; *) # No sh extension, so fork subprocess. $i stop ;; esac done
#chmod 755 /opt/etc/optware.shutdown
設定 DD-WRT 在執行關機程序時會自動停止 Asterisk,步驟
登入管理網頁 > Administration > Commands ,接著內容的下方填入
/opt/etc/config/optware.shutdown
按 Save Shutdown 存檔,重啟機器。
# vi /opt/etc/asterisk/sip.conf
[general] context=default ; Default context for incoming calls ;allowguest=no ; Allow or reject guest calls (default is yes) allowoverlap=no ; Disable overlap dialing support. (Default is yes) ;allowtransfer=no ; Disable all transfers (unless enabled in peers or users) ; Default is enabled ;realm=mydomain.tld ; Realm for digest authentication ; defaults to "asterisk". If you set a system name in ; asterisk.conf, it defaults to that system name ; Realms MUST be globally unique according to RFC 3261 ; Set this to your host name or domain name bindport=5060 ; UDP Port to bind to (SIP standard port is 5060) ; bindport is the local UDP port that Asterisk will listen on bindaddr=0.0.0.0 ; IP address to bind to (0.0.0.0 binds to all) srvlookup=yes ; Enable DNS SRV lookups on outbound calls ; Note: Asterisk only uses the first host ; in SRV records ; Disabling DNS SRV lookups disables the ; ability to place SIP calls based on domain ; names to some other SIP users on the Internet #include "/opt/etc/asterisk/sip_custom.conf" ;pedantic=yes ; Enable checking of tags in headers,
# vi /opt/etc/asterisk/sip_custom.conf
; SIP accounts [1000] type=friend context=internal callerid="Softphone" <1000> qualify=yes secret=1111 nat=yes canreinvite=no dtmfmode=rfc2833 host=dynamic call-limit=2 disallow=all allow=alaw [1001] type=friend context=internal callerid="Home" <1001> qualify=yes secret=1111 nat=yes canreinvite=no dtmfmode=rfc2833 host=dynamic call-limit=2 disallow=all allow=alaw
# vi /opt/etc/asterisk/extensions.conf
;priorityjumping=yes ; ; User context is where entries from users.conf are registered. The ; default value is 'default' ; ;userscontext=default ; ; You can include other config files, use the #include command ; (without the ';'). Note that this is different from the "include" command ; that includes contexts within other contexts. The #include command works ; in all asterisk configuration files. ;#include "filename.conf" #include "/opt/etc/asterisk/extensions_custom.conf" ; The "Globals" category contains global variables that can be referenced ; in the dialplan with the GLOBAL dialplan function: ; ${GLOBAL(VARIABLE)} ; ${${GLOBAL(VARIABLE)}} or ${text${GLOBAL(VARIABLE)}} or any hybrid ; Unix/Linux environmental variables can be reached with the ENV dialplan ; function: ${ENV(VARIABLE)} ; [globals]
# vi /opt/etc/asterisk/extensions_custom.conf
[globals] ;;; apps context [apps] exten => 444,1,Answer() exten => 444,n,Wait(1) exten => 444,n,Echo ;;; incoming calls context [incoming] ;exten => 3221234567,1,Dial(SIP/1001,30) ;exten => 3221234567,n,Dial(SIP/1002,30) ;exten => 3221234567,n,Dial(SIP/1000,30) ;;; outgoing calls context ; local calls only [local] include => apps exten => _1XXX,1,Dial(SIP/${EXTEN}) exten => _1XXX,n,NoOp(===== DIAL STATUS --> ${DIALSTATUS} =====) exten => _1XXX,n,Hangup() ; national (Belgium, code 32) calls only [national] include => local include => apps ;exten => _0N.,1,Dial(SIP/0032${EXTEN:1}@itsp_ipness) ;exten => _0N.,n,NoOp(===== DIAL STATUS --> ${DIALSTATUS} =====) ;exten => _0N.,n,Hangup() ; international calls [international] ;include => national ;include => local ;include => apps ;exten => _00.,1,Dial(SIP/${EXTEN}@itsp_ipness) ;exten => _00.,n,NoOp(===== DIAL STATUS --> ${DIALSTATUS} =====) ;exten => _00.,n,Hangup()
存檔後,重啟 Asterisk 服務
# /opt/etc/init.d/S50asterisk stop
# /opt/etc/init.d/S50asterisk start
參考連結:
Install Asterisk on an Asus WL-520GU router
Googlevoice + Asterisk pbx (PiAF) + Free DID from SipGate = Free incoming/outgoing USA VOIP service
Slimming Asterisk for the NSLU2 under Debian
使用 SJphone 註冊分機 1000,撥 444 Echo Test -> OK
使用 PAP2 註冊分機 1001,撥分機 1000 -> OK
在保持兩個 Channels 持續通話,系統的資源使用狀態:
DD-WRT 網頁的資訊
使用 top 指令觀察 CPU 使用
使用 free 指令觀察記憶體使用
CPU 資訊
Memory 資訊
如果分機是在外部網路的 Internet 上,在DD-WRT預設的環境下外部分機是無法向 Asterisk 註冊的,解決方法也很簡單,只要在防火牆規則開啟需要的通訊埠即可。
執行步驟如下:
登入管理網頁 > Administration > Commands 文字框填入
iptables -I INPUT 1 -p udp --dport 5060 -j ACCEPT iptables -I INPUT 1 -p udp --dport 10000:20000 -j ACCEPT iptables -I INPUT 1 -p udp --dport 4569 -j ACCEPT
或者,改成比較安全的規則如下(僅適用外部分機使用固定IP時):
iptables -I INPUT 1 -p udp --dport 5060 -s outbound_ip_of_outside_extension -j ACCEPT iptables -I INPUT 1 -p udp --dport 10000:20000 -s outbound_ip_of_outside_extension -j ACCEPT iptables -I INPUT 1 -p udp --dport 4569 -s outbound_ip_of_outside_extension -j ACCEPT
按 Save Firewall 存檔,重啟機器。
提示!
登入管理頁 > Administration > Commands
Startup (開機指令)
sleep 10 && mount /dev/scsi/host0/bus0/target0/lun0/part1 /opt sleep 10 && mount /dev/scsi/host0/bus0/target0/lun0/part3 /jffs/usb-disk sleep 10 && mount /dev/scsi/host0/bus0/target0/lun0/part4 /mnt sleep 10 && /opt/bin/busybox swapon /dev/scsi/host0/bus0/target0/lun0/part2 /opt/etc/config/optware.startup
Shutdown (關機指令)
/opt/etc/config/optware.shutdown
Firewall (防火牆指令)
iptables -I INPUT 1 -p udp --dport 5060 -j ACCEPT iptables -I INPUT 1 -p udp --dport 10000:20000 -j ACCEPT iptables -I INPUT 1 -p udp --dport 4569 -j ACCEPT
#> vi /opt/etc/profile
#
export PATH=/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin
export PS1='\u@\h:\w\$ '
[ -x /opt/bin/less ] || alias less=more
[ -x /opt/bin/vim ] || alias vim=vi
arp() { cat /proc/net/arp; }
ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
reboot() {
echo "$(nvram get rc_shutdown)" > /tmp/.rc_shutdown
if [ -f /tmp/.rc_shutdown ]; then
chmod +x /tmp/.rc_shutdown
/tmp/.rc_shutdown
fi
/opt/sbin/asterisk -rx "stop now" > /dev/null 2>&1 <--- 這行作用是在關機前再一次關閉 Asterisk, 可不加。
/sbin/reboot
}
#> vi /opt/etc/config/optware.startup
增加藍字的部份
#!/bin/sh
#
(
export PATH=/opt/bin:/opt/sbin:$PATH
[ -e /opt/etc/profile ] && mount -o bind /opt/etc/profile /etc/profile
# Insert whatever it takes to mount the USB drive here
#
# Start all init scripts in /opt/etc/init.d
# executing them in numerical order.
#
for i in /opt/etc/init.d/S??* ; do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
) > /tmp/optware_startup.log 2>&1
文件 | 大小 | 日期 | 附件上傳者 | |||
---|---|---|---|---|---|---|
![]() | 4gb_USB_Drive.jpg USB_Flash_Drive | 24.71 KB | 18:54, 16 Oct 2009 | alang | 動作 | |
![]() | asus_wl-520gu.jpg ASUS WL-520GU | 2.96 KB | 17:23, 14 Oct 2009 | alang | 動作 | |
![]() | DD-WRT_2_Channels_cpu_mem.png DD-WRT CPU & Memory | 36.77 KB | 00:07, 19 Oct 2009 | alang | 動作 | |
![]() | ![]() | DD-WRT_2_Channels_free.png DD-WRT free | 7.85 KB | 00:07, 19 Oct 2009 | alang | 動作 |
![]() | DD-WRT_2_Channels_top.png DD-WRT top | 36.04 KB | 00:11, 19 Oct 2009 | alang | 動作 | |
![]() | DD-WRT_SSH.png DD-WRT with SSH | 13.66 KB | 23:59, 18 Oct 2009 | alang | 動作 | |
![]() | DD-WRT_Status.png DD-WRT Status | 49.17 KB | 00:00, 19 Oct 2009 | alang | 動作 | |
![]() | wl520gu-cpu.png DD-WRT CPU | 12.05 KB | 10:19, 17 Dec 2009 | alang | 動作 | |
![]() | wl520gu-mem.png DD-WRT Memory | 9.63 KB | 10:19, 17 Dec 2009 | alang | 動作 |
Images 9 | ||
---|---|---|
![]() USB_Flash_Drive4gb_USB_Drive.jpg | ![]() ASUS WL-520GUasus_wl-520gu.jpg | ![]() DD-WRT CPU & MemoryDD-WRT_2_Channels_cpu_mem.png |
![]() DD-WRT freeDD-WRT_2_Channels_free.png | ![]() DD-WRT topDD-WRT_2_Channels_top.png | ![]() DD-WRT with SSHDD-WRT_SSH.png |
![]() DD-WRT StatusDD-WRT_Status.png | ![]() DD-WRT CPUwl520gu-cpu.png | ![]() DD-WRT Memorywl520gu-mem.png |
1.小弟還想自動群呼我所需要的用用戶(自訂的一長串電話號碼)播放語音信息。
2,群呼我指定的號碼,響一聲即掛。。。
基於以上兩點小應用,你仍然是推薦這個機器和安裝這個asterisk版本,看應用,似乎大陸的這個版本http://cn.astercc.org 好象跟我想要的非常類似,如果我非要安裝astercc在這款機器上,請你用你的使用經驗來說,可行不??
1.小弟還想自動群呼我所需要的用戶(自訂的一長串電話號碼)播放語音信息。
2,群呼我指定的號碼,響一聲即掛。。。
舉凡這類的特殊應用,還是建議用 x86 機器來運行。