dhcpd

NodeJS pagckage for managing DHCPD

Usage no npm install needed!

<script type="module">
  import dhcpd from 'https://cdn.skypack.dev/dhcpd';
</script>

README

dhcpd

Introduce

NodeJS pagckage for managing DHCPD

Installation

npm i --save dhcpd

!Important

Please notice this package will compile and install isc-dhcp(ver-4.4.2) to your machine(if no dhcpd binary found), therefore, make sure your compile tools' ready.

Simple Usage

Import the package
import {Dhcpd} from 'dhcpd'

or

const {Dhcpd} = require('dhcpd);
Setup DHCP server
//CIDR
const dhcpd = new Dhcpd({
    interface: 'en9',
    cidr: '172.0.0.1/24'
})
dhcpd.start().then(() => {
    console.log('DHCPD started')
}).catch(e => {
    console.error(e)
})
Or
const dhcpd = new Dhcpd({
    interface: 'en9',
    range: [
        "192.168.3.10", "192.168.3.99"
    ],
    static: [
        {
            hostname: 'host1',
            macAddress: 'xx:xx:xx:xx:xx:xx',
            ipAddress: '192.168.3.2'
        }
    ],
    network: '192.168.3.0',
    netmask: '255.255.255.0',
    router: '192.168.3.1',
    dns: ["8.8.8.8", "8.8.4.4"],
    broadcast: '192.168.3.255'
})
dhcpd.start().then(() => {
    console.log('DHCPD started')
}).catch(e => {
    console.error(e)
})

API

start()

(returns a promise) start the server

stop()

(returns a promise) stop the server

getInterface()

get DHCP service binding network interface

getRouter()

get router address

getNetMask()

get network mask

getNetwork()

get network address

getDNS()

get DNS address array

getBroadcast()

get broadcast address

License

MIT