Kea DHCP

From Dave-Wiki
Revision as of 01:21, 2 March 2024 by Dave (talk | contribs) (→‎Leases)
Jump to navigation Jump to search

Links

ISC-Kea
https://kea.readthedocs.io/en/latest/arm/config.html
Stork
https://stork.readthedocs.io/en/v1.8.0/
https://gitlab.isc.org/isc-projects/stork/-/wikis/Screenshots

Leases

Leases are stored in memfile, by default. But you can also have them written to a CSV file:

 "lease-database": {
     "type": "memfile", // write leases to memfile...
     "persist": true,
     "name": "/tmp/kea-leases4.csv", // ...but also write them to csv
     "lfc-interval": 3600,
     "max-row-errors": 100
 },

MySQL Integration

To use host reservations from MySQL, you need to add the "hosts-database" section to the "Dhcp4" section of the config file. Subnet-Ids need to be defined in your subnet declarations, too.

IPv4 Reservations - Insert Statement

 START TRANSACTION;
 SET @ipv4_reservation='192.0.2.4';
 SET @hostname = 'myhost.example.org';
 SET @identifier_type='hw-address';
 SET @identifier_value='10:20:30:40:50:60';
 SET @dhcp4_subnet_id=1;
 SET @next_server='10.0.0.1';
 SET @server_hostname='server-name.example.org';
 SET @boot_file_name='bootfile.efi';
 
 INSERT INTO hosts (dhcp_identifier,
                    dhcp_identifier_type,
 		   dhcp4_subnet_id,
                    ipv4_address,
                    hostname,
                    dhcp4_next_server,
                    dhcp4_server_hostname,
                    dhcp4_boot_file_name)
 VALUES (UNHEX(REPLACE(@identifier_value, ':', )),
 	(SELECT type FROM host_identifier_type WHERE name=@identifier_type),
         @dhcp4_subnet_id,
         INET_ATON(@ipv4_reservation),
         @hostname,
         INET_ATON(@next_server),
         @server_hostname,
         @boot_file_name);
 
 COMMIT;


 SELECT host_id,dhcp_identifier,dhcp4_subnet_id,ipv4_address,hostname FROM hosts;
 
 START TRANSACTION;
 SET @ipv4_reservation='10.144.70.18';
 SET @hostname = 'blink-closet';
 SET @identifier_type='hw-address';
 SET @identifier_value='74:ab:93:03:4e:99';
 SET @dhcp4_subnet_id=70;
 
 INSERT INTO hosts (dhcp_identifier,
                    dhcp_identifier_type,
                    dhcp4_subnet_id,
                    ipv4_address,
                    hostname)
 VALUES (UNHEX(REPLACE(@identifier_value, ':', )),
 	(SELECT type FROM host_identifier_type WHERE name=@identifier_type),
         @dhcp4_subnet_id,
         INET_ATON(@ipv4_reservation),
         @hostname);
 
 COMMIT;

MySQL Performance Tuning

Configure in /etc/mysql/my.cnf:

[mysqld]
innodb_flush_log_at_trx_commit=2


Control-Agent Commands

[ { "arguments": [ "build-report", "config-backend-pull", "config-get", "config-reload", "config-set", "config-test", "config-write", "dhcp-disable", "dhcp-enable", "ha-continue", "ha-heartbeat", "ha-maintenance-cancel", "ha-maintenance-notify", "ha-maintenance-start", "ha-reset", "ha-scopes", "ha-sync", "ha-sync-complete-notify", "lease4-add", "lease4-del", "lease4-get", "lease4-get-all", "lease4-get-by-client-id", "lease4-get-by-hostname", "lease4-get-by-hw-address", "lease4-get-page", "lease4-resend-ddns", "lease4-update", "lease4-wipe", "lease6-add", "lease6-bulk-apply", "lease6-del", "lease6-get", "lease6-get-all", "lease6-get-by-duid", "lease6-get-by-hostname", "lease6-get-page", "lease6-resend-ddns", "lease6-update", "lease6-wipe", "leases-reclaim", "libreload", "list-commands", "server-tag-get", "shutdown", "statistic-get", "statistic-get-all", "statistic-remove", "statistic-remove-all", "statistic-reset", "statistic-reset-all", "statistic-sample-age-set", "statistic-sample-age-set-all", "statistic-sample-count-set", "statistic-sample-count-set-all", "status-get", "version-get" ], "result": 0 } ]