Geen omschrijving

Stephen Fox 31f0e00106 Basic go module support. 6 jaren geleden
.travis c54b03d33a CI: linters and fixes 6 jaren geleden
cmds c54b03d33a CI: linters and fixes 6 jaren geleden
config 3fc2408960 dhcpv6: Joining multicast group offloaded to dhcp library 6 jaren geleden
handler 8092679242 Initial import 7 jaren geleden
logger 0f423ad80d Switched to logrus 7 jaren geleden
plugins 4b1e2c6c17 Added FIXME entries 6 jaren geleden
.gitignore 6d9a00f8a1 Moved main server and client packages under cmds/ (#6) 7 jaren geleden
.stickler.yml 1d2a09489b Adding .stickler.yml 7 jaren geleden
.travis.yml c54b03d33a CI: linters and fixes 6 jaren geleden
LICENSE a711f5f6d9 Initial commit 7 jaren geleden
README.md 8e02ef2261 README: added section on how to write plugins 7 jaren geleden
coredhcp.go d76cffab70 DHCPv6: handle relay-forw requests 6 jaren geleden
go.mod 31f0e00106 Basic go module support. 6 jaren geleden
go.sum 31f0e00106 Basic go module support. 6 jaren geleden

README.md

coredhcp

Build Status codecov Go Report Card

Fast, multithreaded, modular and extensible DHCP server written in Go

This is still a work-in-progress

Example configuration

In CoreDHCP almost everything is implemented as a plugin. The order of plugins in the configuration matters: every request is evaluated calling each plugin in order, until one breaks the evaluation and responds to, or drops, the request.

The following configuration runs a DHCPv6-only server, listening on all the interfaces, using a custom DUID-LL as server ID, and reading the leases from a text file.

server6:
    listen: '[::]:547'
    plugins:
        - server_id: LL 00:de:ad:be:ef:00
        - file: "leases.txt"
        # - dns: 8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844

#server4:
#    listen: '127.0.0.1:67'

See also config.yml.example.

Build and run

The server is located under cmds/coredhcp/, so enter that directory first.

Once you have a working configuration in config.yml (see config.yml.example), you can build and run the server:

$ cd cmds/coredhcp
$ go build
$ sudo ./coredhcp
INFO[2019-01-05T22:28:07Z] Registering plugin "file"
INFO[2019-01-05T22:28:07Z] Registering plugin "server_id"
INFO[2019-01-05T22:28:07Z] Loading configuration
INFO[2019-01-05T22:28:07Z] Found plugin: `server_id` with 2 args, `[LL 00:de:ad:be:ef:00]`
INFO[2019-01-05T22:28:07Z] Found plugin: `file` with 1 args, `[leases.txt]`
INFO[2019-01-05T22:28:07Z] Loading plugins...
INFO[2019-01-05T22:28:07Z] Loading plugin `server_id`
INFO[2019-01-05T22:28:07Z] plugins/server_id: loading `server_id` plugin
INFO[2019-01-05T22:28:07Z] plugins/server_id: using ll 00:de:ad:be:ef:00
INFO[2019-01-05T22:28:07Z] Loading plugin `file`
INFO[2019-01-05T22:28:07Z] plugins/file: reading leases from leases.txt
INFO[2019-01-05T22:28:07Z] plugins/file: loaded 1 leases from leases.txt
INFO[2019-01-05T22:28:07Z] Starting DHCPv6 listener on [::]:547
INFO[2019-01-05T22:28:07Z] Waiting
2019/01/05 22:28:07 Server listening on [::]:547
2019/01/05 22:28:07 Ready to handle requests
...

Then try it with the local test client, that is located under cmds/client/:

$ cd cmds/client
$ go build
$ sudo ./client
INFO[2019-01-05T22:29:21Z] &{ReadTimeout:3s WriteTimeout:3s LocalAddr:[::1]:546 RemoteAddr:[::1]:547}
INFO[2019-01-05T22:29:21Z] DHCPv6Message
  messageType=SOLICIT
  transactionid=0x6d30ff
  options=[
    OptClientId{cid=DUID{type=DUID-LLT hwtype=Ethernet hwaddr=00:11:22:33:44:55}}
    OptRequestedOption{options=[DNS Recursive Name Server, Domain Search List]}
    OptElapsedTime{elapsedtime=0}
    OptIANA{IAID=[250 206 176 12], t1=3600, t2=5400, options=[]}
  ]
...

How to write a plugin

CoreDHCP is heavily based on plugins: even the core functionalities are implemented as plugins. Therefore, knowing how to write one is the key to add new features to CoreDHCP.

The best way to learn is to read the comments and source code of the example plugin, which guides you through the implementation of a simple plugin that prints a packet every time it is received by the server.

Authors