OpenWrt on VMwareでAsteriskを動かす
Asterisk 1.4をOpenWrt Kamikaze for x86 (8.09.2) on VMware環境で動作させます。
OpenWrt Kamikaze for x86 (8.09.2)環境の構築
QEMUのインストール
WindowsにWindows版QEMUをインストールします。QEMUはVMwareイメージを作成するのに使用します。
QEMU on Windows
http://www.h7.dion.ne.jp/~qemu-win/index-ja.html
qemu-0.9.0-windows.zip
ダウンロードしたqemu-0.12.2-windows.zipを解凍し、C:直下におきました。また、フォルダ名をリネームしqemuとします。
OpenWrt Kamikaze for x86.imageのダウンロード
コンパイル済みのOpenWrt Kamikaze for x86をダウンロードします。
http://downloads.openwrt.org/kamikaze/8.09.2/x86/openwrt-x86-ext2.image
openwrt-x86-ext2.image
ダウンロードしたopenwrt-x86-ext2.imageをqemuと同一フォルダにおきます。
VMwareイメージの作成
QEMUでVMwareイメージを作成します。
コマンドプロンプトから下記のコマンドでQEMUを起動します。
C:\Documents and Settings\Administrator>cd c:\qemu
C:\qemu>qemu-img convert -f raw openwrt-x86-ext2.image -O vmdk openwrt-x86-ext2.vmdk
VMwawre設定ファイルの作成
下記の内容で拡張子 .vmx のファイル(openwrt-x86-ext2.vmx)を作成します。
.encoding = "Shift_JIS"
config.version = "8"
virtualHW.version = "4"
displayName = "OpenWrt Kamikaze x86 8.09.2"
annotation = ""
guestinfo.vmware.product.long = ""
guestinfo.vmware.product.url = ""
guestOS = "other26xlinux"
nvram = "OpenWrt Kamikaze x86.nvram"
MemTrimRate = "-1"
memsize = "128"
numvcpus = "1"
MemAllowAutoScaleDown = "FALSE"
uuid.action = "create"
checkpoint.vmState = ""
hints.hideAll = "TRUE"
serial0.pipe.endPoint = "server"
floppy0.present = "FALSE"
serial0.present = "TRUE"
serial0.fileType = "pipe"
serial0.fileName = "\\.\pipe\com_1"
serial0.hardwareFlowControl = "TRUE"
sound.present = "FALSE"
logging = "FALSE"
isolation.tools.hgfs.disable = "FALSE"
isolation.tools.dnd.disable = "FALSE"
isolation.tools.copy.enable = "TRUE"
isolation.tools.paste.enabled = "TRUE"
gui.restricted = "FALSE"
paevm = "TRUE"
gui.fullScreenAtPowerOn = "FALSE"
tools.syncTime = "TRUE"
ethernet0.present = "TRUE"
ethernet0.virtualDev = "e1000"
ethernet0.connectionType = "bridged"
ethernet0.addressType = "generated"
ethernet0.generatedAddress = "00:0c:29:33:8c:f3"
ethernet0.generatedAddressOffset = "0"
ethernet1.present = "TRUE"
ethernet1.virtualDev = "e1000"
ethernet1.connectionType = "bridged"
ethernet1.generatedAddress = "00:0c:29:33:8c:fd"
ethernet1.generatedAddressOffset = "10"
scsi0.present = "FALSE"
ide0:0.present = "TRUE"
ide0:0.fileName = "openwrt-x86-ext2.vmdk"
#ide0:0.fileName = "HDD.vmdk"
ide0:0.deviceType = "disk"
ide0:0.mode = "persistent"
ide0:0.redo = ""
ide0:0.startConnected = "TRUE"
ide0:0.writeThrough = "TRUE"
ide0:0.autodetect = "TRUE"
# USB settings
# This config activates USB
usb.present = "TRUE"
usb.generic.autoconnect = "FALSE"
ethernet1.addressType = "generated"
uuid.location = "56 4d ba e7 2e 2d ad fb-79 e9 20 93 fd 33 8c f3"
uuid.bios = "56 4d ba e7 2e 2d ad fb-79 e9 20 93 fd 33 8c f3"
virtualHW.productCompatibility = "hosted"
vmotion.checkpointFBSize = "18153472"
extendedConfigFile = "openwrt-x86-ext2.vmxf"
tools.upgrade.policy = "manual"
tools.remindInstall = "TRUE"
OpenWrtの実行確認
作成した openwrt-x86-ext2.vmdk と openwrt-x86-ext2.vmx を同じディレクトリに入れ、openwrt-x86-ext2.vmx を実行します。
telnetでログイン
Tera Termからtelnetでログインします。
IPアドレスは 192.168.1.1 です。
=== IMPORTANT ============================ Use 'passwd' to set your login password this will disable telnet and enable SSH ------------------------------------------ BusyBox v1.11.2 (2009-12-03 07:02:09 UTC) built-in shell (ash) Enter 'help' for a list of built-in commands. _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M KAMIKAZE (8.09.2, r18961) ------------------------- * 10 oz Vodka Shake well with ice and strain * 10 oz Triple sec mixture into 10 shot glasses. * 10 oz lime juice Salute! --------------------------------------------------- root@OpenWrt:/#
ログインパスワードの設定
ログインパスワードを設定します。
パスワード設定した後はTelnetからではなくSSHでログインするようにします。
root@OpenWrt:~# passwd
Changing password for root
New password:
Bad password: similar to username
Retype password:
Password for root changed by root
root@OpenWrt:~#
IPアドレスの変更
IPアドレスを192.168.1.1から192.168.1.2に変更します。
# uci set network.lan.proto=static
# uci set network.lan.ipaddr=192.168.1.2
# uci set network.lan.netmask=255.255.255.0
# uci set network.lan.gateway=192.168.1.1
# uci set network.lan.dns=192.168.1.1
# uci commit network
# ifdown lan && ifup lan
ネットワーク設定後のifconfigの表示内容です。
root@OpenWrt:/# ifconfig br-lan Link encap:Ethernet HWaddr 00:0C:29:33:8C:F3 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:11 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:5916 (5.7 KiB) TX bytes:608 (608.0 B) eth0 Link encap:Ethernet HWaddr 00:0C:29:33:8C:F3 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:23908 errors:0 dropped:0 overruns:0 frame:0 TX packets:172 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:14327487 (13.6 MiB) TX bytes:16781 (16.3 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:24 errors:0 dropped:0 overruns:0 frame:0 TX packets:24 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1464 (1.4 KiB) TX bytes:1464 (1.4 KiB) root@OpenWrt:/#
Asteriskのインストール
パッケージリストの更新
パッケージリストを更新します。
root@OpenWrt:/# opkg update Downloading http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages/Packages.gz Connecting to downloads.openwrt.org (78.24.191.177:80) Packages.gz 100% |*****************************************| 147k 00:00:00 ETA Inflating http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages/Packages.gz Updated list of available packages in /var/opkg-lists/snapshots root@OpenWrt:/#
asteriskのインストール
Asterisk 1.4をインストールします。
root@OpenWrt:/# opkg install asterisk14
Installing asterisk14 (1.4.23.1-1.2) to root...
Downloading http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages/asterisk14_1.4.23.1-1.2_i386.ipk
Connecting to downloads.openwrt.org (78.24.191.177:80)
asterisk14_1.4.23.1- 100% |*****************************************| 1312k 00:00:00 ETA
Installing libncurses (5.6-1) to root...
Downloading http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages/libncurses_5.6-1_i386.ipk
Connecting to downloads.openwrt.org (78.24.191.177:80)
libncurses_5.6-1_i38 100% |*****************************************| 148k 00:00:00 ETA
Installing libpopt (1.7-4) to root...
Downloading http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages/libpopt_1.7-4_i386.ipk
Connecting to downloads.openwrt.org (78.24.191.177:80)
libpopt_1.7-4_i386.i 100% |*****************************************| 13474 00:00:00 ETA
Installing libpthread (0.9.29-14.3) to root...
Downloading http://downloads.openwrt.org/kamikaze/8.09.2/x86/packages/libpthread_0.9.29-14.3_i386.ipk
Connecting to downloads.openwrt.org (78.24.191.177:80)
libpthread_0.9.29-14 100% |*****************************************| 17970 00:00:00 ETA
Configuring asterisk14
Configuring libncurses
Configuring libpopt
Configuring libpthread
root@OpenWrt:/#
Asteriskの起動と停止
Asteriskを起動します。
# /etc/init.d/asterisk start
Asteriskを停止します。
# /etc/init.d/asterisk stop
Asterisk (CLI)へのアクセス
asterisk -rvvvvvでCLI(コマンドラインインターフェース)にアクセスします。
root@OpenWrt:/# asterisk -rvvvvv
Asterisk 1.4.23.1, Copyright (C) 1999 - 2008 Digium, Inc. and others.
Created by Mark Spencer
Asteriskの設定
Asterisk設定ファイル
Asteriskの設定ファイルは /etc/asterisk ディレクトリにあります。
root@OpenWrt:~# cd /etc/asterisk
root@OpenWrt:/etc/asterisk# ls
agents.conf enum.conf logger.conf queues.conf
alarmreceiver.conf extconfig.conf manager.conf rtp.conf
amd.conf extensions.ael meetme.conf say.conf
asterisk.conf extensions.conf misdn.conf sip.conf
cdr.conf features.conf modules.conf sip_notify.conf
cdr_custom.conf followme.conf musiconhold.conf sla.conf
cdr_manager.conf http.conf musiconhold.conf.old smdi.conf
chan_dahdi.conf iax.conf muted.conf udptl.conf
codecs.conf iaxprov.conf osp.conf users.conf
dnsmgr.conf indications.conf privacy.conf
root@OpenWrt:/etc/asterisk#
マスタ設定ファイル(asterisk.conf)
asterisk.confはAsteriskが使用するディレクトリやオプションなどを設定するためのファイルです。
root@OpenWrt:/etc/asterisk# cat asterisk.conf
[directories]
astetcdir => /etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /usr/lib/asterisk
astdatadir => /usr/lib/asterisk
astagidir => /usr/lib/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run
astlogdir => /var/log/asterisk
[options]
languageprefix = yes ; Use the new sound prefix path syntax
;verbose = 3
;debug = 3
;alwaysfork = yes ; same as -F at startup
;nofork = yes ; same as -f at startup
;quiet = yes ; same as -q at startup
;timestamp = yes ; same as -T at startup
;execincludes = yes ; support #exec in config files
;console = yes ; Run as console (same as -c at startup)
;highpriority = yes ; Run realtime priority (same as -p at startup)
;initcrypto = yes ; Initialize crypto keys (same as -i at startup)
;nocolor = yes ; Disable console colors
;dontwarn = yes ; Disable some warnings
;dumpcore = yes ; Dump core on crash (same as -g at startup)
;internal_timing = yes
;systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues
;maxcalls = 10 ; Maximum amount of calls allowed
;maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit
;cache_record_files = yes ; Cache recorded sound files to another directory during recording
;record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)
;transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded
;transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated
;transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly
;runuser = asterisk ; The user to run as
;rungroup = asterisk ; The group to run as
;dahdichanname = yes ; Channels created by chan_dahdi will be called 'DAHDI', otherwise 'Zap'
; Changing the following lines may compromise your security.
;[files]
;astctlpermissions = 0660
;astctlowner = root
;astctlgroup = apache
;astctl = asterisk.ctl
root@OpenWrt:/etc/asterisk#
機能設定ファイル(features.conf)
コールパーキング(保留転送)の設定が記述されています。
下記の記述は、かかってきた電話を保留するときの内線番号が700、転送する先の番号の範囲が701~720と定義されています。
[general]
parkext => 700
parkpos => 701-720
context => parkedcalls
RTP設定ファイル(rtp.conf)
rtp.confは通話に使われるRTP(real-time transport protocol)を設定するファイルです。
[general]
rtpstart=10000
rtpend=20000
RTPの範囲として、ポート番号の10000~20000を指定しています。
モジュール設定ファイル(modules.conf)
モジュールのロードを制御します。通常は以下のような内容のファイルを用意します。
autoload=yes が定義されているとモジュール類は自動で読み込まれます。
SIPチャネルの設定(sip.conf)
2台のIP電話機のためのSIPチャネルを設定します。
[general]
maxexpirey=3600
defaultexpirey=3600
context=default
port=5060
bindaddr=0.0.0.0
srvlookup=yes
disallow=all
allow=ulaw
allow=gsm
language=jp
localnet=192.168.0.0/255.255.0.0
[201]
type=friend
username=201
secret=pass
canreinvite=no
host=dynamic
dtmfmode=auto
callgroup=1
pickupgroup=1
[202]
type=friend
username=202
secret=pass
canreinvite=no
host=dynamic
dtmfmode=auto
callgroup=1
pickupgroup=1
ダイヤルプランの設定(extensions.conf)
ダイヤルプランを記述します。
2台の電話機を接続し、それぞれの内線番号を201と202とします。
内線番号301としてエコーテストを実装します。
[general]
writeprotect=no
[default]
exten => 201,1,Dial(SIP/201,,tT)
exten => 201,n,Hangup
exten => 202,1,Dial(SIP/202,,tT)
exten => 202,n,Hangup
exten => 301,1,Answer()
exten => 301,n,Playback(beep)
exten => 301,n,Echo()
exten => 301,n,Hangup
保留音を鳴らす設定
保留音はmusiconhold.confファイルで設定します。
[default]
mode=files
directory=/usr/lib/asterisk/moh
mode=files で、保留音をファイルからの直接再生するように指定しています。
directory=/usr/lib/asterisk/moh で、音楽ファイルの場所を記述しています。
音楽ファイルはPCM(WAVEオーディオ)で、16bitモノラル、8KHzサンプリングのものを使用します。
OpenWrt Kamikazeダウンロードサイト
http://downloads.openwrt.org/kamikaze/
QEMU on Windows
http://www.h7.dion.ne.jp/~qemu-win/index-ja.html
2010.07.25