Walker News

How To Record Wireless Router Connection Log?

The trick to log wireless connection of router modem can be useful in securing WLAN, as the WIFI activities log allows network administrator (or broadband owner) to detect WIFI connection initiated from unknown clients or devices.

With that in mind, I developed a simple Windows-Bash shell script and run it repeatedly by Windows Task Scheduler to log WIFI connection activities on the D-LINK router modem.

For those who are using Linux, I think you will get the idea on how to do it after reading this post. For those who are using Windows (in my case, it is Windows 7 Ultimate x64-bit), you need the following to proceed:
  • The D-LINK DSL-2640T Wireless ADSL Router modem. Although most router modems are running on Linux, there might be some differences on display wireless connection in the router. For my DSL-2640T, the Linux command used to check WLAN connection status is:
    cat /proc/wlan/mgmt/staStatistics

    If you are kind to share, please leave a comment about the command for checking wireless connection in your router modem, if it is different than mine. Please specify the brand, model, and probably the firmware version too.
  • win-bash, the portable GNU bash shell for Microsoft Windows without relying on cygwin library or any other non-standard DLL and does not need any registry variables to run properly (even working fine on my Windows 7 Ultimate x64-bit).
  • plink, the open source SSH client for Windows command line.
  • CoreUtils for Windows (download the binaries zip file) – the script requires date, wc, and tail program to run properly.

Trick to generate wireless ADSL router modem connection log

1) Create folder in C:\ drive to keep the GNU utilities, e.g. C:\GNUTool

2) Download and keep the win-bash.exe, Putty (plink.exe) and GNU CoreUtils for Windows (wc.exe, tail.exe, date.exe) in C:\GNUTool

3) Copy the following Windows-Bash shell script code to Notepad, change the text in red accordingly (to suit your case) and save it as WifiChk.sh in C:\GNUTool folder:
  • Be careful when changing the Windows path, if necessary, as the path must use / (slash) and not the \ (backslash) when use in the Windows-Bash shell script.
  • The Windows-Bash shell script is case-sensitive, i.e. “A” is not equal to “a”.
RouterCmd="cat /proc/wlan/mgmt/staStatistics"


TDate=`$GNUPath/date +"%d-%m-%y %H:%M:%S"`
WIFICnt=`$GNUPath/plink -l $RouterID -pw $RouterPasswd $RouterIP "$RouterCmd" | $GNUPath/wc -l`

if [ $RecCnt -ne 0 ]
	OutRes=$TDate" :: "`$GNUPath/plink -l $RouterID -pw $RouterPasswd $RouterIP "$RouterCmd" | $GNUPath/tail -$RecCnt`
	echo $OutRes >> $WifiLog

4) Setup Windows Task Scheduler to run the WifiChk.sh by win-bash.exe repeatedly, as this:
C:\GNUTool\win-bash.exe C:\GNUTool\WifiChk.sh

The trick to record router modem wireless connection for securing WLAN network.

In my setup, the WifiChk.sh script is executed every 15 minutes, at every hour, 24×7, and it doesn’t impair the router performance as well as broadband Internet experience.

Custom Search

  1. Walker 28-04-10@12:11

    In addition, the SSH service must be turned on in the router modem and allowed connection from your computer.

    While the D-LINK DSL-2640T Wireless ADSL router modem supports SSH, not every brands / models support this feature, I bet.

2014  •  Privacy Policy