I am running distro version 3.211.63-7 with Asterisk 1.8.21.0
My system is set to NOT allow Anonymous Inbound SIP Calls
but to allow SIP guests.
Looking at my logs I see thousands of attempts to break into the system, trying one sip extension variation after another.
Fail2ban is not blocking the IPs (I guess) because the Asterisk log does not show the incoming IP when receiving incoming SIP connections from an unknown peer
However a simple “SIP set debug on” command or “sip show channels”, shows the originating IP address.
Given that SIP security is important and a breach could be very expensive and given that the attackers IP is available to the system why can’t we block it automatically? I am not technical enough to do this but it appears to me that it should be possible to get the info and use it in fail2ban or some other application. I manually blocked the IP range and the attack stopped. Here are my findings.
<— Transmitting (NAT) to 83.170.84.47:5074 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 83.170.84.47:5074;branch=z9hG4bK-a1c25859cdd39128e084bf31113392f5;received=83.170.84.47;rport=5074
From: 3182sip:[email protected];tag=13aaaca0
To: 001441904891988sip:[email protected];tag=as0bd0f7d6
SIP SHOW CHANNELS
83.170.84.47 3197 122cee76f85f76c 0x0 (nothing) No Rx: BYE
83.170.84.47 3194 9a3d8e3234fe1d3 0x0 (nothing) No Rx: BYE
2013-04-14 19:44:35 1365983075.626 3134 Answer s (from-sip-external) ANSWERED 00:00
2013-04-14 19:44:25 1365983065.625 3133 Answer s (from-sip-external) ANSWERED 00:00
2013-04-14 19:44:14 1365983054.624 3132 Answer s (from-sip-external) ANSWERED 00:01
2013-04-14 19:44:04 1365983044.623 3131 Answer s (from-sip-external) ANSWERED 00:01
2013-04-14 19:43:53 1365983033.622 3130 Answer s (from-sip-external) ANSWERED 00:01
2013-04-14 19:43:43 1365983023.621 3129 Answer s (from-sip-external) ANSWERED 00:00
…
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [001441904891988@from-sip-external:1] NoOp(“SIP/xxx.xxx.xxx.xxx-00000243”, “Received incoming SIP connection from unknown peer to 001441904891988”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [001441904891988@from-sip-external:1] NoOp(“SIP/xxx.xxx.xxx.xxx-00000243”, “Received incoming SIP connection from unknown peer to 001441904891988”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [001441904891988@from-sip-external:2] Set(“SIP/xxx.xxx.xxx.xxx-00000243”, “DID=001441904891988”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [001441904891988@from-sip-external:2] Set(“SIP/xxx.xxx.xxx.xxx-00000243”, “DID=001441904891988”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [001441904891988@from-sip-external:3] Goto(“SIP/xxx.xxx.xxx.xxx-00000243”, “s,1”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [001441904891988@from-sip-external:3] Goto(“SIP/xxx.xxx.xxx.xxx-00000243”, “s,1”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Goto (from-sip-external,s,1)
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Goto (from-sip-external,s,1)
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [s@from-sip-external:1] GotoIf(“SIP/xxx.xxx.xxx.xxx-00000243”, “0?checklang:noanonymous”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [s@from-sip-external:1] GotoIf(“SIP/xxx.xxx.xxx.xxx-00000243”, “0?checklang:noanonymous”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Goto (from-sip-external,s,5)
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Goto (from-sip-external,s,5)
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [s@from-sip-external:5] Set(“SIP/xxx.xxx.xxx.xxx-00000243”, “TIMEOUT(absolute)=15”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] pbx.c: – Executing [s@from-sip-external:5] Set(“SIP/xxx.xxx.xxx.xxx-00000243”, “TIMEOUT(absolute)=15”) in new stack
[2013-04-14 19:36:33] VERBOSE[7332] func_timeout.c: Channel will hangup at 2013-04-14 19:36:48.814 EDT
…