218_さくらVPS2、CentOS6.9/Asterisk 13/RegOK

ビルド環境構築
$ yum update
$ yum install gcc-c++ make gnutls-devel kernel-devel libxml2-devel ncurses-devel subversion doxygen texinfo curl-devel net-snmp-devel neon-devel
$ yum install uuid-devel libuuid-devel sqlite-devel sqlite git speex-devel gsm-devel
janssonが必要とのことなのでこちらもインストール
$ cd /usr/src/
$ git clone https://github.com/akheron/jansson.git
$ cd jansson
$ autoreconf -i
$ ./configure -prefix=/usr/
$ make && make install
必要ライブラリのインストール
SRTP
$ cd /usr/src/
$ wget wget https://downloads.sourceforge.net/project/srtp/srtp/1.4.4/srtp-1.4.4.tgz
$ tar zxvf srtp-1.4.4.tgz
$ cd srtp
$ autoconf
$ ./configure CFLAGS=-fPIC
$ make && make install
PJPROJECT
$ cd /usr/src/
$ wget http://www.pjsip.org/release/2.4/pjproject-2.4.tar.bz2
$ tar xvjf pjproject-2.4.tar.bz2
$ cd pjproject-2.4
$ ./configure –prefix=/usr –enable-shared –disable-sound –disable-resample –disable-video –disable-opencore-amr
$ ./configure –libdir=/usr/lib64 –prefix=/usr –enable-shared –disable-sound –disable-resample –disable-video –disable-opencore-amr
$ touch pjlib/include/pj/config_site.h
$ make dep
$ make clean
$ make
$ make install
$ ldconfig
確認!!!
$ ldconfig -p | grep pj
Asteriskのビルド&インストール
$ cd /usr/src/
# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz
# tar zxvf asterisk-14-current.tar.gz
# cd asterisk-14.4.0
$ ./configure -with-crypto -with-ssl -with-srtp=/usr/local/lib –prefix=/usr –libdir=/usr/lib64
$ contrib/scripts/get_mp3_source.sh
$ make menuselect
Resource Modules を選択 下記のように res_pjsip_**** が [*] となっていることを確認。
**************************************************
Asterisk Module and Build Option Selection
**************************************************
                Press ‘h’ for help.
               [*] res_format_attr_celt
[*] res_format_attr_h263
ビルド完了!
$ make install
+—- Asterisk Installation Complete ——-+
+                                           +
+    YOU MUST READ THE SECURITY DOCUMENT    +
+                                           +
+ Asterisk has successfully been installed. +
+ If you would like to install the sample   +
+ configuration files (overwriting any      +
+ existing config files), run:              +
+                                           +
+                make samples               +
+                                           +
+—————–  or ———————+
+                                           +
+ You can go ahead and install the asterisk +
+ program documentation now or later run:   +
+                                           +
+               make progdocs               +
+                                           +
+ **Note** This requires that you have      +
+ doxygen installed on your local system    +
+——————————————-+
インストール完了!!
$ make
+——— Asterisk Build Complete ———+
+ Asterisk has successfully been built, and +
+ can be installed by running:              +
+                                           +
+                make install               +
+——————————————-+
$ make samples
$ make config
$ chkconfig asterisk on
設定
# cd /etc/asterisk
# vi sip.conf
[general]
;
;***********2017/04/08 setting*****************
;
bindport=5060
;context=default
;port=5060
;bindaddr=0.0.0.0
;language=ja
localhost=153.126.154.106/255.255.255.0
[5000]
type=friend
username=5000
secret=pass
canreinvite=no
host=dynamic
[5001]
type=friend
username=5001
secret=pass
canreinvite=no
host=dynamic
[5002]
type=friend
username=5002
secret=pass
canreinvite=no
host=dynamic
[5003]
type=friend
username=5003
secret=pass
canreinvite=no
host=dynamic
[5004]
type=friend
username=5004
secret=pass
canreinvite=no
host=dynamic
;
;***********2017/04/08 setting*****************
;
Asterisk の設定:/etc/asterisk/extensions.conf
[default] セクションを下記のように変更します。。。。と。
;
;***********2017/04/08 setting*****************
;
exten => _5XXX,1,Dial(SIP/${EXTEN},30)
exten => _5XXX,2,Congestion
exten => _5XXX,102,Busy
exten => 9001,1,Playback(queue-thankyou)
exten => 9002,1,Playback(hello-world)
;
;***********2017/04/08 setting*****************
;
Asterisk の設定:/etc/asterisk/rtp.conf
[default] セクションを下記のように変更します。。。。と。
rtpstart=10000
rtpend=10010
;rtpend=20000
起動
$ /etc/init.d/asterisk start
[iptables(ファイアーウォール)でポートを開く]
# cd /etc/sysconfig/
# vi iptables
#——————————————————————-
-A INPUT -p tcp -m state –state NEW -m tcp –dport 22 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 5060 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 80 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 25 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 443 -j ACCEPT
-A INPUT -p tcp -m state –state NEW -m tcp –dport 3306 -j ACCEPT
#——————————————————————-
このようにポートを解放して、iptables再起動。
参考
http://qiita.com/shimohiko/items/ec672655edb84578a82e
# /etc/init.d/iptables restart
上記はコメントにして下記に修正

を参考
# vi iptables
A INPUT -p udp -m udp –dport 5060 -j ACCEPT
A INPUT -p udp -m udp –dport 10000:20000 -j ACCEPT
にしてみる。
# /etc/init.d/iptables restart
REGが通った!!!!!!