我在本地 Ubuntu 12.04 机器上安装了 Asterisk。启动星号 [asterisk -c] 后,我运行了以下命令
netstat -nlpa | grep asterisk
显示的输出如下 ->
tcp 0 0 127.0.0.1:5038 0.0.0.0:* LISTEN 2956/asterisk
tcp 0 0 192.168.32.181:8088 0.0.0.0:* LISTEN 2956/asterisk
udp 0 0 0.0.0.0:5000 0.0.0.0:* 2956/asterisk
udp 0 0 0.0.0.0:5060 0.0.0.0:* 2956/asterisk
udp 0 0 0.0.0.0:4520 0.0.0.0:* 2956/asterisk
udp 0 0 0.0.0.0:4569 0.0.0.0:* 2956/asterisk
unix 2 [ ACC ] STREAM LISTENING 25848 2956/asterisk /var/run/asterisk/asterisk.ctl
unix 2 [ ] DGRAM 25971 2956/asterisk
我的疑问是
- 为什么 asterisk 在环回地址上运行而不是在 192.168.32.181:5038 上运行?
- 为什么 SIP 没有绑定到任何地址?(仅显示 0.0.0.0:5060)
- 我应该编辑哪个文件才能使其按预期工作。
这是 asterisk cli 上“sip show settings”命令的输出->
*CLI> sip show settings
Global Settings:
----------------
UDP Bindaddress: 0.0.0.0:5060
TCP SIP Bindaddress: Disabled
TLS SIP Bindaddress: Disabled
Videosupport: No
Textsupport: No
Ignore SDP sess. ver.: No
AutoCreate Peer: No
Match Auth Username: No
Allow unknown access: No
Allow subscriptions: Yes
Allow overlap dialing: Yes
Allow promisc. redir: No
Enable call counters: No
SIP domain support: No
Realm. auth: No
Our auth realm asterisk
Use domains as realms: No
Call to non-local dom.: Yes
URI user is phone no: No
Always auth rejects: Yes
Direct RTP setup: No
User Agent: Asterisk PBX 1.8.10.1~dfsg-1ubuntu1
SDP Session Name: Asterisk PBX 1.8.10.1~dfsg-1ubuntu1
SDP Owner Name: root
Reg. context: (not set)
Regexten on Qualify: No
Legacy userfield parse: No
Caller ID: asterisk
From: Domain:
Record SIP history: Off
Call Events: Off
Auth. Failure Events: Off
T.38 support: No
T.38 EC mode: Unknown
T.38 MaxDtgrm: -1
SIP realtime: Disabled
Qualify Freq : 60000 ms
Q.850 Reason header: No
Store SIP_CAUSE: No
Network QoS Settings:
---------------------------
IP ToS SIP: CS0
IP ToS RTP audio: CS0
IP ToS RTP video: CS0
IP ToS RTP text: CS0
802.1p CoS SIP: 4
802.1p CoS RTP audio: 5
802.1p CoS RTP video: 6
802.1p CoS RTP text: 5
Jitterbuffer enabled: No
Network Settings:
---------------------------
SIP address remapping: Disabled, no localnet list
Externhost: <none>
Externaddr: (null)
Externrefresh: 10
Global Signalling Settings:
---------------------------
Codecs: 0x80000008000e (gsm|ulaw|alaw|h263|testlaw)
Codec Order: none
Relax DTMF: No
RFC2833 Compensation: No
Symmetric RTP: No
Compact SIP headers: No
RTP Keepalive: 0 (Disabled)
RTP Timeout: 0 (Disabled)
RTP Hold Timeout: 0 (Disabled)
MWI NOTIFY mime type: application/simple-message-summary
DNS SRV lookup: Yes
Pedantic SIP support: Yes
Reg. min duration 60 secs
Reg. max duration: 3600 secs
Reg. default duration: 120 secs
Outbound reg. timeout: 20 secs
Outbound reg. attempts: 0
Notify ringing state: Yes
Include CID: No
Notify hold state: No
SIP Transfer mode: open
Max Call Bitrate: 384 kbps
Auto-Framing: No
Outb. proxy: <not set>
Session Timers: Accept
Session Refresher: uas
Session Expires: 1800 secs
Session Min-SE: 90 secs
Timer T1: 500
Timer T1 minimum: 100
Timer B: 32000
No premature media: Yes
Max forwards: 70
Default Settings:
-----------------
Allowed transports: UDP
Outbound transport: UDP
Context: default
Force rport: Yes
DTMF: rfc2833
Qualify: 0
Use ClientCode: No
Progress inband: Never
Language:
MOH Interpret: default
MOH Suggest:
Voice Mail Extension: asterisk
注意:我可以通过注册用户(102)到默认号码 2006 来拨打虚拟电话。但我无法从同一 LAN 中的另一台机器注册同一用户。它显示“获取注册失败。408 请求超时”。可能是什么原因?是因为查询 1 中的原因吗?
sip.conf 中的条目
[102]
type=friend
host=dynamic
secret=******
context=demo1
extensions.conf 中的条目
[demo1]
exten => 2600,1,Dial(IAX2/[email protected]/s@default)
exten => 100,1,Dial(SIP/1060)
exten => 101,1,Dial(IAX2/[email protected]/s@default)
same => n,Hangup()
命令“sip show peers”的输出
*CLI> sip show peers
Name/username Host Dyn Forcerport ACL Port Status
101 (Unspecified) D N 0 Unmonitored
102/102 192.168.32.181 D N 5071 Unmonitored
1060/1060 (Unspecified) D N 0 Unmonitored
1061/1061 (Unspecified) D N 0 Unmonitored
4 sip peers [Monitored: 0 online, 0 offline Unmonitored: 1 online, 3 offline]
如果需要更多信息,请告诉我。谢谢。
答案1
您问了多个问题,我可以回答一些,但不是全部。
为什么星号在环回地址上运行而不是在 192.168.32.181:5038 上运行
据我几次搜索得知,端口 5038 是星号管理接口。因此,我假设出于安全原因,它绑定到 127.0.0.1:5038。您不会希望从任何地方都可以访问它。
为什么 SIP 没有绑定到任何地址?(仅显示 0.0.0.0:5060)
实际上它绑定到任意地址,因为 0.0.0.0 是任意地址。通过绑定到该地址,套接字将接收发送到分配给该机器的任何 IPv4 地址的数据包。
但是,对 UDP 使用任意地址而不对 TCP 使用任意地址有点奇怪。当服务器绑定到任意地址时,套接字 API 将让 TCP 服务器知道使用了哪个地址。但是对于 UDP,它必须将单独的套接字绑定到每个 IP,以便知道数据包被发送到哪个地址。因此,看到进程对 TCP 使用任意地址而不对 UDP 使用任意地址并不罕见。不知道为什么 asterisk 会反过来做。