DHCP daemon ( ubuntu 20 )
We beginnen met het opzetten van een testomgeving:
- 1 ubuntu20.04 met 2 netwerkkaarten: 1 kaart op NAT via DHCP // 1 kaart op intnet op 192.168.10.11/24
- 1 w2k-client op intnet
- netwerk
Het is nuttig de server eerst op te starten met slechts 1 netwerkkaart op NAT en die in te stellen als dhcp-client
Daarna pas testen op de tweede netwerkkaart,
ik zet die op 192.168.10.11/24:
user@ubu20-04-001:~$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity' network: ethernets: enp0s3: dhcp4: true enp0s8: addresses: - 192.168.10.11/24 version: 2
ik herstart het netwerk:
user@ubu204-dhcp:~$
sudo netplan apply
Vervolgens controlleer ik metifconfig
:user@deb-91-dhcp:~$ ifconfig enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe80::a00:27ff:fecc:edd0 prefixlen 64 scopeid 0x20<link> ether 08:00:27:cc:ed:d0 txqueuelen 1000 (Ethernet) RX packets 3613 bytes 2005449 (1.9 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2821 bytes 343108 (335.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.11 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::a00:27ff:fe20:d5d5 prefixlen 64 scopeid 0x20<link> ether 08:00:27:20:d5:d5 txqueuelen 1000 (Ethernet) RX packets 156 bytes 25247 (24.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 43 bytes 5640 (5.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- Installatie van dhcp-server:
sudo apt-get install isc-dhcp-server
- configuratie van de netwerkkaart in dhcp-server:
/etc/default/isc-dhcp-server
. . . # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="enp0s8"
- een minimum configuratie van de dhcp-server
user@deb-91-dhcp:~$
cat /etc/dhcp/dhcpd.conf
:default-lease-time 600; max-lease-time 7200; subnet 192.168.10.0 netmask 255.255.255.0 { }
- dhcp-server herstarten:
user@deb-91-dhcp:~$
sudo systemctl restart isc-dhcp-server.service
$ sudo systemctl restart isc-dhcp-server.service Job for isc-dhcp-server.service failed. See 'systemctl status isc-dhcp-server.service' and 'journalctl -xn' for details.
metsudo less /var/log/syslog
zie je wat er echt fout gegaan is >>> scrollen (of end toets) tot einde syslog.May 31 23:38:52 deb84 isc-dhcp-server[1600]: The error was: May 31 23:38:52 deb84 dhcpd: Internet Systems Consortium DHCP Server 4.3.1 May 31 23:38:52 deb84 isc-dhcp-server[1600]: Internet Systems Consortium DHCP Server 4.3.1 May 31 23:38:52 deb84 dhcpd: Copyright 2004-2014 Internet Systems Consortium. May 31 23:38:52 deb84 isc-dhcp-server[1600]: Copyright 2004-2014 Internet Systems Consortium. May 31 23:38:52 deb84 dhcpd: All rights reserved. May 31 23:38:52 deb84 isc-dhcp-server[1600]: All rights reserved. May 31 23:38:52 deb84 dhcpd: For info, please visit https://www.isc.org/software/dhcp/ May 31 23:38:52 deb84 dhcpd: Config file: /etc/dhcp/dhcpd.conf May 31 23:38:52 deb84 dhcpd: Database file: /var/lib/dhcp/dhcpd.leases May 31 23:38:52 deb84 dhcpd: PID file: /var/run/dhcpd.pid May 31 23:38:52 deb84 dhcpd: /etc/dhcp/dhcpd.conf line 23: expecting a declaration May 31 23:38:52 deb84 dhcpd: }; May 31 23:38:52 deb84 dhcpd: ^ May 31 23:38:52 deb84 dhcpd: Configuration file errors encountered -- exiting
- status van de dhcp service:
user@deb-91-dhcp:~$
sudo systemctl status isc-dhcp-server.service
- configureren
Als je eindelijk een werkende dhcpd krijgt kun je de configuratie aanpassen tot bvb.:ddns-update-style none; option domain-name "example.org"; option domain-name-servers 10.28.100.20; option subnet-mask 255.255.0.0; default-lease-time 600; max-lease-time 7200; authoritative; log-facility local7; subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.101 192.168.10.200; }
- fixed IP op MAC-address
ddns-update-style none; option domain-name "example.org"; option domain-name-servers 10.28.100.20; option subnet-mask 255.255.0.0; default-lease-time 600; max-lease-time 7200; authoritative; log-facility local7; # # This is a very basic subnet declaration. # subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.101 192.168.10.200; # option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; ### STATIC IP LEASES ### # w2k dhcp2 MAC: 08-00-27-92-49-3F host w2k-dhcp2 { hardware ethernet 08:00:27:92:49:3F; fixed-address 192.168.10.201; } }
- leases controlleren
user@deb-91-dhcp:~$
tail -n 15 /var/lib/dhcp/dhcpd.leases
# authoring-byte-order entry is generated, DO NOT DELETE authoring-byte-order little-endian; lease 192.168.10.101 { starts 5 2018/02/23 12:33:08; ends 5 2018/02/23 12:43:08; cltt 5 2018/02/23 12:33:08; binding state active; next binding state free; rewind binding state free; hardware ethernet 08:00:27:6b:5e:d0; uid "\001\010\000'k^\320"; set vendor-class-identifier = "MSFT 5.0"; client-hostname "vbox-w2k"; }
- netwerk