Repte 2.3:Configuració de xarxa dinàmica per clients des del DHCP
Primer vaig intentar fer la instal·lació de vim, ja que és l’editor que utilitzem, però hi havia un error amb el DNS que tenim predeterminat.
root@gateway-hector:/home/vagrant# apt-get install vim
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libgpm2 libsodium23 vim-runtime
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
libgpm2 libsodium23 vim vim-runtime
0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 8770 kB of archives.
After this operation, 41.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Ign:1 http://deb.debian.org/debian bookworm/main amd64 libgpm2 amd64 1.20.7-10+b1
Ign:2 http://deb.debian.org/debian bookworm/main amd64 libsodium23 amd64 1.0.18-1
Ign:3 http://deb.debian.org/debian bookworm/main amd64 vim-runtime all 2:9.0.1378-2+deb12u2
Ign:4 http://deb.debian.org/debian bookworm/main amd64 vim amd64 2:9.0.1378-2+deb12u2
Ign:1 http://deb.debian.org/debian bookworm/main amd64 libgpm2 amd64 1.20.7-10+b1
Ign:2 http://deb.debian.org/debian bookworm/main amd64 libsodium23 amd64 1.0.18-1
Ign:3 http://deb.debian.org/debian bookworm/main amd64 vim-runtime all 2:9.0.1378-2+deb12u2
Ign:4 http://deb.debian.org/debian bookworm/main amd64 vim amd64 2:9.0.1378-2+deb12u2
Ign:1 http://deb.debian.org/debian bookworm/main amd64 libgpm2 amd64 1.20.7-10+b1
Ign:2 http://deb.debian.org/debian bookworm/main amd64 libsodium23 amd64 1.0.18-1
Ign:3 http://deb.debian.org/debian bookworm/main amd64 vim-runtime all 2:9.0.1378-2+deb12u2
Ign:4 http://deb.debian.org/debian bookworm/main amd64 vim amd64 2:9.0.1378-2+deb12u2
Err:1 http://deb.debian.org/debian bookworm/main amd64 libgpm2 amd64 1.20.7-10+b1
Temporary failure resolving 'deb.debian.org'
Err:2 http://deb.debian.org/debian bookworm/main amd64 libsodium23 amd64 1.0.18-1
Temporary failure resolving 'deb.debian.org'
Err:3 http://deb.debian.org/debian bookworm/main amd64 vim-runtime all 2:9.0.1378-2+deb12u2
Temporary failure resolving 'deb.debian.org'
Err:4 http://deb.debian.org/debian bookworm/main amd64 vim amd64 2:9.0.1378-2+deb12u2
Temporary failure resolving 'deb.debian.org'
E: Failed to fetch http://deb.debian.org/debian/pool/main/g/gpm/libgpm2_1.20.7-10%2bb1_amd64.deb Temporary failure resolving 'deb.debian.org'
E: Failed to fetch http://deb.debian.org/debian/pool/main/libs/libsodium/libsodium23_1.0.18-1_amd64.deb Temporary failure resolving 'deb.debian.org'
E: Failed to fetch http://deb.debian.org/debian/pool/main/v/vim/vim-runtime_9.0.1378-2%2bdeb12u2_all.deb Temporary failure resolving 'deb.debian.org'
E: Failed to fetch http://deb.debian.org/debian/pool/main/v/vim/vim_9.0.1378-2%2bdeb12u2_amd64.deb Temporary failure resolving 'deb.debian.org'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Per solucionar el problema vaig entrar a l’arxie
Un cop solucionat ja pots començar a fer la instal·lació del dhcp i la configuració, per començar fem la instal·lació de dhcp.
root@gateway-hector:/home/vagrant# apt install isc-dhcp-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
policycoreutils selinux-utils
Suggested packages:
policykit-1 isc-dhcp-server-ldap ieee-data
The following NEW packages will be installed:
isc-dhcp-server policycoreutils selinux-utils
0 upgraded, 3 newly installed, 0 to remove and 28 not upgraded.
Need to get 1766 kB of archives.
After this operation, 7818 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://deb.debian.org/debian bookworm/main amd64 isc-dhcp-server amd64 4.4.3-P1-2 [1479 kB]
Get:2 http://deb.debian.org/debian bookworm/main amd64 selinux-utils amd64 3.4-1+b6 [126 kB]
Get:3 http://deb.debian.org/debian bookworm/main amd64 policycoreutils amd64 3.4-1 [161 kB]
Fetched 1766 kB in 0s (9654 kB/s)
apt-listchanges: Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_GB:en",
LC_ALL = (unset),
LC_MONETARY = "es_ES.UTF-8",
LC_ADDRESS = "es_ES.UTF-8",
LC_TELEPHONE = "es_ES.UTF-8",
LC_NAME = "es_ES.UTF-8",
LC_MEASUREMENT = "es_ES.UTF-8",
LC_IDENTIFICATION = "es_ES.UTF-8",
LC_NUMERIC = "es_ES.UTF-8",
LC_PAPER = "es_ES.UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_ALL to default locale: No such file or directory
Preconfiguring packages ...
Selecting previously unselected package isc-dhcp-server.
(Reading database ... 34391 files and directories currently installed.)
Preparing to unpack .../isc-dhcp-server_4.4.3-P1-2_amd64.deb ...
Unpacking isc-dhcp-server (4.4.3-P1-2) ...
Selecting previously unselected package selinux-utils.
Preparing to unpack .../selinux-utils_3.4-1+b6_amd64.deb ...
Unpacking selinux-utils (3.4-1+b6) ...
Selecting previously unselected package policycoreutils.
Preparing to unpack .../policycoreutils_3.4-1_amd64.deb ...
Unpacking policycoreutils (3.4-1) ...
Setting up selinux-utils (3.4-1+b6) ...
Setting up policycoreutils (3.4-1) ...
Setting up isc-dhcp-server (4.4.3-P1-2) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating /etc/default/isc-dhcp-server...
Job for isc-dhcp-server.service failed because the control process exited with error code.
See "systemctl status isc-dhcp-server.service" and "journalctl -xeu isc-dhcp-server.service" for details.
invoke-rc.d: initscript isc-dhcp-server, action "start" failed.
× isc-dhcp-server.service - LSB: DHCP server
Loaded: loaded (/etc/init.d/isc-dhcp-server; generated)
Active: failed (Result: exit-code) since Mon 2026-03-09 09:50:43 CET; 18ms ago
Docs: man:systemd-sysv-generator(8)
Process: 2097 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)
CPU: 38ms
Mar 09 09:50:41 gateway-hector dhcpd[2109]: bugs on either our web page at www.isc.org or in the README file
Mar 09 09:50:41 gateway-hector dhcpd[2109]: before submitting a bug. These pages explain the proper
Mar 09 09:50:41 gateway-hector dhcpd[2109]: process and the information we find helpful for debugging.
Mar 09 09:50:41 gateway-hector dhcpd[2109]:
Mar 09 09:50:41 gateway-hector dhcpd[2109]: exiting.
Mar 09 09:50:43 gateway-hector isc-dhcp-server[2097]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed!
Mar 09 09:50:43 gateway-hector isc-dhcp-server[2097]: failed!
Mar 09 09:50:43 gateway-hector systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Mar 09 09:50:43 gateway-hector systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Mar 09 09:50:43 gateway-hector systemd[1]: Failed to start isc-dhcp-server.service - LSB: DHCP server.
Processing triggers for man-db (2.11.2-2) ...
root@gateway-hector:/home/vagrant# systemctl restart isc-dhcp-server
Job for isc-dhcp-server.service failed because the control process exited with error code.
See "systemctl status isc-dhcp-server.service" and "journalctl -xeu isc-dhcp-server.service" for details.
root@gateway-hector:/home/vagrant# journalctl -xeu isc-dhcp-server.service
Mar 09 09:51:39 gateway-hector systemd[1]: Starting isc-dhcp-server.service - LSB: DHCP server...
░░ Subject: A start job for unit isc-dhcp-server.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit isc-dhcp-server.service has begun execution.
░░
░░ The job identifier is 1317.
Mar 09 09:51:39 gateway-hector isc-dhcp-server[2120]: Launching both IPv4 and IPv6 servers (please configure INTERFACES in /etc/default/isc-dhcp-server if you only want one or the other).
Mar 09 09:51:39 gateway-hector dhcpd[2132]: Wrote 0 leases to leases file.
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]: No subnet declaration for enp0s3 (10.0.2.15).
Mar 09 09:51:39 gateway-hector dhcpd[2132]: ** Ignoring requests on enp0s3. If this is not what
Mar 09 09:51:39 gateway-hector dhcpd[2132]: you want, please write a subnet declaration
Mar 09 09:51:39 gateway-hector dhcpd[2132]: in your dhcpd.conf file for the network segment
Mar 09 09:51:39 gateway-hector dhcpd[2132]: to which interface enp0s3 is attached. **
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]: No subnet declaration for enp0s9 (172.100.100.1).
Mar 09 09:51:39 gateway-hector dhcpd[2132]: ** Ignoring requests on enp0s9. If this is not what
Mar 09 09:51:39 gateway-hector dhcpd[2132]: you want, please write a subnet declaration
Mar 09 09:51:39 gateway-hector dhcpd[2132]: in your dhcpd.conf file for the network segment
Mar 09 09:51:39 gateway-hector dhcpd[2132]: to which interface enp0s9 is attached. **
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]: No subnet declaration for enp0s8 (172.25.202.12).
Mar 09 09:51:39 gateway-hector dhcpd[2132]: ** Ignoring requests on enp0s8. If this is not what
Mar 09 09:51:39 gateway-hector dhcpd[2132]: you want, please write a subnet declaration
Mar 09 09:51:39 gateway-hector dhcpd[2132]: in your dhcpd.conf file for the network segment
Mar 09 09:51:39 gateway-hector dhcpd[2132]: to which interface enp0s8 is attached. **
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]: Not configured to listen on any interfaces!
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]: If you think you have received this message due to a bug rather
Mar 09 09:51:39 gateway-hector dhcpd[2132]: than a configuration issue please read the section on submitting
Mar 09 09:51:39 gateway-hector dhcpd[2132]: bugs on either our web page at www.isc.org or in the README file
Mar 09 09:51:39 gateway-hector dhcpd[2132]: before submitting a bug. These pages explain the proper
Mar 09 09:51:39 gateway-hector dhcpd[2132]: process and the information we find helpful for debugging.
Mar 09 09:51:39 gateway-hector dhcpd[2132]:
Mar 09 09:51:39 gateway-hector dhcpd[2132]: exiting.
Mar 09 09:51:41 gateway-hector isc-dhcp-server[2120]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed!
Mar 09 09:51:41 gateway-hector isc-dhcp-server[2120]: failed!
Mar 09 09:51:41 gateway-hector systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ An ExecStart= process belonging to unit isc-dhcp-server.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Mar 09 09:51:41 gateway-hector systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit isc-dhcp-server.service has entered the 'failed' state with result 'exit-code'.
Mar 09 09:51:41 gateway-hector systemd[1]: Failed to start isc-dhcp-server.service - LSB: DHCP server.
░░ Subject: A start job for unit isc-dhcp-server.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit isc-dhcp-server.service has finished with a failure.
░░
Dona errors perquè amb la instal·lació fa un reinici, i t’ensenya els falls que hi troba, un cop això queda clar ja podem començar amb la configuració, per començar creem la targeta que estarà rebent les sol·licituds del dhcp.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug enp0s3
iface enp0s3 inet dhcp
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto enp0s8
iface enp0s8 inet static
address 172.25.202.12
netmask 255.255.0.0
gateway 172.25.130.254
dns-nameservers 172.25.130.254
#VAGRANT-END
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
auto enp0s9
iface enp0s9 inet manual
auto enp0s9.10
iface enp0s9.10 inet static
address 172.100.100.1
netmask 255.255.255.224
vlan-raw-device enp0s9 Un cop això queda fet ja podem fer un reinici del servei.
root@gateway-hector:/home/vagrant# sudo systemctl restart networking
root@gateway-hector:/home/vagrant#
Si has fet una bona configuració no hauria de passar res, s’hauria de veure així.
Ara ja podem passar a fer la configuració del dhcp, hem de crear les xarxes i els rangs en dinàmic.
root@gateway-hector:/home/vagrant# vim /etc/dhcp/dhcpd.conf
# NAT Vagrant - sin DHCP
subnet 10.0.2.0 netmask 255.255.255.0 {
}
# Red publica - sin DHCP
subnet 172.25.0.0 netmask 255.255.0.0 {
}
# Red interna - con DHCP activo
subnet 172.100.100.0 netmask 255.255.255.224 {
range 172.100.100.10 172.100.100.30;
option routers 172.100.100.1;
option domain-name-servers 172.25.130.254;
}
root@gateway-hector:/home/vagrant# vim /etc/default/isc-dhcp-server # Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid
# Additional options to start dhcpd with.
# Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="enp0s9.10"
INTERFACESv6=""
Aquesta és la configuració que farem servir, només cal fer 1 xarxa, ja que només ho farem servir per nosaltres.
Amb això ja queda la configuració del dhcp dinàmic creat, per confirmar que tot està ben configurat hem de fer el restart.
root@gateway-hector:/home/vagrant# systemctl restart isc-dhcp-server
root@gateway-hector:/home/vagrant#