Thursday, August 25, 2016

DNSMASQ as internal DNS server with a PHP mangement page (GUI)





Environment

  • Apache as the web server. (In my server apache set to run in port 9000)
          PHP and SQLite DB files located at "/var/www/html/dnsmasq" and the same path set as the root directory.

         service accessed via http://server1/dnsmasq/login.php
  • login.php
  • admin.php - add/remove/modify host entries and update the DB
  • admin.db - user logins
  • db.php - DB connections
  • hosts.db - host entry DB
  • update.sh - updates the local hosts file when invoked from the PHP file
  • dnsmasq.conf - replace dnsmasq initial file with this
* make sure to grant dnsmasq service reload access to apache user in visudo
   # visudo
   -- add below entry
    apache  ALL = NOPASSWD: /etc/init.d/dnsmasq reload

* current user in admin.db is "admin", password is "password"
   to change the login or to add a user use below sql commands;
   
   change admin user password ---  sqlite3 admin.db "update logins set password='123456' where username='admin'"

   add a user --- sqlite3 admin.db "insert into logins (username,password) values ('admin','password')"