vyos-1x icon indicating copy to clipboard operation
vyos-1x copied to clipboard

T6068: dhcp-server: add split option to dhcp-server configuration.

Open nicolas-fort opened this issue 11 months ago • 1 comments

Change Summary

Add split option to dhcp-server configuration.This adds the hability to the user to specify load balancing towards dhcp servers defined in failover.

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Code style update (formatting, renaming)
  • [ ] Refactoring (no functional changes)
  • [ ] Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • [ ] Other (please describe):

Related Task(s)

https://vyos.dev/T6068

Related PR(s)

Component(s) name

dhcp-server

Proposed changes

How to test

Config

set service dhcp-server failover name 'TEST'
set service dhcp-server failover remote '198.51.100.2'
set service dhcp-server failover source-address '198.51.100.1'
set service dhcp-server failover split '256'
set service dhcp-server failover status 'primary'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 default-router '198.51.100.1'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 enable-failover
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 name-server '8.8.8.8'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 range 0 start '198.51.100.101'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 range 0 stop '198.51.100.200'

Config file:

cat /run/dhcp-server/dhcpd.conf
...
failover peer "TEST" {
    primary;
    mclt 1800;
    split 256;
    address 198.51.100.1;
    port 647;
    peer address 198.51.100.2;
    peer port 647;
    max-response-delay 30;
    max-unacked-updates 10;
    load balance max seconds 3;
}
..

And error check if setting it to server secondary dhcp-server:

vyos@dhcp-sag-main# run show config comm | grep failover
set service dhcp-server failover name 'TEST'
set service dhcp-server failover remote '198.51.100.2'
set service dhcp-server failover source-address '198.51.100.1'
set service dhcp-server failover status 'secondary'
set service dhcp-server shared-network-name LAN subnet 198.51.100.0/24 enable-failover
[edit]
vyos@dhcp-sag-main# set service dhcp-server failover split 123
[edit]
vyos@dhcp-sag-main# commit

DHCP failover split parameter can only be used if status is primary

[[service dhcp-server]] failed
Commit failed
[edit]
vyos@dhcp-sag-main# 

Smoketest result

root@dhcp-sag-main:/usr/libexec/vyos/tests/smoke/cli# ./test_service_dhcp-server.py                                                   

test_dhcp_exclude_in_range (__main__.TestServiceDHCPServer.test_dhcp_exclude_in_range) ... ok
test_dhcp_exclude_not_in_range (__main__.TestServiceDHCPServer.test_dhcp_exclude_not_in_range) ... ok
test_dhcp_failover (__main__.TestServiceDHCPServer.test_dhcp_failover) ... 
No DHCP address range or active static-mapping configured within shared-
network "FAILOVER, 192.0.2.0/25"!


DHCP failover must be enabled for at least one subnet!

ok
test_dhcp_failover_split (__main__.TestServiceDHCPServer.test_dhcp_failover_split) ... ok
test_dhcp_invalid_raw_options (__main__.TestServiceDHCPServer.test_dhcp_invalid_raw_options) ... 
DEPRECATION WARNING: Additional global parameters are subject of
removal in VyOS 1.5! Please raise a feature request for proper CLI
nodes!


Configuration file errors encountered - check your options!

ok
test_dhcp_multiple_pools (__main__.TestServiceDHCPServer.test_dhcp_multiple_pools) ... ok
test_dhcp_relay_server (__main__.TestServiceDHCPServer.test_dhcp_relay_server) ... ok
test_dhcp_single_pool_options (__main__.TestServiceDHCPServer.test_dhcp_single_pool_options) ... 
No DHCP address range or active static-mapping configured within shared-
network "SMOKE-0815, 192.0.2.0/25"!

ok
test_dhcp_single_pool_range (__main__.TestServiceDHCPServer.test_dhcp_single_pool_range) ... 
No DHCP address range or active static-mapping configured within shared-
network "SMOKE-1, 192.0.2.0/25"!

ok
test_dhcp_single_pool_static_mapping (__main__.TestServiceDHCPServer.test_dhcp_single_pool_static_mapping) ... 
No DHCP address range or active static-mapping configured within shared-
network "SMOKE-2, 192.0.2.0/25"!


Configured IP address for static mapping "dupe1" already exists on
another static mapping


Configured MAC address for static mapping "dupe2" already exists on
another static mapping

ok

----------------------------------------------------------------------
Ran 10 tests in 33.143s

OK
root@dhcp-sag-main:/usr/libexec/vyos/tests/smoke/cli# 

Checklist:

  • [x] I have read the CONTRIBUTING document
  • [x] I have linked this PR to one or more Phabricator Task(s)
  • [x] I have run the components SMOKETESTS if applicable
  • [x] My commit headlines contain a valid Task id
  • [x] My change requires a change to the documentation
  • [ ] I have updated the documentation accordingly

nicolas-fort avatar Mar 22 '24 14:03 nicolas-fort