AdGuardHome/internal/dhcpd
Eugene Burkov 39b404be19 cherry-pick: 4358 fix stats
Merge in DNS/adguard-home from 4358-fix-stats to master

Updates #4358.
Updates #4342.

Squashed commit of the following:

commit 5683cb304688ea639e5ba7f219a7bf12370211a4
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Aug 4 18:20:54 2022 +0300

    stats: rm races test

commit 63dd67650ed64eaf9685b955a4fdf3c0067a7f8c
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Aug 4 17:13:36 2022 +0300

    stats: try to imp test

commit 59a0f249fc00566872db62e362c87bc0c201b333
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Aug 4 16:38:57 2022 +0300

    stats: fix nil ptr deref

commit 7fc3ff18a34a1d0e0fec3ca83a33f499ac752572
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Apr 7 16:02:51 2022 +0300

    stats: fix races finally, imp tests

commit c63f5f4e7929819fe79b3a1e392f6b91cd630846
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Aug 4 00:56:49 2022 +0300

    aghhttp: add register func

commit 61adc7f0e95279c1b7f4a0c0af5ab387ee461411
Merge: edbdb2d4 9b3adac1
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Aug 4 00:36:01 2022 +0300

    Merge branch 'master' into 4358-fix-stats

commit edbdb2d4c6a06dcbf8107a28c4c3a61ba394e907
Merge: a91e4d7a a481ff4c
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Aug 3 21:00:42 2022 +0300

    Merge branch 'master' into 4358-fix-stats

commit a91e4d7af13591eeef45cb7980d1ebc1650a5cb7
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Aug 3 18:46:19 2022 +0300

    stats: imp code, docs

commit c5f3814c5c1a734ca8ff6726cc9ffc1177a055cf
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Aug 3 18:16:13 2022 +0300

    all: log changes

commit 5e6caafc771dddc4c6be07c34658de359106fbe5
Merge: 091ba756 eb8e8166
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Aug 3 18:09:10 2022 +0300

    Merge branch 'master' into 4358-fix-stats

commit 091ba75618d3689b9c04f05431283417c8cc52f9
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Aug 3 18:07:39 2022 +0300

    stats: imp docs, code

commit f2b2de77ce5f0448d6df9232a614a3710f1e2e8a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Aug 2 17:09:30 2022 +0300

    all: refactor stats & add mutexes

commit b3f11c455ceaa3738ec20eefc46f866ff36ed046
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Apr 27 15:30:09 2022 +0300

    WIP
2022-08-17 18:10:16 +03:00
..
README.md Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
bitset.go Pull request: dhcpd: imp static lease validation 2021-03-18 17:07:13 +03:00
bitset_test.go Pull request: dhcpd: imp static lease validation 2021-03-18 17:07:13 +03:00
broadcast_bsd.go Pull request: 3443 dhcp broadcast vol.2 2021-09-30 18:28:19 +03:00
broadcast_bsd_test.go Pull request: 3443 dhcp broadcast vol.2 2021-09-30 18:28:19 +03:00
broadcast_others.go Pull request: 3443 dhcp broadcast vol.2 2021-09-30 18:28:19 +03:00
broadcast_others_test.go Pull request: 3443 dhcp broadcast vol.2 2021-09-30 18:28:19 +03:00
conn_unix.go cherry-pick: upd-go 2022-08-03 16:01:02 +03:00
conn_unix_test.go cherry-pick: upd-go 2022-08-03 16:01:02 +03:00
db.go Pull request: dhcpd: add purge, imp code 2021-06-16 16:48:46 +03:00
dhcpd.go cherry-pick: 4358 fix stats 2022-08-17 18:10:16 +03:00
dhcpd_test.go all: sync more 2022-06-02 17:55:48 +03:00
helpers.go Pull request: 3225 bsd dhcp 2021-08-12 17:33:53 +03:00
http.go cherry-pick: 4698 Gateway IP in DHCP Lease 2022-07-13 15:14:32 +03:00
http_test.go Pull request: use testutil 2021-10-22 11:58:18 +03:00
iprange.go cherry-pick: filtering: fix rw to subdomain 2021-12-29 16:02:04 +03:00
iprange_test.go Pull request: use testutil 2021-10-22 11:58:18 +03:00
options_unix.go all: upd chlog, minimize diff to master 2022-01-28 17:44:10 +03:00
options_unix_test.go Pull request: use testutil 2021-10-22 11:58:18 +03:00
os_windows.go Pull request: all: imp build tags 2021-06-15 19:42:41 +03:00
routeradv.go Pull request: all: mv some utilities to netutil 2021-08-09 16:03:37 +03:00
routeradv_test.go Pull request: dhcpd: do not assume mac addrs of 6 bytes 2021-03-31 12:36:57 +03:00
server.go all: upd chlog, minimize diff to master 2022-01-28 17:44:10 +03:00
v4.go cherry-pick: upd-go 2022-08-03 16:01:02 +03:00
v4_test.go cherry-pick: upd-go 2022-08-03 16:01:02 +03:00
v6.go cherry-pick: all: opt log levels more 2021-12-29 16:03:23 +03:00
v6_test.go Pull request: dhcpd: add purge, imp code 2021-06-16 16:48:46 +03:00
v46.go Pull request: 3225 bsd dhcp 2021-08-12 17:33:53 +03:00
v46_windows.go Pull request: dhcpd: add purge, imp code 2021-06-16 16:48:46 +03:00

README.md

DHCP server

Contents:

Test setup with Virtual Box

To set up a test environment for DHCP server you need:

  • Linux host machine
  • Virtual Box
  • Virtual machine (guest OS doesn't matter)

Configure client

  1. Install Virtual Box and run the following command to create a Host-Only network:

     $ VBoxManage hostonlyif create
    

    You can check its status by ip a command.

    You can also set up Host-Only network using Virtual Box menu:

     File -> Host Network Manager...
    
  2. Create your virtual machine and set up its network:

     VM Settings -> Network -> Host-only Adapter
    
  3. Start your VM, install an OS. Configure your network interface to use DHCP and the OS should ask for a IP address from our DHCP server.

  4. To see the current IP address on client OS you can use ip a command on Linux or ipconfig on Windows.

  5. To force the client OS to request an IP from DHCP server again, you can use dhclient on Linux or ipconfig /release on Windows.

Configure server

  1. Edit server configuration file 'AdGuardHome.yaml', for example:

     dhcp:
       enabled: true
       interface_name: vboxnet0
       dhcpv4:
         gateway_ip: 192.168.56.1
         subnet_mask: 255.255.255.0
         range_start: 192.168.56.2
         range_end: 192.168.56.2
         lease_duration: 86400
         icmp_timeout_msec: 1000
         options: []
       dhcpv6:
         range_start: 2001::1
         lease_duration: 86400
         ra_slaac_only: false
         ra_allow_slaac: false
    
  2. Start the server

     ./AdGuardHome
    

    There should be a message in log which shows that DHCP server is ready:

     [info] DHCP: listening on 0.0.0.0:67