Local DNS Server using DD-WRT | Buffalo Routers

August 13, 2017

A local DNS will help a developer to access and test the applications across local network having to worry about hostnames (Especially mobile devices, where updating host files may force one to root the devices)

This time we will see how a local DNS could be setup using relatively cheap WIFI routers running DD-WRT firmware

I am using a Buffalo router that acts as a WIFI access point at my home.

image

Make sure you are running the latest available firmware for the device to insure maximum stability. Once the firmware has been updated to the latest, Click on Services and you will be landed on Services page. Setting up the local DNS is most effective when you have all your “Computers” have static IP allocation (As seen with below image)

 

image

Don’t worry about the lease time parameters, as long your computers are having static IP addresses, these entries work as ‘A’ records, letting you to access the computers by their name, instead of IP addresses.

Set Used Domain as “LAN & WAN” & provide a meaningful name to “Lan Domain”. This name will be appended to your hostnames when you do a simple ping like commands. For example, when I try to ping “rajesh-pc” from command prompt, “rajesh-pc.my.home” will be automatically generated incase if you set up parameter “expand-hosts” with Additional DNSMasq options (Check below image)

 

 

image

Save the settings & apply. You are all set to start using the local DNS server. Whenever you have a new host, access the services page and create a static host entry (one time) & your last device is accessible using a name, instead of IP addresses.

 

Regards,

 


Batch file for FTP

April 5, 2017

Hi guys

We’ve a legacy application for our Bahrain operations and after a disastrous hardware failure we wanted to find a cost effective method to bring the database dumps to Kuwait for regular health checks.

Options in front of us were pretty limited. The business in Bahrain only had a basic internet connection(dial-up DSL) without static IP address, hence we were forced to workout something that is dependable. Finally we decided to FTP the dump file in compressed form after the dump export every Friday once after realizing that the total size of the compressed dump file was less than 100MB in size!

Here is the script file We’ve compiled after referring a number of blogs/tech forum visits. Please note, the methods we implement here uses passwords seen in clear text. Hence make sure that you take maximum attention while implementing our solution in your environments.

::http://blogs.msdn.com/b/oldnewthing/archive/2012/08/01/10334557.aspx
@echo off
SETLOCAL
::Get the latest dump file name, generated using exp command
for /f "tokens=*" %%a in ('dir *.dmp /o:-d /b') do set NEWEST=%%a&& goto :next

:next
REM echo The most recently created file is %NEWEST%
::http://stackoverflow.com/questions/15567809/batch-extract-path-and-filename-from-a-variable
FOR %%i IN ("%NEWEST%") DO (
REM ECHO filedrive=%%~di
REM ECHO filepath=%%~pi
SET ZIPNAME=%%~ni
REM ECHO fileextension=%%~xi
)

SET ZIPNAME=%ZIPNAME%.zip
::Creating ZIP file using Java Runtime
::Dump files could be huge and take hours to transfer in full size. So we will use Java RunTime Executable to create a zip file which
::Will be smaller in size
::Make sure you have JRE installed, and the installation path is set in the environment variables, if not call JRE using the full path
::eg: C:\java\jre
echo Creating Zip file for transfer, filename ""%ZIPNAME%""
::We will create the zip file without meta-info, hence the M switch is used
::jar -cfM %ZIPNAME% %NEWEST%
::Another option is to go with 7Zip, 3rd party utility that could create zip/7z files
::7z a %ZIPNAME% %NEWEST%
::Or using Windows built-in Zip utility
zip %ZIPNAME% %NEWEST%
::You can use IP address or fully qualified domain names for the FTP server
::If the FQDN is not registered, you can add an entry with your hosts file
::FTP accepts parameter files, ftp -s:parameter file, so we will create the parameter during the initial running
::Please note, the parameter file created is permanent & clear text format, hence make sure that adequate security measures are practiced
::to avoid getting sensitive details exposed.
echo open ftpservername(FQDN/IP)>ftp.txt
echo username>>ftp.txt
echo password>>ftp.txt
echo binary>>ftp.txt
echo put %ZIPNAME%>>ftp.txt
echo disconnect>>ftp.txt
echo quit>>ftp.txt

REM echo put filename2.dat >>ftp.txt
REM echo put filename3.dat >>ftp.txt
REM echo put filename4.dat >>ftp.txt
::We referred the following thread for making the batch file
::Google search keywords:  pass parameter to ftp script
::http://stackoverflow.com/questions/5170627/is-it-possible-to-pass-a-variable-into-a-windows-ftp-script-file

ftp -s:ftp.txt
::Delete the zip file after transfer comples
del %ZIPNAME%

::Optionally you can use "exit" the command windows-ftp-script-file
::Exit

and usually the ftp.txt should look like below

open ftp.myserver.com
username
password
binary
put exp_10032017.zip
disconnect
quit

regards,

rajesh


D-link routers affected by DNS hijacking

September 20, 2015

D-link is a trusted cost effective router solution for homes and small offices, especially in the regions where cable internet is still an unreachable reality. Recently I changed my home DSL router, from a Linksys X1000 to DSL-2750U (India specific) and was pretty happy to see that the device stood robust, without a single hangup after being online for weeks. Further, the firmware of the device provided much more tweaks compared to Linksys x1000.

However, almost a month and half back, I have noticed that my internet connection (4MBPS DSL) started getting a lot slower, websites unreachable due to DNS timeouts.

To my utter surprise, I found that the DNS settings with router were changed with a DNS server from Saudi Arabia (Primary) & Google DNS server 8.8.8.8 for the secondary. I changed the DNS to static and fed in KEMS Zajil corporate DNS server entries & found, sometimes within a day or other times after couple of days, the router is once again back to the “automatically” changed DNS server entries. This made me google about DNS hijacking, specific to D-link routers & here is what I came across

I contacted D-link support, instead of replying my query they forwarded me a link to download a firmware (patched? new?) , which I thought should be one with the fix. I had no troubles for almost 3 weeks. Once again, I started experiencing no internet at all or host not found errors! this time I knew where exactly to look & I found my router with compromised DNS entries

DNS Entries

Obviously, this particular router firmware comes with TR-069, disabled. I ain’t at all sure whether, it is being exploited. Anyway, this time I didn’t bother to contact D-link and download another “firmware”, instead I quickly dusted out my old Linksys x1000 router, and configured it as a modem router, thus limiting the load on the device, which caused frequent hanging while used as Modem Router+ DHCP Server +  WIFI access point combo.

So far so good, I keep on checking the status page of the router to make sure that the DNS entries are not manipulated by the ISP for some reasons, or hijacked by…

So if you are feeling your DSL connection has gone all slow or you are constantly getting timed out DNS errors, cross check your D-link router’s DNS entries page.

Regards,

for windows7bugs

rajesh