Asterisk13その2

* [Asterisk13+日本語ガイダンス - Qiita](http://qiita.com/tukiyo3/items/20fad28d1bfc1846fac4)の続き
* Astersisk11と同じ。

# 鍵生成

```bash:
# astgenkey

This script generates an RSA private and public key pair
in PEM format for use by Asterisk.  You will be asked to
enter a passcode for your key multiple times.  Please
enter the same code each time.  The resulting files will
need to be moved to /var/lib/asterisk/keys if you want
to use them, and any private keys (.key files) will
need to be initialized at runtime either by running
Asterisk with the '-i' option, or with the 'keys init'
command once Asterisk is running.

Press ENTER to continue or ^C to cancel.

Enter key name: pbx.localdomain
Generating SSL key 'pbx.localdomain':
Generating RSA private key, 1024 bit long modulus
................++++++
.....++++++
e is 65537 (0x10001)
Enter pass phrase for pbx.localdomain.key:
Verifying - Enter pass phrase for pbx.localdomain.key:
Enter pass phrase for pbx.localdomain.key:
writing RSA key
Key creation successful.
Public key:  pbx.localdomain.pub
Private key: pbx.localdomain.key
```

> pass phrase

３回聞かれるが、全部同じパスワードを入力。

* /etc/asterisk/pbx.localdomain.key
* /etc/asterisk/pbx.localdomain.pub

が生成される。

# sip.conf

[Fusion IP-Phone マイページ](https://smart.fusioncom.co.jp/sfkr/mypage/)のページからSIP-user,SIP-passを取得しておく。

![fusion.png](https://qiita-image-store.s3.amazonaws.com/0/25728/e9955499-42c4-f09c-0e51-fdc6eb52747f.png)



# sip.conf (Fusion-IP Phone用)

```bash:sip.conf
; 参考:
; http://www.voip-info.jp/index.php/Asterisk_FUSION
; http://www.voip-info.jp/index.php/FUSION_IP-Phone_SMART

[general]
maxexpirey=3600
defaultexpirey=3600
registertimeout=300
context=incoming ;incoming固定
port=5060
bindaddr=0.0.0.0
srvlookup=yes
disallow=all
allow=ulaw
allow=alaw
allow=gsm
language=ja

allowguest=yes ;yes固定

;[fusion1]
register => FUSIONユーザ名:FUSIONパスワード@fusion1/smart.0038.net

[fusion1]
type=friend
username=FUSIONユーザ名
fromuser=FUSIONユーザ名
secret=FUSIONパスワード
canreinvite=no
context=incoming
insecure=port,invite
host=smart.0038.net
fromdomain=smart.0038.net
dtmfmode=inband
allowsubscribe=no
nat=never

[201]
type=friend
defaultuser=201
secret=pass201
context=default ;default固定
canreinvite=no
host=dynamic
dtmfmode=rfc2833
callgroup=1
pickupgroup=1
mailbox=201

[202]
type=friend
defaultuser=202
secret=pass202
context=default
canreinvite=no
host=dynamic
dtmfmode=rfc2833
callgroup=1
pickupgroup=1
mailbox=202
```

# 複数registryする場合

```diff:sip.conf
  ; 参考:
  ; http://www.voip-info.jp/index.php/Asterisk_FUSION
  ; http://www.voip-info.jp/index.php/FUSION_IP-Phone_SMART
  
  [general]
  maxexpirey=3600
  defaultexpirey=3600
  registertimeout=300
  context=incoming ;incoming固定
  port=5060
  bindaddr=0.0.0.0
  srvlookup=yes
  disallow=all
  allow=ulaw
  allow=alaw
  allow=gsm
  language=ja
  
  allowguest=yes ;yes固定
  
  ;[fusion1]
  register => FUSIONユーザ名1:FUSIONパスワード2@fusion1/smart.0038.net
+ ;[fusion2]
+ register => FUSIONユーザ名2:FUSIONパスワード2@fusion1/smart.0038.net
  
  [fusion1]
  type=friend
  username=FUSIONユーザ名1
  fromuser=FUSIONユーザ名1
  secret=FUSIONパスワード1
  canreinvite=no
  context=incoming
  insecure=port,invite
  host=smart.0038.net
  fromdomain=smart.0038.net
  dtmfmode=inband
  allowsubscribe=no
  nat=never
  
+ [fusion2]
+ type=friend
+ username=FUSIONユーザ名2
+ fromuser=FUSIONユーザ名2
+ secret=FUSIONパスワード2
+ canreinvite=no
+ context=incoming
+ insecure=port,invite
+ host=smart.0038.net
+ fromdomain=smart.0038.net
+ dtmfmode=inband
+ allowsubscribe=no
+ nat=never
  
  
  [201]
  type=friend
  defaultuser=201
  secret=pass201
  context=default ;default固定
  canreinvite=no
  host=dynamic
  dtmfmode=rfc2833
  callgroup=1
  pickupgroup=1
  mailbox=201
  
  [202]
  type=friend
  defaultuser=202
  secret=pass202
  context=default
  canreinvite=no
  host=dynamic
  dtmfmode=rfc2833
  callgroup=1
  pickupgroup=1
  mailbox=202
```

```bash:
*CLI> core reload
*CLI> sip show registry
Host                                    dnsmgr Username       Refresh State                Reg.Time
fusion1:5060                            N      11111111           585 Registered           Thu, 13 Nov 2014 09:29:36
fusion2:5060                            N      22222222           585 Registered           Thu, 13 Nov 2014 09:29:36
2 SIP registrations.
```