AdGuardHome/internal/dhcpd
Ainar Garipov bf4c256c72 Pull request: return 501 when we don't support features
Merge in DNS/adguard-home from 2295-dhcp-windows to master

Updates #2295.

Squashed commit of the following:

commit 3b00a90c3d9bc33e9af478e4062c0f938d4f327d
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Nov 16 16:45:43 2020 +0300

    all: use the 501 handlers instead of the real ones, revert other changes

commit 0a3b37736a21abd6181e0d28c32069e8d7a576d0
Merge: 45feba755 6358240e9
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Nov 16 15:59:15 2020 +0300

    Merge branch 'master' into 2295-dhcp-windows and update

commit 45feba755dde37e43cc8075b896e1576157341e6
Merge: cd987d8bc a19523b25
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Nov 16 15:51:16 2020 +0300

    Merge branch 'master' into 2295-dhcp-windows

commit cd987d8bc2cd524b7454d9037b595069714645f9
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Nov 13 15:55:23 2020 +0300

    all: improve tests and refactor dhcp checking code even more

commit 3aad675443f325b5909523bcc1c987aa04ac61d9
Merge: 70c477e61 09196118e
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Nov 13 14:44:43 2020 +0300

    Merge branch 'master' into 2295-dhcp-windows

commit 70c477e61cdc1237603918f1c44470c1549f1136
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Nov 13 14:34:06 2020 +0300

    home: fix dhcpd test on windows

commit e59597d783fb9304e63f94eee2b5a5d67a5b2169
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Nov 13 13:38:25 2020 +0300

    all: mention the feature in the changelog

commit 5555c8d881b1c20b5b0a0cb096a17cf56e209c06
Merge: c3b6a5a93 e802e6645
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Nov 13 13:35:35 2020 +0300

    Merge branch 'master' into 2295-dhcp-windows

commit c3b6a5a930693090838eb1ef9f75a09b5b223ba6
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Nov 12 20:37:09 2020 +0300

    util: fix comment

commit ed92dfdb5d3a6c4ba5d032cbe781e7fd87882813
Author: ArtemBaskal <asbaskal@miem.hse.ru>
Date:   Thu Nov 12 20:24:14 2020 +0300

    Adapt client

commit e6f0494c20a4ad5388492af9091568eea5c6e2d6
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Nov 12 13:35:25 2020 +0300

    return 501 when we don't support features
2020-11-16 19:01:12 +03:00
..
nclient4 Pull request: 2273 clean tests output 2020-11-16 15:52:05 +03:00
check_other_dhcp.go Pull request: return 501 when we don't support features 2020-11-16 19:01:12 +03:00
check_other_dhcp_windows.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
db.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
dhcpd.go Pull request: return 501 when we don't support features 2020-11-16 19:01:12 +03:00
dhcpd_test.go Pull request: 2273 clean tests output 2020-11-16 15:52:05 +03:00
dhcphttp.go Pull request: return 501 when we don't support features 2020-11-16 19:01:12 +03:00
dhcphttp_test.go Pull request: return 501 when we don't support features 2020-11-16 19:01:12 +03:00
helpers.go Pull request: * dhcpd: send secondary dns as well 2020-11-09 19:27:04 +03:00
network_utils.go Pull request: return 501 when we don't support features 2020-11-16 19:01:12 +03:00
network_utils_test.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
os_windows.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
README.md Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
router_adv.go Pull request:* all: remove github.com/joomcode/errorx dependency 2020-11-05 15:20:57 +03:00
router_adv_test.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
server.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
v4.go Pull request: * dhcpd: send secondary dns as well 2020-11-09 19:27:04 +03:00
v4_test.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
v6.go Pull request: * dhcpd: send secondary dns as well 2020-11-09 19:27:04 +03:00
v6_test.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00
v46_windows.go Pull request: * all: move internal Go packages to internal/ 2020-10-30 13:32:02 +03:00

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