Skip to content

the basic DHCP server that uses MongoDB to control device data.

Notifications You must be signed in to change notification settings

sajad-sadra/mongo-dhcp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mongo DHCP

The basic DHCP server is written in node js and saves user's data and configurations on the mongo database.

Deploy

Very easy:)

  • Expose port 67
  • Clone
git clone https://github.com/sajad-sadra/mongo-dhcp.git
  • Go to directory
cd mongo-dhcp/
npm start

Enviroments

Enviroment variables that use in the deploy procedure and placed in .env file.

Variable Description
DB URL of mongodb server
DB_LOG if it was no then logs just print in the console. if yes then logs also add to the database
SERVER local IP address of this DHCP server
ROUTER default gateway of local network
NETMASK subnet mask
BROADCAST local network broadcast IP address(same network part with broadcast host part-255-)
DNS1,DNS2 default nameservers(you can leave DNS2, blank)
LEASE default lease time

Database schema

Device

DHCP-server saves data and config of every device that connects to the network in this schema on MongoDB.

{
  MAC: String,
  IP: String,
  Name: String,
  Static: Boolean,
  ReserveTime: Number,
  Options: {
    DNS: Array,
    ExpireTime: Number,
    Router: String,
  },
}

If you change these properties in the database(for example with tools like mongoCompass) new value will applied for next request of device with no need to restart server.

Variable Description
MAC physical network address of device
IP IP-address that DHCP gave to this device
Name name or comment just to ٰdetect or search easily in documents (first time it's automatically generated according to day and time but you should edit it) )
Static if it is false the document will be removed after lease time ended, but if it istrue this document will never be removed automatically
ReserveTime code of time this document generated (don't change it)
DNS array of nameserver that must be passed to clients during DHCP-ack
Router network gateway that must be passed to client during DHCP-ack

Log

Every DHCP message that the device sends and server replies have been logged in this part with time and date (if environment DB_LOG=yes).

{
  Day: String,
  Time: String,
  Contex: String,
}

Day and Time variable getten from server system time and date.

About

the basic DHCP server that uses MongoDB to control device data.

Topics

Resources

Stars

Watchers

Forks