Asterisk服务器在环回地址上运行而不是本地ipv4地址

我在我的本地Ubuntu 12.04机器上安装了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 

我的查询是

  1. 为什么星号运行在回送地址上,而不是192.168.32.181:5038?
  2. 为什么SIP不绑定到任何地址? (只显示0.0.0.0:5060)
  3. 我应该编辑什么文件,以便像愿望一样工作。

这是星号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中input

 [102] type=friend host=dynamic secret=****** context=demo1 

在extensions.conf中input

 [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) DN 0 Unmonitored 102/102 192.168.32.181 DN 5071 Unmonitored 1060/1060 (Unspecified) DN 0 Unmonitored 1061/1061 (Unspecified) DN 0 Unmonitored 4 sip peers [Monitored: 0 online, 0 offline Unmonitored: 1 online, 3 offline] 

请让我知道是否需要更多的信息。 谢谢。

你问多个问题,我可以回答一些,但不是全部。

为什么星号运行在回送地址上,而不是192.168.32.181:5038

据我所知,从几个search端口5038是星号pipe理界面。 所以我认为它出于安全原因绑定到127.0.0.1:5038。 你不会希望从任何地方都可以访问它。

为什么SIP不绑定到任何地址? (只显示0.0.0.0:5060)

其实它是绑定到任何地址,因为0.0.0.0是任何地址。 通过绑定到该地址,套接字将接收发送到分配给该机器的任何IPv4地址的数据包。

使用任何地址的UDP而不是TCP有点奇怪。 当服务器绑定到任何地址时,套接字API将让TCP服务器知道使用了哪个地址。 但是对于UDP,它必须将不同的套接字绑定到每个IP,以便知道分组被发送到哪个地址。 因此,看到一个进程使用TCP的任何地址而不是UDP的情况并不罕见。 不知道为什么星号会反其道而行。