Pages

Showing posts with label VoIP - Asterisk. Show all posts
Showing posts with label VoIP - Asterisk. Show all posts

Friday, September 15, 2023

Unban 1 IP - Gỡ IP ra khỏi fail2ban

Unban 1 IP

1. Kiểm tra IP có bị chặn không.

iptables -v -L -n



2. Gỡ IP ra khỏi danh sánh
fail2ban-client set  asterisk-cpbx unbanip 10.10.6.65



Tuesday, September 25, 2018

Cấu hình Linksys PAP2T




ATA Linksys PAP2T có 4 cổng và tương ứng với nó là 4 đèn báo hiệu trạng thái. Gồm có:
  • Cổng nguồn: Cắm dây nguồn để cung cấp điện ATA
  • Cổng Ethernet: Nối với dây cáp mạng dùng cho voice
  • Phone 1 và phone 2: Là nơi nối với 2 điện thoại analog sử dụng cho 2 điện thoại truyền thống ( phone 1 và phone 2 có thể hoạt động riêng biệt với nhau )

Monday, September 4, 2017

How to list all DND-enable extensions

List DND-enabled extensions

If the DND is set using the DND feature of the IP-Phone then there is no way you can list them. Otherwise, if it is set using FreePBX feature code (*78) then here is the way to do it:


in linux prompt run:
# asterisk -rx “database show DND” or
#asterisk -rx “database show” | grep “/DND/”
# asterisk -rx "database show DND"
/DND/1002                                         : YES
/DND/1004                                         : YES
/DND/1006                                         : YES
/DND/1007                                         : YES

To remove DND from an extension run:

# asterisk -rx “database del DND ext.”

Thursday, October 15, 2015

Kết nối Wireshark đến tổng đài VoIP Asterisk.

 Kết nối Wireshark đến tổng đài VoIP Asterisk.

plink.exe -ssh -pw abc123 root@192.168.2.1 "tcpdump -ni eth0 -s 0 -w - not port 22" | "C:\Program Files\Wireshark\Wireshark.exe" -k -i -

1. Download plink.exe
2. abc123: password Asterisk Server
3. root: user Asterisk
5. eth0: card network cần capture
4. 192.168.2.1: Địa chỉ IP Server

Thursday, January 8, 2015

Apache Error [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

One fine morning I have discovered that my Apache (httpd) service is down and can't be started :)

Step 1: Checking httpd Service Status:
#/etc/init.d/httpd status
httpd dead but pid file exists

Saturday, March 15, 2014

Simple shell script to block failed ssh attempts


It’s annoying having scripts and bots attempting to ssh into your pbx server. If you have proper passwords they don’t stand a chance of getting in, but it’s not satisfying to ignore them while they create load and clutter up your log files with failed login messages.
There are many tools out there to monitor and block IP addresses that repeatedly attempt to connect. My needs were:
  • low memory (memory is precious on a VPS)
  • simple
  • customizable
After wasting time installing various complicated python and perl scripts, I found a clever use of awk that counts matches in a log file and I put together this simple shell script:
scan-secure.sh
#!/bin/sh

# scan /var/log/secure for ssh attempts
# use iptables to block the bad guys

# Looking for attempts on existing and non-existing users. For example:
# Nov  2 22:44:07 pbxer sshd[28318]: Failed password for root from 74.143.42.70 port 52416 ssh2
# Nov  3 00:06:57 pbxer sshd[31767]: Failed password for invalid user mat3 from 192.203.145.200 port 35841 ssh2

tail -1000 /var/log/secure | awk '/sshd/ && /Failed password for/ { if (/invalid user/) try[$13]++; else try[$11]++; }
END { for (h in try) if (try[h] > 4) print h; }' |
while read ip
do
 # note: check if IP is already blocked...
 /sbin/iptables -L -n | grep $ip > /dev/null
 if [ $? -eq 0 ] ; then
  # echo "already denied ip: [$ip]" ;
  true 
 else
  # echo "Subject: denying ip: $ip" | /usr/sbin/sendmail notify@email.com
  logger -p authpriv.notice "*** Blocking SSH attempt from: $ip"
  /sbin/iptables -I INPUT -s $ip -j DROP
 fi
done

awk does all the magic. It grabs relevant lines, splits the lines into tokens, stores IP addresses in a hash and counts how many times they were seen, and finally outputs all IP addresses that were seen more than four times.
For the first few days, it’s interesting to receive an email when IP addresses are banned. Add your email and comment out that line.
Once you’re sure that the script is working how you’d like, you can add it to cron so that it runs every few minutes. I found that every two minutes works for me.
 
crontab -e
# scan the secure log every 2 minutes
*/2 * * * * /root/scan-secure.sh
 
After a few months you might find that the iptables are started to get cluttered.
iptables -L -n
You can clean them out by “flushing” them.
iptables -F
Now sleep tight knowing that people aren’t continually coming by to see if you locked your doors.

Wednesday, November 27, 2013

Configuring Sendmail to relay through Gmail SMTP

Sending email directly from the MTA (mail transfer agent) on one’s server is now considered to be faux pas. Unless you’ve got that machine configured within DNS (MX record, reverse lookup, etc), it’d likely fail most basic spam checks at the destination mail server. The complexity of the configuration increases if you’ve got the need to masquerade emails from multiple domains. Instead, the ideal approach is to relay through a central SMTP gateway for all of the outbound emails generated from your server(s).

I’ve been on Google mail hosting for a long time now and needed to configure my server to relay mail through it. Here’s a nice article that walks you through exactly what needs to be done to configure your sendmail MTA to relay through Gmail’s SMTP servers. Another similar post here.