next up previous contents
suivant: Le voisinage réseau des monter: Configurer un client/serveur DHCP précédent: Configurer un client/serveur DHCP   Table des matières

Coté serveur : DHCPd

Avant de commencer, il faut vérifier que dhcpd est installé et que les options TCP/IP et MULTICAST sont activés dans le noyau. Un ifconfig eth0 devrait le confirmer :

Networking options  --->
<*> Packet socket (CONFIG_PACKET)
[*] Socket filtering (CONFIG_FILTER)
[*]   IP: multicasting (CONFIG_IP_MULTICAST)

Créer aussi le fichier dhcpd.leases s'il n'existe pas (ce fichier contient les adresses IP attribuées, et DHCPd refusera de démarrer si il n'existe pas, afin de préserver les adresses IP déjà attribuées en cas de crash et redémarrage du serveur). Ce fichier peut se trouver dans les répertoires /var/state/dhcp/ FIXME. Utiliser la commande locate pour le trouver.

Ensuite, éditer le fichier /etc/dhcpd.conf (voir aussi dhcpd.conf(5)) :

#
# Passerelle par defaut
#

option routers 192.168.1.1;

#
# Masque de sous-reseau
#

option subnet-mask 255.255.255.0;

#
# Adresse de diffusion
#

option broadcast-address 192.168.1.255;

#
# Nom de domaine
#

option domain-name "chez.moi";

#
# Serveur(s) DNS
#

option domain-name-servers 192.168.1.1, 192.168.2.1;

#
# Duree en secondes pendant laquelle l'adresse IP attribuee est valide
# (si le client ne demande une date d'expiration)
#

default-lease-time 21600;

#
# Duree maximale en secondes pendant laquelle l'adresse IP attribuee est
# valide (si le client demande une date d'expiration)
#

max-lease-time 43200;

#
# Pour les reseau d'adresse 192.168.1.0 et de masque 255.255.255.0
#

subnet 192.168.1.0 netmask 255.255.255.0 {

#
# L'hote zecastor aura toujours une adresse IP fixe. Son adresse MAC (celle
# de la carte Ethernet) 00:a0:c9:ea:22:61 sera toujours associee a l'adresse
# IP 192.168.1.1
#

    host zecastor {
        hardware ethernet 00:a0:c9:ea:22:61;
        fixed-address 192.168.1.1;
    }

#
# Idem pour nougat
#

    host nougat {
        hardware ethernet 52:54:00:e8:70:ff;
        fixed-address 192.168.1.2;
    } 

#
# Les adresses comprises entre [192.168.1.10 ; 192.168.1.100] et
# [ 192.168.1.150 ; 192.168.1.200 ] sont attribuées aux autres machines
#

    range 192.168.1.10 192.168.1.100 ;
    range  192.168.1.150 192.168.1.200;
}

Pour que ces modifications soient prisent en compte, relancer le serveur DHCP :

Le fichier /etc/dhcpd.conf de la Debian contient des fonctionnalités intéressantes (hôtes se connectant à divers résaux et prenant divers paramètres) :

# Hosts which require special configuration options can be listed in
# host statements.   If no address is specified, the address will be
# allocated dynamically (if possible), but the host-specific information
# will still come from the host declaration.

host passacaglia {
  hardware ethernet 0:0:c0:5d:bd:95;
  filename "vmunix.passacaglia";
  server-name "toccata.fugue.com";
}

# 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 fantasia {
  hardware ethernet 08:00:07:26:c0:a5;
  fixed-address fantasia.fugue.com;
}

# If a DHCP or BOOTP client is mobile and might be connected to a variety
# of networks, more than one fixed address for that host can be specified.
# Hosts can have fixed addresses on some networks, but receive dynamically
# allocated address on other subnets; in order to support this, a host
# declaration for that client must be given which does not have a fixed
# address.   If a client should get different parameters depending on
# what subnet it boots on, host declarations for each such network should
# be given.   Finally, if a domain name is given for a host's fixed address
# and that domain name evaluates to more than one address, the address
# corresponding to the network to which the client is attached, if any,
# will be assigned.
host confusia {
  hardware ethernet 02:03:04:05:06:07;
  fixed-address confusia-1.fugue.com, confusia-2.fugue.com;
  filename "vmunix.confusia";
  server-name "toccata.fugue.com";
}

host confusia {
  hardware ethernet 02:03:04:05:06:07;
  fixed-address confusia-3.fugue.com;
  filename "vmunix.confusia";
  server-name "snarg.fugue.com";
}

host confusia {
  hardware ethernet 02:03:04:05:06:07;
  filename "vmunix.confusia";
  server-name "bb.home.vix.com";
}

Pour que les clients DHCP de Windows marchent (violation du protocole DHCP), ajouter :

# route add -host 255.255.255.255 dev eth0
#

Si le message d'erreur 255.255.255.255: Unknown host apparait, ajouter dans le fichier /etc/hosts l'entrée suivante :

255.255.255.255 all-ones

Essayer alors l'une de ces deux commandes :

# route add -host all-ones dev eth0
# route add 255.255.255.0 dev eth0
#


next up previous contents
suivant: Le voisinage réseau des monter: Configurer un client/serveur DHCP précédent: Configurer un client/serveur DHCP   Table des matières
2004-07-17