Contexte d'exemple :

  • Notre réseau est sur la plage d'adresse IP privée : 10.1.10.0/24
  • Notre routeur (gateway) a l'adresse IP : 10.1.10.254
  • Nous avons à notre disposition un serveur également un serveur sous GNU Linux Debian 4 Etch qui a pour IP 10.1.10.1

Notre serveur (IP:10.1.10.1 - sous GNU Linux Debian 4 Etch ) va faire office de serveur DHCP, TFTP et PXE

Si votre routeur fait également serveur DHCP, vous devez arreter ce service.

Serveur DHCP

 apt-get install dhcp3-server

Note : ne pas utiliser dhcpd qui ne supporte pas certaines options nécessaires

Le fichier /etc/default/dhcp3-server

Vous devez y spécifier le nom de la ou des interfaces sur lesquel le serveur DHCP doit ecouter.

Par exemple :

 INTERFACES="eth1"

Le fichier /etc/dhcp3/dhcpd.conf

 authoritative;
 ddns-update-style interim;
 ignore client-updates;
 
 subnet 10.1.10.0 netmask 255.255.255.0 {
   range 10.1.10.120 10.1.10.145;
   option domain-name-servers 10.1.10.1;
   option domain-name "queret.net";
   option routers 10.1.10.254;
   option subnet-mask 255.255.255.0;
   option broadcast-address 10.1.10.255;
   default-lease-time 43200;
   max-lease-time 86400;
 
   server-name "PXE";
   next-server 10.1.10.1;
   filename "/tftpboot/pxe/pxelinux.0";
 }

Relancer le serveur dhcp

 /etc/init.d/dhcp3-server restart

Serveur TFTP

 apt-get install atftpd
 mkdir /tftpboot
 chmod 777 /tftpboot -R

Editer le fichier **/etc/default/atftpd** et changer la première ligne par :

 USE_INETD=false

Editer le fichier **/etc/inetd.conf** et commenter la ligne concernant tftp :

 # tftp            dgram   udp     wait    nobody /usr/sbin/tcpd /usr/sbin/in.tftpd --tftpd-timeout 300 --retry-timeout 5     --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5  /tftpboot

Lancer le serveur tftp

 /etc/init.d/atftpd start

Serveur PXE

 apt-get install pxe syslinux

Editez le fichier /etc/pxe.conf et adapter les valeurs réseau au votre, notamment quelle sera l'interface réseau sur laquelle va se connecter le client, l'IP de celle-ci ainsi que le chemin de base /tftpboot.

Preparation de l'arborescence du dossiers tftp

Vu que notre servuer tftp peut servir a autre chose que le boot PXE (VOIP, Config Switch, ...) on crée un sous dossier "pxe".

 mkdir /tftpboot/pxe/

Il faut maintenant définir le fichier de configuration de PXE lui indiquant quel est le noyau linux sur lequel le poste client va booter.\\ Comme nous voulons pouvoir aussi bien installer debian etch que debian lenny sur une plateforme 32 bits et 64 bits, il va nous falloir recupérer les images des noyau de tout cela.

Telechargement des images netboot

 wget http://ftp.fr.debian.org/debian/dists/etch/main/installer-i386/current/images/netboot/netboot.tar.gz -O /tmp/netboot-debian-etch-i386.tar.gz
 wget http://ftp.fr.debian.org/debian/dists/etch/main/installer-amd64/current/images/netboot/netboot.tar.gz -O /tmp/netboot-debian-etch-amd64.tar.gz
 wget http://ftp.fr.debian.org/debian/dists/lenny/main/installer-i386/current/images/netboot/netboot.tar.gz -O /tmp/netboot-debian-lenny-i386.tar.gz
 wget http://ftp.fr.debian.org/debian/dists/lenny/main/installer-amd64/current/images/netboot/netboot.tar.gz -O /tmp/netboot-debian-lenny-amd64.tar.gz

Creation des repertoires temporaires

 mkdir -p /tmp/netboot-debian-etch-i386/
 mkdir -p /tmp/netboot-debian-etch-amd64/
 mkdir -p /tmp/netboot-debian-lenny-i386/
 mkdir -p /tmp/netboot-debian-lenny-amd64/

Decompression des images netboot dans les repertoires temporaires

 cd /tmp/netboot-debian-etch-i386/; tar zxvf /tmp/netboot-debian-etch-i386.tar.gz
 cd /tmp/netboot-debian-etch-amd64/; tar zxvf /tmp/netboot-debian-etch-amd64.tar.gz
 cd /tmp/netboot-debian-lenny-i386/; tar zxvf /tmp/netboot-debian-lenny-i386.tar.gz
 cd /tmp/netboot-debian-lenny-amd64/; tar zxvf /tmp/netboot-debian-lenny-amd64.tar.gz

Creation de l'arboresence tftp

 mkdir -p /tftpboot/pxe/
 mkdir -p /tftpboot/pxe/boot-screens/
 mkdir -p /tftpboot/pxe/pxelinux.cfg/
 mkdir -p /tftpboot/pxe/debian-etch/i386/
 mkdir -p /tftpboot/pxe/debian-etch/amd64/
 mkdir -p /tftpboot/pxe/debian-lenny/i386/
 mkdir -p /tftpboot/pxe/debian-lenny/amd64/

Copie des fichiers necessaires depuis les repertoires temporaires vers l'arborescence netboot

 cp /tmp/netboot-debian-lenny-i386/debian-installer/i386/pxelinux.0 /tftpboot/pxe/
 cp /tmp/netboot-debian-lenny-i386/debian-installer/i386/boot-screens/splash.png /tftpboot/pxe/boot-screens/
 cp /tmp/netboot-debian-lenny-i386/debian-installer/i386/boot-screens/vesamenu.c32 /tftpboot/pxe/boot-screens/
 cp /tmp/netboot-debian-etch-i386/debian-installer/i386/initrd.gz /tftpboot/pxe/debian-etch/i386/
 cp /tmp/netboot-debian-etch-i386/debian-installer/i386/linux /tftpboot/pxe/debian-etch/i386/
 cp /tmp/netboot-debian-etch-amd64/debian-installer/amd64/initrd.gz /tftpboot/pxe/debian-etch/amd64/
 cp /tmp/netboot-debian-etch-amd64/debian-installer/amd64/linux /tftpboot/pxe/debian-etch/amd64/
 cp /tmp/netboot-debian-lenny-i386/debian-installer/i386/initrd.gz /tftpboot/pxe/debian-lenny/i386/
 cp /tmp/netboot-debian-lenny-i386/debian-installer/i386/linux /tftpboot/pxe/debian-lenny/i386/
 cp /tmp/netboot-debian-lenny-amd64/debian-installer/amd64/initrd.gz /tftpboot/pxe/debian-lenny/amd64/
 cp /tmp/netboot-debian-lenny-amd64/debian-installer/amd64/linux /tftpboot/pxe/debian-lenny/amd64/

Creation du fichier /tftpboot/pxe/pxelinux.cfg/default

 include /boot-screens/menu.cfg
 default /boot-screens/vesamenu.c32
 prompt 0
 timeout 0

Creation du fichier /tftpboot/pxe/boot-screens/menu.cfg

 menu hshift 13
 menu width 49
 
 menu title LTU Installer boot menu
 menu background boot-screens/splash.png
 menu color title        * #FFFFFFFF *
 menu color border       * #00000000 #00000000 none
 menu color sel          * #ffffffff #76a1d0ff *
 menu color hotsel       1;7;37;40 #ffffffff #76a1d0ff *
 menu color tabmsg       * #ffffffff #00000000 *
 menu vshift 12
 menu rows 10
 menu tabmsgrow 16
 menu timeoutrow 17
 menu tabmsg Press ENTER to boot or TAB to edit a menu entry
 menu autoboot Starting Local System in # seconds
 
 prompt 0
 
 
 label bootlocal
     menu label ^Boot from local disk
         menu default
         localboot 0
         timeout 200           #timeout which is displayed, Wait 10 seconds unless the user types somethin
         totaltimeout 1200     #timeout which executes the default definitely, always boot after 2 minutes
 
 menu begin debian
       menu title Debian
       label mainmenu
               menu label ^Back..
               menu exit
       menu begin debian-etch
               menu title Debian Etch
               label mainmenu
                       menu label ^Back..
                       menu exit
               menu begin debian-etch-i386
                       menu title Debian Etch i386
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       DEFAULT install
                       LABEL install
                               kernel debian-etch/i386/linux
                               append vga=normal initrd=debian-etch/i386/initrd.gz --
                       LABEL expert
                               kernel debian-etch/i386/linux
                               append priority=low vga=normal initrd=debian-etch/i386/initrd.gz --
                       LABEL rescue
                               kernel debian-etch/i386/linux
                               append vga=normal initrd=debian-etch/i386/initrd.gz rescue/enable=true --
                       LABEL auto
                               kernel debian-etch/i386/linux
                               append auto=true priority=critical vga=normal initrd=debian-etch/i386/initrd.gz --
               menu end
               menu begin debian-etch-amd64
                       menu title Debian Etch amd64
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       DEFAULT install
                       LABEL install
                               kernel debian-etch/amd64/linux
                               append vga=normal initrd=debian-etch/amd64/initrd.gz --
                       LABEL expert
                               kernel debian-etch/amd64/linux
                               append priority=low vga=normal initrd=debian-etch/amd64/initrd.gz --
                       LABEL rescue
                               kernel debian-etch/amd64/linux
                               append vga=normal initrd=debian-etch/amd64/initrd.gz rescue/enable=true --
                       LABEL auto
                               kernel debian-etch/amd64/linux
                               append auto=true priority=critical vga=normal initrd=debian-etch/amd64/initrd.gz --
               menu end
       menu end
 
       menu begin debian-lenny
               menu title Debian Lenny
               label mainmenu
                       menu label ^Back..
                       menu exit
               menu begin debian-lenny-i386
                       menu title Debian Lenny i386
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       default install
                       label install
                               menu label ^Install
                               kernel debian-lenny/i386/linux
                               append vga=normal initrd=debian-lenny/i386/initrd.gz -- quiet
                       label expert
                               menu label ^Expert install
                               kernel debian-lenny/i386/linux
                               append priority=low vga=normal initrd=debian-lenny/i386/initrd.gz --
                       label rescue
                               menu label ^Rescue mode
                               kernel debian-lenny/i386/linux
                               append vga=normal initrd=debian-lenny/i386/initrd.gz rescue/enable=true -- quiet
                       label auto
                               menu label ^Automated install
                               kernel debian-lenny/i386/linux
                               append auto=true priority=critical vga=normal initrd=debian-lenny/i386/initrd.gz -- quiet
               menu end
               menu begin debian-lenny-amd64
                       menu title Debian Lenny amd64
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       label install
                               menu label ^Install
                               kernel debian-lenny/amd64/linux
                               append vga=normal initrd=debian-lenny/amd64/initrd.gz -- quiet
                       label expert
                               menu label ^Expert install
                               kernel debian-lenny/amd64/linux
                               append priority=low vga=normal initrd=debian-lenny/amd64/initrd.gz --
                       label rescue
                               menu label ^Rescue mode
                               kernel debian-lenny/amd64/linux
                               append vga=normal initrd=debian-lenny/amd64/initrd.gz rescue/enable=true -- quiet
                       label auto
                               menu label ^Automated install
                               kernel debian-lenny/amd64/linux
                               append auto=true priority=critical vga=normal initrd=debian-lenny/amd64/initrd.gz -- quiet
               menu end
       menu end
 menu end

Arboresence final

 /tftpboot/pxe
 /tftpboot/pxe/debian-etch
 /tftpboot/pxe/debian-etch/i386
 /tftpboot/pxe/debian-etch/i386/initrd.gz
 /tftpboot/pxe/debian-etch/i386/linux
 /tftpboot/pxe/debian-etch/amd64
 /tftpboot/pxe/debian-etch/amd64/initrd.gz
 /tftpboot/pxe/debian-etch/amd64/linux
 /tftpboot/pxe/debian-lenny
 /tftpboot/pxe/debian-lenny/i386
 /tftpboot/pxe/debian-lenny/i386/initrd.gz
 /tftpboot/pxe/debian-lenny/i386/linux
 /tftpboot/pxe/debian-lenny/amd64
 /tftpboot/pxe/debian-lenny/amd64/initrd.gz
 /tftpboot/pxe/debian-lenny/amd64/linux
 /tftpboot/pxe/pxelinux.0
 /tftpboot/pxe/pxelinux.cfg
 /tftpboot/pxe/pxelinux.cfg/default
 /tftpboot/pxe/boot-screens
 /tftpboot/pxe/boot-screens/splash.png
 /tftpboot/pxe/boot-screens/menu.cfg
 /tftpboot/pxe/boot-screens/vesamenu.c32

Centos

Comme pour Debian, nous avons besoin des noyaux netboot. Nous allons ici preparer un boot PXE pour CentOS4 & CentOS5

Creation de l'arboresence

 mkdir -p /tftpboot/pxe/centos-4/i386/
 mkdir -p /tftpboot/pxe/centos-4/x86_64/
 
 mkdir -p /tftpboot/pxe/centos-5/i386/
 mkdir -p /tftpboot/pxe/centos-5/x86_64/

Telechargement des noyaux netboot

 wget http://mirror.centos.org/centos/4/os/i386/images/pxeboot/initrd.img -O /tftpboot/pxe/centos-4/i386/initrd.img
 wget http://mirror.centos.org/centos/4/os/i386/images/pxeboot/vmlinuz -O /tftpboot/pxe/centos-4/i386/vmlinuz
 wget http://mirror.centos.org/centos/4/os/x86_64/images/pxeboot/initrd.img -O /tftpboot/pxe/centos-4/x86_64/initrd.img
 wget http://mirror.centos.org/centos/4/os/x86_64/images/pxeboot/vmlinuz -O /tftpboot/pxe/centos-4/x86_64/vmlinuz
 
 wget http://mirror.centos.org/centos/5/os/i386/images/pxeboot/initrd.img -O /tftpboot/pxe/centos-5/i386/initrd.img
 wget http://mirror.centos.org/centos/5/os/i386/images/pxeboot/vmlinuz -O /tftpboot/pxe/centos-5/i386/vmlinuz
 wget http://mirror.centos.org/centos/5/os/x86_64/images/pxeboot/initrd.img -O /tftpboot/pxe/centos-5/x86_64/initrd.img
 wget http://mirror.centos.org/centos/5/os/x86_64/images/pxeboot/vmlinuz -O /tftpboot/pxe/centos-5/x86_64/vmlinuz

Rajouter à la fin du fichier /tftpboot/pxe/boot-screens/menu.cfg

 menu begin centos
       menu title Centos
       label mainmenu
               menu label ^Back..
               menu exit
       menu begin centos-4
               menu title CentOS 4
               label mainmenu
                       menu label ^Back..
                       menu exit
               menu begin centos-4-i386
                       menu title CentOS 4 i386
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       label install
                               menu label ^Install
                               kernel centos-4/i386/vmlinuz
                               append ksdevice=eth0 console=tty0 initrd=centos-4/i386/initrd.img ks=http://10.1.10.1/pxe/ks.centos-4-i386.cfg ramdisk_size=8192
               menu end
               menu begin centos-4-x86_64
                       menu title CentOS 4 x86_64
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       label install
                               menu label ^Install
                               kernel centos-4/x86_64/vmlinuz
                               append ksdevice=eth0 console=tty0 initrd=centos-4/x86_64/initrd.img ks=http://10.1.10.1/pxe/ks.centos-4-x86_64.cfg ramdisk_size=8192
               menu end
       menu end
       menu begin centos-5
               menu title CentOS 5
               label mainmenu
                       menu label ^Back..
                       menu exit
               menu begin centos-5-i386
                       menu title CentOS 5 i386
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       label install
                               menu label ^Install
                               kernel centos-5/i386/vmlinuz
                               append ksdevice=eth0 console=tty0 initrd=centos-5/i386/initrd.img ks=http://10.1.10.1/pxe/ks.centos-5-i386.cfg ramdisk_size=8192
               menu end
               menu begin centos-5-x86_64
                       menu title CentOS 5 amd64
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       label install
                               menu label ^Install
                               kernel centos-5/x86_64/vmlinuz
                               append ksdevice=eth0 console=tty0 initrd=centos-5/x86_64/initrd.img ks=http://10.1.10.1/pxe/ks.centos-5-x86_64.cfg ramdisk_size=8192
               menu end
       menu end
 menu end

Les fichiers KS

Les distribution basée sur Redhat, on besoin de recupérer un fichier soit par http ou par ftp.\\ Nous allons, utiliser le serveur apache.

 apt-get install apache2

Le fichier http://10.1.10.1/ks.centos-4-i386.cfg (dans /var/www/)

 install
 url --url http://mirror.centos.org/centos/4/os/i386/
 lang en_US.UTF-8
 langsupport --default en_US.UTF-8 en_US.UTF-8 fr_FR.UTF-8
 keyboard fr_FR-latin1

Le fichier http://10.1.10./ks.centos-4-x86_64.cfg (dans /var/www/)

 install
 url --url http://mirror.centos.org/centos/4/os/x86_64/
 lang en_US.UTF-8
 langsupport --default en_US.UTF-8 en_US.UTF-8 fr_FR.UTF-8
 keyboard fr_FR-latin1

Le fichier http://10.1.10.1/ks.centos-5-i386.cfg (dans /var/www/)

 install
 url --url http://mirror.centos.org/centos/5/os/i386/
 lang en_US.UTF-8
 langsupport --default en_US.UTF-8 en_US.UTF-8 fr_FR.UTF-8
 keyboard fr_FR-latin1

Le fichier http://10.1.10.1/ks.centos-5-x86_64.cfg (dans /var/www/)

 install
 url --url http://mirror.centos.org/centos/5/os/x86_64/
 lang en_US.UTF-8
 langsupport --default en_US.UTF-8 en_US.UTF-8 fr_FR.UTF-8
 keyboard fr_FR-latin1

Fedora

Fedora étant basé sur Redhat le fonctionnement est le meme que pour centos.

Creation de l'arboresence

 mkdir -p /tftpboot/pxe/fedora-9/i386/
 mkdir -p /tftpboot/pxe/fedora-9/x86_64/

Telechargement des noyaux netboot

 wget http://ftp.ciril.fr/pub/linux/fedora/linux/releases/9/Fedora/i386/os/images/pxeboot/initrd.img -O /tftpboot/pxe/fedora-9/i386/initrd.img
 wget http://ftp.ciril.fr/pub/linux/fedora/linux/releases/9/Fedora/i386/os/images/pxeboot/vmlinuz -O /tftpboot/pxe/fedora-9/i386/vmlinuz
 wget http://ftp.ciril.fr/pub/linux/fedora/linux/releases/9/Fedora/x86_64/os/images/pxeboot/initrd.img -O /tftpboot/pxe/fedora-9/x86_64/initrd.img
 wget http://ftp.ciril.fr/pub/linux/fedora/linux/releases/9/Fedora/x86_64/os/images/pxeboot/vmlinuz -O /tftpboot/pxe/fedora-9/x86_64/vmlinuz

Rajouter à la fin du fichier /tftpboot/pxe/boot-screens/menu.cfg

 menu begin fedora
       menu title Fedora
               label mainmenu
               menu label ^Back..
               menu exit
       menu begin fedora-9
               menu title Fedora 9
               label mainmenu
                       menu label ^Back..
                       menu exit
               menu begin fedora-9-i386
                       menu title Fedora 9 i386
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       label install
                               menu label ^Install
                               kernel fedora-9/i386/vmlinuz
                               append ksdevice=eth0 console=tty0 initrd=fedora-9/i386/initrd.img ks=http://10.1.10.1/pxe/ks.fedora-9-i386.cfg ramdisk_size=8192
               menu end
               menu begin fedora-9-x86_64
                       menu title Fedora 9 amd64
                       label mainmenu
                               menu label ^Back..
                               menu exit
                       label install
                               menu label ^Install
                               kernel fedora-9/x86_64/vmlinuz
                               append ksdevice=eth0 console=tty0 initrd=fedora-9/x86_64/initrd.img ks=http://10.1.10.1/pxe/ks.fedora-9-x86_64.cfg ramdisk_size=8192
               menu end
       menu end
 menu end

Les fichiers KS

Comme pour CentOS les distribution basée sur Redhat, on besoin de recupérer un fichier soit par http ou par ftp.\\ Nous allons, toujours dans cette exemple, utiliser un serveur http.

Le fichier http://10.1.10.1/ks.fedora-9-i386.cfg (dans /var/www/)

 install
 url --url http://ftp.ciril.fr/pub/linux/fedora/linux/releases/9/Fedora/i386/os/

Le fichier http://10.1.10.1/ks.fedora-9-x86_64.cfg (dans /var/www/)

 install
 url --url http://ftp.ciril.fr/pub/linux/fedora/linux/releases/9/Fedora/x86_64/os/