我嘗試在運行的 Debian 10 伺服器上安裝 HylaFax + IAXModem + Asterisk。伺服器直接連接到互聯網,防火牆已停用(未設定規則)。伺服器唯一要做的就是發送傳真。我使用 sipgate 主幹。在 HylaFax 嘗試發送傳真期間,我在 Asterisk 控制台中看到此輸出(SIP 偵錯和詳細程度開啟/10):
-- Accepting AUTHENTICATED call from 127.0.0.1:4570:
-- > requested format = alaw,
-- > requested prefs = (),
-- > actual format = alaw,
-- > host prefs = (alaw),
-- > priority = mine
-- Executing [RECIPIENT@fax_out:1] Set("IAX2/iaxmodem-7708", "CALLERID(num)=CALLER") in new stack
-- Executing [RECIPIENT@fax_out:2] Set("IAX2/iaxmodem-7708", "CALLERID(name)=CALLER") in new stack
-- Executing [RECIPIENT@fax_out:3] SIPAddHeader("IAX2/iaxmodem-7708", "P-Preferred-Identity:<sip:CALLER>") in new stack
-- Executing [RECIPIENT@fax_out:4] Dial("IAX2/iaxmodem-7708", "SIP/sipconnect.sipgate.de/RECIPIENT,,r") in new stack
== Using SIP RTP CoS mark 5
Audio is at 17702
Adding codec alaw to SDP
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 217.10.68.150:5060:
INVITE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:5060;branch=z9hG4bK12349644
Max-Forwards: 70
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>
Contact: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 102 INVITE
User-Agent: Asterisk PBX 16.2.1~dfsg-1+deb10u1
Date: Mon, 21 Oct 2019 12:22:20 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
P-Preferred-Identity: <sip:CALLER>
P-Asserted-Identity: "CALLER" <sip:[email protected]>
Content-Type: application/sdp
Content-Length: 270
v=0
o=root 698738770 698738770 IN IP4 127.0.1.1
s=Asterisk PBX 16.2.1~dfsg-1+deb10u1
c=IN IP4 127.0.1.1
t=0 0
m=audio 17702 RTP/AVP 8 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv
---
-- Called SIP/sipconnect.sipgate.de/RECIPIENT
<--- SIP read from UDP:217.10.68.150:5060 --->
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 127.0.1.1:5060;rport=5060;received=X.X.X.X;branch=z9hG4bK12349644
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>;tag=c63713a666d5644779294882ed89253a.0c69
Call-ID: [email protected]
CSeq: 102 INVITE
Proxy-Authenticate: Digest realm="sipconnect.sipgate.de", nonce="Xa2kKF2tovxRNF/AcCiPaUlB/z/ev7jl"
Content-Length: 0
<------------->
--- (8 headers 0 lines) ---
Transmitting (no NAT) to 217.10.68.150:5060:
ACK sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:5060;branch=z9hG4bK12349644
Max-Forwards: 70
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>;tag=c63713a666d5644779294882ed89253a.0c69
Contact: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 102 ACK
User-Agent: Asterisk PBX 16.2.1~dfsg-1+deb10u1
Content-Length: 0
---
Audio is at 17702
Adding codec alaw to SDP
Adding codec ulaw to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 217.10.68.150:5060:
INVITE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:5060;branch=z9hG4bK248f1ffc
Max-Forwards: 70
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>
Contact: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 103 INVITE
User-Agent: Asterisk PBX 16.2.1~dfsg-1+deb10u1
Proxy-Authorization: Digest username="USER", realm="sipconnect.sipgate.de", algorithm=MD5, uri="sip:[email protected]:5060", nonce="Xa2kKF2tovxRNF/AcCiPaUlB/z/ev7jl", response="42016e991f588a252062bb86b35a3f6c"
Date: Mon, 21 Oct 2019 12:22:20 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
P-Preferred-Identity: <sip:CALLER>
P-Asserted-Identity: "CALLER" <sip:[email protected]>
Content-Type: application/sdp
Content-Length: 270
v=0
o=root 698738770 698738771 IN IP4 127.0.1.1
s=Asterisk PBX 16.2.1~dfsg-1+deb10u1
c=IN IP4 127.0.1.1
t=0 0
m=audio 17702 RTP/AVP 8 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv
---
<--- SIP read from UDP:217.10.68.150:5060 --->
SIP/2.0 100 trying -- your call is important to us
Via: SIP/2.0/UDP 127.0.1.1:5060;rport=5060;received=X.X.X.X;branch=z9hG4bK248f1ffc
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 103 INVITE
Content-Length: 0
<------------->
--- (7 headers 0 lines) ---
<--- SIP read from UDP:217.10.68.150:5060 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 127.0.1.1:5060;rport=5060;received=X.X.X.X;branch=z9hG4bK248f1ffc
Record-Route: <sip:172.20.40.8;lr>
Record-Route: <sip:217.10.68.150;lr;ftag=as65bc91b0>
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>;tag=as21618100
Call-ID: [email protected]
CSeq: 103 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces
Contact: <sip:[email protected]:5060>
Content-Length: 0
<------------->
--- (12 headers 0 lines) ---
sip_route_dump: route/path hop: <sip:217.10.68.150;lr;ftag=as65bc91b0>
sip_route_dump: route/path hop: <sip:172.20.40.8;lr>
-- SIP/sipconnect.sipgate.de-00000003 is ringing
<--- SIP read from UDP:217.10.68.150:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 127.0.1.1:5060;rport=5060;received=X.X.X.X;branch=z9hG4bK248f1ffc
Record-Route: <sip:172.20.40.8;lr>
Record-Route: <sip:217.10.68.150;lr;ftag=as65bc91b0>
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>;tag=as21618100
Call-ID: [email protected]
CSeq: 103 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces
Contact: <sip:[email protected]:5060>
Content-Type: application/sdp
Content-Length: 298
v=0
o=root 1290589385 1290589385 IN IP4 217.116.117.70
s=sipgate VoIP GW
c=IN IP4 212.9.44.253
t=0 0
m=audio 15550 RTP/AVP 8 0 101
a=silenceSupp:off - - - -
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv
a=rtcp:15551
a=ptime:20
<------------->
--- (13 headers 14 lines) ---
Found RTP audio format 8
Found RTP audio format 0
Found RTP audio format 101
Found audio description format PCMA for ID 8
Found audio description format PCMU for ID 0
Found audio description format telephone-event for ID 101
Capabilities: us - (alaw|ulaw), peer - audio=(ulaw|alaw)/video=(nothing)/text=(nothing), combined - (alaw|ulaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
> 0x7f4634015640 -- Strict RTP learning after remote address set to: 212.9.44.253:15550
Peer audio RTP is at port 212.9.44.253:15550
sip_route_dump: route/path hop: <sip:217.10.68.150;lr;ftag=as65bc91b0>
sip_route_dump: route/path hop: <sip:172.20.40.8;lr>
set_destination: Parsing <sip:217.10.68.150;lr;ftag=as65bc91b0> for address/port to send to
set_destination: set destination to 217.10.68.150:5060
Transmitting (no NAT) to 217.10.68.150:5060:
ACK sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:5060;branch=z9hG4bK12463de5
Route: <sip:217.10.68.150;lr;ftag=as65bc91b0>,<sip:172.20.40.8;lr>
Max-Forwards: 70
From: "CALLER" <sip:[email protected]>;tag=as65bc91b0
To: <sip:[email protected]:5060>;tag=as21618100
Contact: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 103 ACK
User-Agent: Asterisk PBX 16.2.1~dfsg-1+deb10u1
Content-Length: 0
---
-- SIP/sipconnect.sipgate.de-00000003 answered IAX2/iaxmodem-7708
-- Channel SIP/sipconnect.sipgate.de-00000003 joined 'simple_bridge' basic-bridge <262f871a-8fc7-4bb9-a64b-981378a84acd>
-- Channel IAX2/iaxmodem-7708 joined 'simple_bridge' basic-bridge <262f871a-8fc7-4bb9-a64b-981378a84acd>
> 0x7f4634015640 -- Strict RTP switching to RTP target address 212.9.44.253:15550 as source
<--- SIP read from UDP:217.10.68.150:5060 --->
<------------->
<--- SIP read from UDP:217.10.68.150:5060 --->
BYE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 217.10.68.150;branch=z9hG4bKd711.674d11475dd9179e68c4eb52c2088642.0
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bKd711.39ae43c7fc3d82443eba26f3d75b5f39.0
Via: SIP/2.0/UDP 217.116.117.70:5060;branch=z9hG4bK5d2cbd05
Max-Forwards: 68
From: <sip:[email protected]:5060>;tag=as21618100
To: "CALLER" <sip:[email protected]>;tag=as65bc91b0
Call-ID: [email protected]
CSeq: 102 BYE
Reason: Q.850;cause=16
Content-Length: 0
X-hint: rr-enforced
<------------->
--- (12 headers 0 lines) ---
Sending to 217.10.68.150:5060 (no NAT)
Scheduling destruction of SIP dialog '[email protected]' in 6400 ms (Method: BYE)
<--- Transmitting (no NAT) to 217.10.68.150:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 217.10.68.150;branch=z9hG4bKd711.674d11475dd9179e68c4eb52c2088642.0;received=217.10.68.150
Via: SIP/2.0/UDP 172.20.40.8;branch=z9hG4bKd711.39ae43c7fc3d82443eba26f3d75b5f39.0
Via: SIP/2.0/UDP 217.116.117.70:5060;branch=z9hG4bK5d2cbd05
From: <sip:[email protected]:5060>;tag=as21618100
To: "CALLER" <sip:[email protected]>;tag=as65bc91b0
Call-ID: [email protected]
CSeq: 102 BYE
Server: Asterisk PBX 16.2.1~dfsg-1+deb10u1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0
<------------>
-- Channel SIP/sipconnect.sipgate.de-00000003 left 'simple_bridge' basic-bridge <262f871a-8fc7-4bb9-a64b-981378a84acd>
-- Channel IAX2/iaxmodem-7708 left 'simple_bridge' basic-bridge <262f871a-8fc7-4bb9-a64b-981378a84acd>
== Spawn extension (fax_out, RECIPIENT, 4) exited non-zero on 'IAX2/iaxmodem-7708'
-- Hungup 'IAX2/iaxmodem-7708'
Really destroying SIP dialog '[email protected]' Method: BYE
在/var/spool/hylafax/log/xferfaxlog
:
10/21/19 15:38 SEND 000000096 ttyIAX0 41 "" [email protected] "RECIPIENT" "" 2220072 0 0:00:03 0:00:00 "No carrier detected" "" "" "" "root" "00 00 00"
(我在這裡替換了寄件者/收件者號碼和使用者名稱)
防火牆目前未運作:
root@asterisk:/etc/asterisk# iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
這是我的星號配置:
在/etc/asterisk/sip.conf
:
[general]
context=unauthenticated
bindport=5060
bindaddr=0.0.0.0
realm=domain.tld
externhost=domain.tld:5060
localnet=127.0.0.0/255.255.255.0
nat=no
srvlookup=yes
allowguest=no
alwaysauthreject=yes
register => USER:[email protected]/USER
[sipconnect.sipgate.de]
type=peer
host=sipconnect.sipgate.de
outboundproxy=sipconnect.sipgate.de
port=5060
username=USER
defaultuser=USER
fromuser=USER
fromdomain=sipconnect.sipgate.de
secret=PASS
dtmfmode=rfc2833
insecure=port,invite
canreinvite=no
directmedia=no
registertimeout=600
sendrpid=pai
usereqphone=no
t38pt_udptl=no
disallow=all
allow=alaw
allow=ulaw
qualify=yes
context=unauthenticated
(我在這裡替換了憑證和網域)
在/etc/asterisk/extensions.conf
:
[general]
[sipgate_in]
exten => sipgate_in,1,Goto(siptrunk,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)
[siptrunk]
exten => 1234567,1,Dial(IAX2/iaxmodem)
exten => 1234567,n,Hangup
[fax_out]
exten => _X.,1,Set(CALLERID(num)=00491231234567)
exten => _X.,n,Set(CALLERID(name)=${CALLERID(num)})
exten => _X.,n,SipAddHeader(P-Preferred-Identity:<sip:${CALLERID(num)}>)
exten => _X.,n,Dial(SIP/sipconnect.sipgate.de/${EXTEN},,r)
[unauthenticated]
(我在這裡替換了寄件者號碼)
在/etc/asterisk/iax.conf
:
[general]
bindport=4569
bindaddr=127.0.0.1
calltokenoptional=127.0.0.1/255.255.255.0
[iaxmodem]
port=4570
type=friend
host=dynamic
qualify=yes
secret=pwd
requirecalltoken=no
disallow=all
allow=alaw
jitterbuffer=no
trunk=no
context=fax_out
(我在這裡替換了憑證)
在/etc/iaxmodem/ttyIAX0
:
device /dev/ttyIAX0
owner uucp:uucp
mode 660
port 4570
refresh 60
server 127.0.0.1
peername iaxmodem
secret pwd
codec alaw
nojitterbuffer
(我在這裡替換了憑證)
IAXModemttyIAX0
註冊成功,Asterisk 在 sipgate 主幹線上。從已知工作設定成功傳送傳真至收件人。之前我收到了一些網路協定錯誤,但由於我在測試期間沒有啟動防火牆,這些錯誤來自於某些嘗試註冊為設備等...
接收方運行的 3CX 不使用 T.38,因此我也在配置中停用了 T.38,只是為了確保 T.38 不是問題所在。
據我了解,調試輸出表明目標設備在發送傳真之前掛起。我這樣看對嗎?有人知道為什麼溝通會這樣?我怎麼才能找到提早掛斷的原因?
更新:我現在可以傳送傳真給另一個目標號碼。也許我做的一切都是對的,但 3CX 傳真卻出現了問題。但我仍然不確定調試協議 - 在這種情況下看起來應該如此嗎?
更新2:T.38 回退已在目標 3CX 上啟用,現在它從我的 Asterisk PBX 接收傳真。我不太了解 3CX 配置,也不知道「後備」意味著什麼 - 但是,它現在可以工作了。我仍然很好奇如何才能找到早期掛斷的原因 - 也許根本不可能。我希望我的配置現在適合現實生活...
答案1
現在透過 SIP 偵錯,我發現您有單向音訊問題(您一側的 RTP 發送您的本機主機 IP)。嘗試啟用nat=yes
此中繼sipconnect.sipgate.de
。在 SIP 偵錯中,您應該看到為 RDP 發送的公共 IP:c=IN IP4 127.0.1.1
應該是:c=IN IP4 your.public.ip.address
。
對於您的 IP 受到攻擊,我建議您啟用防火牆並僅允許來自您的 SIP 連接埠的流量sipconnect.sipgate.de
(通常,提供者會為您提供 IP 清單或範圍),而不是更改預設連接埠。