📌
ROTEIRO
- Download e Instalação do ISC DHCP
- Atribuição de um IPv4 Fixo para o servidor
- Configuração do DHCP Server
- Definir em qual interface o DHCP irá atuar
- Testes
✅ Download e Instalação do ISC DHCP Server
1 2 |
sudo apt update sudo apt install isc-dhcp-server |
✅ Atribuição de um IPv4 Fixo para o servidor com Netplan
Edição do arquivo Netplan
1 |
sudo nano /etc/netplan/01-dhcp-server-config.yaml |
⚠️ Altere as permissões do arquivo de configuração:
1 |
sudo chmod 600 /etc/netplan/01-dhcp-server-config.yaml |
Isso garante que somente o root possa ler e escrever o arquivo, como o Netplan exige.
Configuração da Rede
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
network: version: 2 ethernets: ens3: dhcp4: false addresses: - 172.16.10.254/24 routes: - to: default via: 172.16.10.1 nameservers: addresses: - 8.8.8.8 - 1.1.1.1 |
⚠️ Mantenha a indentação!
Depois de definida a configuração, aplique-a:
1 |
sudo netplan apply |
✅ Configuração do DHCP Server
Edite o arquivo dhcpd.conf
:
1 |
sudo nano /etc/dhcp/dhcpd.conf |
E insira a configuração de rede:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# dhcpd.conf # Nome do domínio e DNSs option domain-name "rede.local"; option domain-name-servers 8.8.8.8, 1.1.1.1; # Tempo de concessão de IP default-lease-time 600; max-lease-time 7200; # Sem atualizações dinâmicas de DNS ddns-update-style none; # Definição da rede local subnet 172.16.10.0 netmask 255.255.255.0 { range 172.16.10.100 172.16.10.200; option routers 172.16.10.1; option subnet-mask 255.255.255.0; option domain-name-servers 8.8.8.8, 1.1.1.1; option domain-name "rede.local"; |
✅ Definir ens3
como interface do DHCP
Edite o arquivo isc-dhcp-server
:
1 |
sudo nano /etc/default/isc-dhcp-server |
Defina a interface ens3
:
1 2 |
INTERFACESv4="ens3" INTERFACESv6="" |
Habilite e (re)inicie o serviço:
1 2 3 |
sudo systemctl restart isc-dhcp-server sudo systemctl enable isc-dhcp-server sudo systemctl status isc-dhcp-server |
✅ Testes
👍 Verifique o status do serviço:
1 |
sudo systemctl status isc-dhcp-server |
Saída:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
ubuntu@ubuntu-cloud:~$ sudo systemctl status isc-dhcp-server ● isc-dhcp-server.service - ISC DHCP IPv4 server Loaded: loaded (/usr/lib/systemd/system/isc-dhcp-server.service; enabled; > Active: active (running) since Sun 2025-07-27 17:24:39 UTC; 38min ago Invocation: 3836b915b34a4a89a0db752c38f8efbb Docs: man:dhcpd(8) Main PID: 659 (dhcpd) Tasks: 1 (limit: 1110) Memory: 4.5M (peak: 4.7M) CPU: 96ms CGroup: /system.slice/isc-dhcp-server.service └─659 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dh> Jul 27 18:01:48 ubuntu-cloud dhcpd[659]: DHCPDISCOVER from 00:50:79:66:68:00 vi> Jul 27 18:01:49 ubuntu-cloud dhcpd[659]: DHCPOFFER on 172.16.10.100 to 00:50:79> Jul 27 18:01:52 ubuntu-cloud dhcpd[659]: DHCPREQUEST for 172.16.10.100 (172.16.> Jul 27 18:01:52 ubuntu-cloud dhcpd[659]: DHCPACK on 172.16.10.100 to 00:50:79:6> Jul 27 18:01:54 ubuntu-cloud dhcpd[659]: DHCPDISCOVER from 00:50:79:66:68:01 vi> Jul 27 18:01:55 ubuntu-cloud dhcpd[659]: DHCPOFFER on 172.16.10.102 to 00:50:79> Jul 27 18:01:57 ubuntu-cloud dhcpd[659]: DHCPDISCOVER from 0c:50:e6:6b:00:00 (u> Jul 27 18:01:58 ubuntu-cloud dhcpd[659]: DHCPOFFER on 172.16.10.103 to 0c:50:e6> Jul 27 18:01:58 ubuntu-cloud dhcpd[659]: DHCPREQUEST for 172.16.10.102 (172.16.> Jul 27 18:01:58 ubuntu-cloud dhcpd[659]: DHCPACK on 172.16.10.102 to 00:50:79:6> ubuntu@ubuntu-cloud:~$ |
👍 Verifique a atribuição de endereços IPv4:
1 |
cat /var/lib/dhcp/dhcpd.leases |
Saída:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
ubuntu@ubuntu-cloud:~$ cat /var/lib/dhcp/dhcpd.leases # The format of this file is documented in the dhcpd.leases(5) manual page. # This lease file was written by isc-dhcp-4.4.3-P1 # authoring-byte-order entry is generated, DO NOT DELETE authoring-byte-order little-endian; lease 172.16.10.100 { starts 0 2025/07/27 18:06:56; ends 0 2025/07/27 18:16:56; tstp 0 2025/07/27 18:16:56; cltt 0 2025/07/27 18:06:56; binding state active; next binding state free; rewind binding state free; hardware ethernet 00:50:79:66:68:00; uid "\001\000Pyfh\000"; client-hostname "PC1"; } lease 172.16.10.102 { starts 0 2025/07/27 18:07:02; ends 0 2025/07/27 18:17:02; tstp 0 2025/07/27 18:17:02; cltt 0 2025/07/27 18:07:02; binding state active; next binding state free; rewind binding state free; hardware ethernet 00:50:79:66:68:01; uid "\001\000Pyfh\001"; client-hostname "PC2"; } server-duid "\000\001\000\0010\031\030h\014P\346k\000\000"; ubuntu@ubuntu-cloud:~$ |
*Atualizado em 28 de julho de 2025