node-dhcp
node-dhcp copied to clipboard
Big Fork.
Hi, Thank for this project.
I'm trying to replace my ugly dnsmask configuration + nodejs front, by an pure nodejs solution. I forked your source for some changes, but I make a loooooooot of changes. the final version should be a kind of pure typescript router (PAC + http-proxy + dhcp + dynamic public IP switch + live http blocking features)
on the dhcp server the change include:
- Use async hook, so can use an external database to store lease.
- Static lease are now reserved.
- New free lease detection algorithm.
- Project converted to Typescript.
- Refactor configuration model.
- Datastorage can be share and fill by an external live interface.
- remove auto remove oldest lease.
- Properly handle Offered lease as non validated lease (that expire within a couples of seconds)
- Implement DHCPRELEASE
- Implement DHCP renew
- Speed improvement
- Add Tag support (allow tagging Lease to add common options)
I think that this fork solve 3 of the current opened issue.
- #2
- #4
- #25
special:
- #33 I handle this case in production
Maybe we will be able to merge one day, but you will have to switch to typescript.
I plane to deploy a first version next week.
https://github.com/UrielCh/node-dhcp
give me your feedback
Hi,
thanks for your ping! Your changes look impressive! The time when I started this project, async code was not a thing. So I'm totally in favor of going a step forward.
I have to test your fork and look into the code in greater detail. But all your improvements are long-awaited and I would look forward integrating these features :) Did you make any cuts in terms of generalizability, which were only useful for your very use-case?
What would be your idea of integrating your fork into the main branch? Can it be seen as a full replacement? If not, would you like to work with me together on bringing these features into the main branch?
Robert
Why are you using a dual licence ? a mix of 2 open licence is unusual.
I chose a dual license to match different requirements. Practically, it's MIT, but to embed it into an environment where GPL is used, you can use the GPL part.
Broken here when try test:
`Error: Cannot find module 'debounce'
Require stack:
- /lib/leaseStore/LeaseStoreFile.js
`
or?
extract from package.json:
"dependencies": {
"debounce": "^1.2.0",
"fs-extra": "^8.1.0",
"minimist": "*"
}
debonce is here, so maybe you should make a new npm install.
I have just finish my heavy refactor.
Leases are now completely new, and leaseStatic support tags, like dnsmask.
anyone know how works Options id 150 151 159 160 ? 100 101 120 132 133 ? I do not knows they types. I can not find they configuration name.
I use this page to find some data: https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
But some optionId are vendor dependent ...
some more change and this project will be able to compete old school classic DHCP server.
I see it had still some typo but now got running. Tried with WinXP laptop and it has still failure to give correct DHCP Offer message so it fails.
Okey, you should wait some days, to let me finish my devs.
Sure! Sorry and thanks.
I have just setup the dhcp server, but It do not receved any discover multicast message. How to be shure that the server listen to the proper network interface (I have 6 ethernet port on my server)
the mail UDP socket is initialied with:
const socket = createSocket({ type: "udp4", reuseAddr: true });
but there is no reference to an interface name.
I make all my developpement on a windows host, the production is is an ubuntu server.
As far as i know there is no specific interface and you need manually setup IP for that Ethernet port (i mean IP, netmask 255.255.255.0 or same you congifured in config, and router IP).
IP and router IP need be same and same on config file for server.
It listens 0.0.0.0 as to get messages which means all IPv4 messages on host machine... When i originally loaded project there was broken broadcast address which was not passed correctly to dhcp.js file which too made it not working.
And if you try pass via config file ip with assigned mac address it is broken still by this day until mac styling is fixed to be same on everywhere on project (including hard coded test files which uses hyphen styling for not any specific reason as far as i know as linux supports colons too).
If I bind socket 10.5.0.1, I do not receive any DHCP Discover. If I bind socket 10.5.255.255, I do not receive any DHCP Discover.
Update: If I bind socket 0.0.0.0, I receive all DHCP Discover....
My set is:
-
enp1s0 => local IP 10.5.0.1 network 10.5.0.0/16 gateway None
-
enp2s0 => Internet service provider 1: (xDsl) IP 10.12.0.3 network 10.12.0.0/16 gateway 10.12.0.1
-
enp3s0 => Internet service provider 2: (coaxial operator) IP 192.168.1.225 network 192.168.1.254/24 gateway 192.168.1.1
-
enp4s0 => Internet service provider 3: not setup yet (will be 4G)
-
enp5s0 => Internet service provider 4: not setup yet (Will be fiber)
-
enp6s0 => Internet service provider 5: not setup yet (will be an other xDSL)
But I only want to reply to DHCP on enp1s0. So... maybe I can try to guess the incomming interface for each UDP, in the last case I will filter that with an IPtables.
an Idea ?
update it's not multicast but broadcast. in nodeJs doc only multicast have call to specified an interface
socket.setBroadcast(true); should be the only needed call but it do not work's
to continue my test I use an basic iptables:
iptables -I INPUT -p udp --dport 67 -i '!enp1s0' -j DROP
Hi, I found some time to resume my fork, the news:
- This server do not support binding a single interface, the issue #37 had never been implemented.
- I have start a rebuild an ReactJS Backoffice ton configure the dhcp + HTTP Proxy + routing interface.
Any chances you will get this work completed and maybe make an npm package from it?
I need a to bind an UDP pour on a specific interface. I tried with an iptables, but that a nightmare using this way.
I wish deno will support interface binding, so I will move to it.
for now I'm stuck.
@UrielCh You can use the setsockopt call for that on Unix-like systems, not sure about Windows.
Check out this stackoverflow thread and this package.
Thx for the link,
But for now, I'm switching from NodeJS to Deno, So can not check that.