- NOTA:
- Num segmento de rede só deve existir um único servidor DHCP, pelo que poderá eventualmente ser necessário desactivar o servidor DHCP do router ADSL.
Instalação
server:~# apt-get install dhcp3-server
Configuração
O serviço DHCP só estará disponível para a rede interna. Por isso só aceitará ligações pela interface eth0, o que é definido no ficheiro de configuração /etc/default/dhcp3-server:
# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp3-server by the maintainer scripts
#
# This is a POSIX shell fragment
#
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="eth0"
A parte principal da configuração é mantida no ficheiro /etc/dhcp3/dhcpd.conf. Neste ficheiro é indicado o nome de domínio (option domain-name "home.lan";), os endereços dos servidores DNS (option domain-name-servers 192.168.1.100, 192.168.1.1;).
É também definida a duração normal e máxima da atribuição do endereço IP atribuído (default-lease-time 600; max-lease-time 7200;). O cliente poderá sempre pedir uma nova atribuição antes da actual expirar, podendo receber ou não o mesmo endereço IP.
Finalmente, para o segmento de rede 192.168.1.0, é indicada a gama de endereços disponível para a atribuição (range 192.168.1.32 192.168.1.63;), qual o router a utilizar (option routers 192.168.1.1;) e qual o endereço de broadcast (option broadcast-address 192.168.1.255;)
#
# Sample configuration file for ISC dhcpd for Debian
#
# $Id: dhcpd.conf,v 1.1.1.1 2002/05/21 00:07:44 peloy Exp $
#
# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;
# option definitions common to all supported networks...
option domain-name "home.lan";
option domain-name-servers 192.168.1.100, 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
## SubRede home.lan
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.32 192.168.1.63;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
}
# [...]
O protocolo DHCP possibilita a atribuição endereços específicos a determinados sistemas, associando o número da placa de rede ao endereço pretendido. No entanto, estes endereços fixos não devem estar na gama dos endereços reservados para atribuição dinâmica.
# [...]
#[...]
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet
# to which a BOOTP client is connected which has the dynamic-bootp flag
# set.
host posto2 {
hardware ethernet 01:23:45:67:89:10;
fixed-address 192.168.1.2;
}
host posto3{
hardware ethernet 01:23:45:67:89:11;
fixed-address 192.168.1.3;
}
Reiniciar o serviço dhcp:
server:~# /etc/init.d/dhcp3-server restart
Configuração dos clientes
Linux
Num cliente Linux, basta instalar o pacote dhcp client. A configuração gerada durante a instalação deverá ser suficiente.
server:~# apt-get install dhcp3-client dhcp3-common
Windows
Num cliente Windows, deverá ser activada a opção "Obter automaticamente um endereço IP", nas propriedades TCP/IP da interface de rede. Numa rede caseira, com acesso à Internet via modem ADSL ou cabo, esta opção deverá, em princípio, já estar activada.
Links Relacionados
- ISC DHCP (http://www.isc.org/index.pl?/sw/dhcp/)
- Wikipedia: DHCP (http://pt.wikipedia.org/wiki/Dns)




















