PXE: Difference between revisions

From Hobbynet Admin Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
 
(26 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= pxe =
= pxe =


Op db-int draait een pxe server voor instalatie van debian op afstand.
Op de virtuele server 'pxe' draait een PXE-server voor installatie van debian op afstand.


er wordt doormiddel van dhcp een extern ip uitgedeeld waarmee je een server kan herinstalleren.
Er wordt door middel van dhcp een extern IP adres uitgedeeld waarmee je een server kan herinstalleren.
== tftp ==
de tftp boot files staan in /var/lib/tftpboot


== dhcp ==
Op deze pagina staat complete installatie handleiding: [http://www.howtoforge.com/ubuntu_pxe_install_server http://www.howtoforge.com/ubuntu_pxe_install_server]
De dhcp server deelt twee reeksen uit
1 in de 2e interne reeks 172.31.1.0/24 van 172.31.1.100 tot 172.31.1.150
2 in de externe reeks 212.72.224.0/26 van 212.72.224.24 tot 212.72.224.26


de config van dhcp
== tftp ==
De tftp boot files staan in /var/lib/tftpboot


<pre>
== dhcpd ==
#
De dhcp server deelt in drie reeksen uit:
# 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
1 in de 2e interne reeks 172.31.1.0/24 van 172.31.1.140 tot 172.31.1.170
# attempt to do a DNS update when a lease is confirmed. We default to the
2 in de externe reeks 212.72.224.0/26 van 212.72.224.200 tot 212.72.224.210
# behavior of the version 2 packages ('none', since DHCP v2 didn't
3 in de externe reeks 212.72.229.0/26 van 212.72.224.200 tot 212.72.229.210
# have support for DDNS.)
ddns-update-style none;


# option definitions common to all supported networks...
De config van dhcp
option domain-name "hobby.nl";
option domain-name-servers 212.72.224.8, 212.72.224.9;


<pre>
default-lease-time 600;
default-lease-time 600;
max-lease-time 7200;
max-lease-time 600;


# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
authoritative;


# Use this to send dhcp log messages to a different log file (you also
subnet 172.31.1.0 netmask 255.255.255.0 {
# have to hack syslog.conf to complete the redirection).
        range 172.31.1.140 172.31.1.170;
log-facility local7;
        filename "pxelinux.0";
        option domain-name "hobby.nl";
        option subnet-mask 255.255.255.0;
        option domain-name-servers 172.31.1.107, 172.31.1.13, 172.31.1.14;
        option routers 172.31.1.254;
}


# No service will be given on this subnet, but declaring it helps the
subnet 212.72.224.0 netmask 255.255.255.0 {
# DHCP server to understand the network topology.
        range 212.72.224.200 212.72.224.210;
        filename "pxelinux.0";
        option domain-name "hobby.nl";
        option subnet-mask 255.255.255.0;
        option domain-name-servers 212.72.224.101, 212.72.224.22, 212.72.224.23;
        option routers 212.72.224.1;
}


#subnet 10.152.187.0 netmask 255.255.255.0 {
subnet 212.72.229.0 netmask 255.255.255.0 {
#}
        range 212.72.229.200 212.72.229.210;
        filename "pxelinux.0";
        option domain-name "hobby.nl";
        option subnet-mask 255.255.255.0;
        option domain-name-servers 212.72.224.101, 212.72.224.22, 212.72.224.23;
        option routers 212.72.229.1;
}
</pre>


# This is a very basic subnet declaration.
== De client kant ==
Neem in de lokale DHCP server op:
<pre>
subnet 192.168.10.0 netmask 255.255.255.0 {
  range 192.168.10.170 192.168.10.199;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.10.255;
  option routers 192.168.10.1;
  filename "pxelinux.0";
  next-server 212.72.224.24;
</pre>
Het gaat om de laatste twee regels; "filename" en "next-server".


#subnet 10.254.239.0 netmask 255.255.255.224 {
== distributies ==
#  range 10.254.239.10 10.254.239.20;
#  option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
#}


# This declaration allows BOOTP clients to get dynamic addresses,
De globale bestanden voor alle distributies staan in /var/lib/tftpboot/pxelinux.cfg/
# which we don't really recommend.


#subnet 10.254.239.32 netmask 255.255.255.224 {
=== ubuntu ===
#  range dynamic-bootp 10.254.239.40 10.254.239.60;
==== Versie 18.04 LTS ====
#  option broadcast-address 10.254.239.31;
De installatie bestanden staan in /var/lib/tftpboot/ubuntu-installer-1804
#  option routers rtr-239-32-1.example.org;
==== Versie 18.10 ====
#}
De installatie bestanden staan in /var/lib/tftpboot/ubuntu-installer-1810


# A slightly different configuration for an internal subnet.
===== Images ophalen van externe server =====
#subnet 10.5.5.0 netmask 255.255.255.224 {
De boot images worden m.b.v. het script '/var/lib/tftpboot/ubuntu-installer-1604/temp/update' van een externe server opgehaald.
#  range 10.5.5.26 10.5.5.30;
#  option domain-name-servers ns1.internal.example.org;
#  option domain-name "internal.example.org";
#  option routers 10.5.5.1;
#  option broadcast-address 10.5.5.31;
#  default-lease-time 600;
#  max-lease-time 7200;
#}


# Hosts which require special configuration options can be listed in
<pre>
# host statements.   If no address is specified, the address will be
cd /var/lib/tftpboot/ubuntu-installer-1804/temp/
# allocated dynamically (if possible), but the host-specific information
echo Get AMD64 files
# will still come from the host declaration.
lftp -c "open http://nl.archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/ubuntu-installer; mirror amd64/"
echo Get i386 files
lftp -c "open http://nl.archive.ubuntu.com/ubuntu/dists/bionic/main/installer-i386/current/images/netboot/ubuntu-installer/; mirror i386/"
echo Move the files to the correct position
rm -fr /var/lib/tftpboot/ubuntu-installer-1804/amd64
rm -fr /var/lib/tftpboot/ubuntu-installer-1804/i386
mv amd64 /var/lib/tftpboot/ubuntu-installer-1804/
mv i386 /var/lib/tftpboot/ubuntu-installer-1804/
ls -l /var/lib/tftpboot/ubuntu-installer-1804/ -r
echo Done
</pre>


#host passacaglia {
=== debian ===
#  hardware ethernet 0:0:c0:5d:bd:95;
==== Versie 9.8 ====
#  filename "vmunix.passacaglia";
De installatie bestanden staan in /var/lib/tftpboot/debian-installer-98
#  server-name "toccata.fugue.com";
===== Images ophalen van externe server =====
#}
De boot images worden m.b.v. het script '/var/lib/tftpboot/debian-installer-98/tmp/update' van een externe server opgehaald.
<pre>
cd /var/lib/tftpboot/debian-installer-98/tmp/
lftp -c "open ftp://ftp.nl.debian.org/debian/dists/stretch/main/installer-i386/current/images/; mirror netboot/"
lftp -c "open ftp://ftp.nl.debian.org/debian/dists/stretch/main/installer-amd64/current/images/; mirror netboot/"
rm -fr /var/lib/tftpboot/debian-installer-98/amd64
rm -fr /var/lib/tftpboot/debian-installer-98/i386
mv /var/lib/tftpboot/debian-installer-98/tmp/netboot/debian-installer/* /var/lib/tftpboot/debian-installer-98
rm -fr netboot
</pre>


# Fixed IP addresses can also be specified for hosts.  These addresses
=== fedora ===
# should not also be listed as being available for dynamic assignment.
==== Fedora boot project ====
# Hosts for which fixed IP addresses have been specified can boot using
===== Bestands locaties =====
# BOOTP or DHCP.  Hosts for which no fixed address is specified can only
De installatie bestanden staan in /var/lib/tftpboot/fedora-bootproject
# be booted with DHCP, unless there is an address range on the subnet
===== Images ophalen van externe server =====
# to which a BOOTP client is connected which has the dynamic-bootp flag
De boot images worden m.b.v. het script '/var/lib/tftpboot/fedora-bootproject/work/doit.sh' van een externe server opgehaald.
# set.
<pre>
#host fantasia {
wget -O../bfo.lkrn http://dl.fedoraproject.org/pub/alt/bfo/bfo.lkrn
#  hardware ethernet 08:00:07:26:c0:a5;
</pre>
#  fixed-address fantasia.fugue.com;
#}


# You can declare a class of clients and then do address allocation
=== CentOS ===
# based on that.   The example below shows a case where all clients
==== Versie 7.5 ====
# in a certain class get addresses on the 10.17.224/24 subnet, and all
===== Bestands locaties =====
# other clients get addresses on the 10.0.29/24 subnet.
De installatie bestanden staan in /var/lib/tftpboot/centos-installer-75
===== Images ophalen van externe server =====
De boot images worden m.b.v. het script '/var/lib/tftpboot/centos-installer-75/temp/update' van een externe server opgehaald.
<pre>
cd /var/lib/tftpboot/centos-installer-75/temp/i386/
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/i386/isolinux/vmlinuz
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/i386/isolinux/initrd.img
mv * /var/lib/tftpboot/centos-installer-75/i386/
cd /var/lib/tftpboot/centos-installer-75/temp/amd64/
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/x86_64/isolinux/vmlinuz
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/x86_64/isolinux/initrd.img
mv * /var/lib/tftpboot/centos-installer-75/amd64/
</pre>


#class "foo" {
== automatische installatie hobbynet ==
#  match if substring (option vendor-class-identifier, 0, 4) = "SUNW";
#}


#shared-network 224-29 {
Voor hobbynet zijn er volledig voorgeconfigureerde installatie scripts, zodat de hobbynet servers op de gewenste manier worden ge&iuml;nstalleerd
#  subnet 10.17.224.0 netmask 255.255.255.0 {
#    option routers rtr-224.example.org;
#  }
#  subnet 10.0.29.0 netmask 255.255.255.0 {
#    option routers rtr-29.example.org;
#  }
#  pool {
#    allow members of "foo";
#    range 10.17.224.10 10.17.224.250;
#  }
#  pool {
#    deny members of "foo";
#    range 10.0.29.10 10.0.29.230;
#  }
#}


=== automatische installatie process ===


 
* Maak VM aan (Beschijven we niet, spreekt voor zich, anders lees de vmware handleiding maar) <br>Minimaal 2 cores en 2 gb geheugen is de standaard
 
* Boot van pxe (bij 2 interfaces faalt de 1e meestal en start van de 2e het interne netwerk)
subnet 172.31.1.0 netmask 255.255.255.0 {
* Kies in menu optie H hobbynet menu
         range 172.31.1.100 172.31.1.150;
* Bij 1 interface (alleen intern) kies je optie B en<br>bij 2 of meer interfaces kies je optie A bij (interne interface is dan de 2e netwerk kaart)
         filename "pxelinux.0";
* Vul de hostnaam in (zonder –int)<br>Let op: hostnaam alleen schrijven in '''kleine letters'''
        next-server 172.31.1.1;
* Wacht tot de machine gaat rebooten
        option subnet-mask 255.255.255.0;
* Login met user a wachtwoord bas
        option broadcast-address 172.31.1.255;
* doe "sudo -i" weer wachtwoord bas
}
* geef het commando ./post-install.sh
 
* wacht op reboot
subnet 212.72.224.0 netmask 255.255.255.192 {
* Tijdens reboot krijg je de melding "A startup job is running for wait for Network to be Configured"<br>Hierop moet je wachten (dit kan soms enkele minuten duren)
        range 212.72.224.24 212.72.224.26;
* login met beheerders account
         filename "pxelinux.0";
* wordt root (sudo -i)
        next-server 212.72.224.23;
* tip: kijk met ifconfig wat het IP adres is, login met ssh en ga verder als root
         option subnet-mask 255.255.255.192;
* pas /etc/netplan/01-netcfg.yaml aan naar de netwerk configuratie (gebruik geen tabs maar spaties)<br>hieronder een voorbeeld van standaard netplan file
        option broadcast-address 212.72.224.63;
<pre>
        option routers 212.72.224.1;
# This file describes the network interfaces available on your system
}
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
         ens160:
            dhcp6: no
            accept-ra: no
            addresses:
            - 212.72.227.86/27
            - 2a02:968:1:7:212:72:227:86/64
            gateway4: 212.72.227.65
            gateway6: 2a02:968:1:7::1
            nameservers:
                addresses: []
                search:
                - hobby.nl
            optional: true
         ens192:
            addresses:
            - 172.31.1.86/24
            nameservers:
                addresses: []
                search: []
            routes:
            - to: 172.31.0.0/16
              via: 172.31.1.1
            - to: 192.168.67.0/24
              via: 172.31.1.1
            - to: 192.168.200.0/24
              via: 172.31.1.1
         ens224:
            addresses:
            - 172.31.8.6/24
            nameservers:
                addresses: []
                search: []
            optional: true
         lo:
            addresses:
            - 212.72.227.83/32
            - 2a02:968:1:7:212:72:227:83/128
            - 172.31.1.100/32
            - 172.31.8.101/32
</pre>
</pre>
* controleer of de routes in de netplan file staan die nodig hebt minimaal de 2 routes uit het voorbeeld hierboven (i.v.m. VPN routering)
* geef commando '''netplan apply'''
* Nu heeft de machine de ip configuratie die jij hebt opgegeven (Als je met ssh zit ingelogd ben je uiteraard je verbinding kwijt)

Latest revision as of 13:18, 30 March 2019

pxe

Op de virtuele server 'pxe' draait een PXE-server voor installatie van debian op afstand.

Er wordt door middel van dhcp een extern IP adres uitgedeeld waarmee je een server kan herinstalleren.

Op deze pagina staat complete installatie handleiding: http://www.howtoforge.com/ubuntu_pxe_install_server

tftp

De tftp boot files staan in /var/lib/tftpboot

dhcpd

De dhcp server deelt in drie reeksen uit:

1 in de 2e interne reeks 172.31.1.0/24 van 172.31.1.140 tot 172.31.1.170
2 in de externe reeks 212.72.224.0/26 van 212.72.224.200 tot 212.72.224.210
3 in de externe reeks 212.72.229.0/26 van 212.72.224.200 tot 212.72.229.210

De config van dhcp

default-lease-time 600;
max-lease-time 600;

authoritative;

subnet 172.31.1.0 netmask 255.255.255.0 {
        range 172.31.1.140 172.31.1.170;
        filename "pxelinux.0";
        option domain-name "hobby.nl";
        option subnet-mask 255.255.255.0;
        option domain-name-servers 172.31.1.107, 172.31.1.13, 172.31.1.14;
        option routers 172.31.1.254;
 }

subnet 212.72.224.0 netmask 255.255.255.0 {
        range 212.72.224.200 212.72.224.210;
        filename "pxelinux.0";
        option domain-name "hobby.nl";
        option subnet-mask 255.255.255.0;
        option domain-name-servers 212.72.224.101, 212.72.224.22, 212.72.224.23;
        option routers 212.72.224.1;
 }

subnet 212.72.229.0 netmask 255.255.255.0 {
        range 212.72.229.200 212.72.229.210;
        filename "pxelinux.0";
        option domain-name "hobby.nl";
        option subnet-mask 255.255.255.0;
        option domain-name-servers 212.72.224.101, 212.72.224.22, 212.72.224.23;
        option routers 212.72.229.1;
 }

De client kant

Neem in de lokale DHCP server op:

subnet 192.168.10.0 netmask 255.255.255.0 {
   range 192.168.10.170 192.168.10.199;
   option subnet-mask 255.255.255.0;
   option broadcast-address 192.168.10.255;
   option routers 192.168.10.1;
   filename "pxelinux.0";
   next-server 212.72.224.24;

Het gaat om de laatste twee regels; "filename" en "next-server".

distributies

De globale bestanden voor alle distributies staan in /var/lib/tftpboot/pxelinux.cfg/

ubuntu

Versie 18.04 LTS

De installatie bestanden staan in /var/lib/tftpboot/ubuntu-installer-1804

Versie 18.10

De installatie bestanden staan in /var/lib/tftpboot/ubuntu-installer-1810

Images ophalen van externe server

De boot images worden m.b.v. het script '/var/lib/tftpboot/ubuntu-installer-1604/temp/update' van een externe server opgehaald.

cd /var/lib/tftpboot/ubuntu-installer-1804/temp/
echo Get AMD64 files
lftp -c "open http://nl.archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/ubuntu-installer; mirror amd64/"
echo Get i386 files
lftp -c "open http://nl.archive.ubuntu.com/ubuntu/dists/bionic/main/installer-i386/current/images/netboot/ubuntu-installer/; mirror i386/"
echo Move the files to the correct position
rm -fr /var/lib/tftpboot/ubuntu-installer-1804/amd64
rm -fr /var/lib/tftpboot/ubuntu-installer-1804/i386
mv amd64 /var/lib/tftpboot/ubuntu-installer-1804/
mv i386 /var/lib/tftpboot/ubuntu-installer-1804/
ls -l /var/lib/tftpboot/ubuntu-installer-1804/ -r
echo Done

debian

Versie 9.8

De installatie bestanden staan in /var/lib/tftpboot/debian-installer-98

Images ophalen van externe server

De boot images worden m.b.v. het script '/var/lib/tftpboot/debian-installer-98/tmp/update' van een externe server opgehaald.

cd /var/lib/tftpboot/debian-installer-98/tmp/
lftp -c "open ftp://ftp.nl.debian.org/debian/dists/stretch/main/installer-i386/current/images/; mirror netboot/"
lftp -c "open ftp://ftp.nl.debian.org/debian/dists/stretch/main/installer-amd64/current/images/; mirror netboot/"
rm -fr /var/lib/tftpboot/debian-installer-98/amd64
rm -fr /var/lib/tftpboot/debian-installer-98/i386
mv /var/lib/tftpboot/debian-installer-98/tmp/netboot/debian-installer/* /var/lib/tftpboot/debian-installer-98
rm -fr netboot

fedora

Fedora boot project

Bestands locaties

De installatie bestanden staan in /var/lib/tftpboot/fedora-bootproject

Images ophalen van externe server

De boot images worden m.b.v. het script '/var/lib/tftpboot/fedora-bootproject/work/doit.sh' van een externe server opgehaald.

wget -O../bfo.lkrn http://dl.fedoraproject.org/pub/alt/bfo/bfo.lkrn

CentOS

Versie 7.5

Bestands locaties

De installatie bestanden staan in /var/lib/tftpboot/centos-installer-75

Images ophalen van externe server

De boot images worden m.b.v. het script '/var/lib/tftpboot/centos-installer-75/temp/update' van een externe server opgehaald.

cd /var/lib/tftpboot/centos-installer-75/temp/i386/
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/i386/isolinux/vmlinuz
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/i386/isolinux/initrd.img
mv * /var/lib/tftpboot/centos-installer-75/i386/
cd /var/lib/tftpboot/centos-installer-75/temp/amd64/
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/x86_64/isolinux/vmlinuz
wget http://ftp.nluug.nl/ftp/pub/os/Linux/distr/CentOS/7/os/x86_64/isolinux/initrd.img
mv * /var/lib/tftpboot/centos-installer-75/amd64/

automatische installatie hobbynet

Voor hobbynet zijn er volledig voorgeconfigureerde installatie scripts, zodat de hobbynet servers op de gewenste manier worden geïnstalleerd

automatische installatie process

  • Maak VM aan (Beschijven we niet, spreekt voor zich, anders lees de vmware handleiding maar)
    Minimaal 2 cores en 2 gb geheugen is de standaard
  • Boot van pxe (bij 2 interfaces faalt de 1e meestal en start van de 2e het interne netwerk)
  • Kies in menu optie H hobbynet menu
  • Bij 1 interface (alleen intern) kies je optie B en
    bij 2 of meer interfaces kies je optie A bij (interne interface is dan de 2e netwerk kaart)
  • Vul de hostnaam in (zonder –int)
    Let op: hostnaam alleen schrijven in kleine letters
  • Wacht tot de machine gaat rebooten
  • Login met user a wachtwoord bas
  • doe "sudo -i" weer wachtwoord bas
  • geef het commando ./post-install.sh
  • wacht op reboot
  • Tijdens reboot krijg je de melding "A startup job is running for wait for Network to be Configured"
    Hierop moet je wachten (dit kan soms enkele minuten duren)
  • login met beheerders account
  • wordt root (sudo -i)
  • tip: kijk met ifconfig wat het IP adres is, login met ssh en ga verder als root
  • pas /etc/netplan/01-netcfg.yaml aan naar de netwerk configuratie (gebruik geen tabs maar spaties)
    hieronder een voorbeeld van standaard netplan file
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
        ens160:
            dhcp6: no
            accept-ra: no
            addresses:
            - 212.72.227.86/27
            - 2a02:968:1:7:212:72:227:86/64
            gateway4: 212.72.227.65
            gateway6: 2a02:968:1:7::1
            nameservers:
                addresses: []
                search:
                - hobby.nl
            optional: true
        ens192:
            addresses:
            - 172.31.1.86/24
            nameservers:
                addresses: []
                search: []
            routes:
            - to: 172.31.0.0/16
              via: 172.31.1.1
            - to: 192.168.67.0/24
              via: 172.31.1.1
            - to: 192.168.200.0/24
              via: 172.31.1.1
        ens224:
            addresses:
            - 172.31.8.6/24
            nameservers:
                addresses: []
                search: []
            optional: true
        lo:
            addresses:
            - 212.72.227.83/32
            - 2a02:968:1:7:212:72:227:83/128
            - 172.31.1.100/32
            - 172.31.8.101/32
  • controleer of de routes in de netplan file staan die nodig hebt minimaal de 2 routes uit het voorbeeld hierboven (i.v.m. VPN routering)
  • geef commando netplan apply
  • Nu heeft de machine de ip configuratie die jij hebt opgegeven (Als je met ssh zit ingelogd ben je uiteraard je verbinding kwijt)