|
|
(8 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
− | NetBoot using PXE and TFTP.
| + | [[Category:Linux]] |
| | | |
− | This will boot using an official installation image.
| + | NetBoot using PXE and TFTP. See [[NetBoot server principle]] |
| | | |
− |
| |
− | Reminder:
| |
− |
| |
− | * NetBoot requires a DHCP server
| |
− | * TFTP is NOT secure at all. You should only use it into your internal network !!
| |
− |
| |
− | => Don't forget to adjust your firewall rules
| |
− |
| |
− |
| |
− |
| |
− | =Installation=
| |
− |
| |
− | '''Trivial FTP (TFTP) client'''
| |
− | <syntaxhighlight lang="bash">
| |
− | apt-get install tftp-hpa
| |
− | </syntaxhighlight>
| |
− |
| |
− | '''Trivial FTP (TFTP) server'''
| |
− | <syntaxhighlight lang="bash">
| |
− | apt-get install tftpd-hpa
| |
− | </syntaxhighlight>
| |
− |
| |
− | '''SysLinux [netboot utilities]'''
| |
− | <syntaxhighlight lang="bash">
| |
− | apt-get install syslinux mtools initramfs-tools
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− | Syslinux contains some starter files you can use for your netboot clients.
| |
− |
| |
− |
| |
− |
| |
− | =Configuration=
| |
− |
| |
− |
| |
− | ==TFTP configuration==
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | vim /etc/default/tftpd-hpa
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− | The TFTP server files, = the files that will be used by the TFTP clients, are in the "TFTP_DIRECTORY" instruction.
| |
− |
| |
− | By default ''tftpd-hpa'' uses '''/var/lib/tftpboot'''
| |
− |
| |
− | !! You should not change the default user or port number if you plan to use NetBoot !!
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | service tftpd-hpa restart
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− | ==Firewall configuration==
| |
− |
| |
− | Adjust your firewall script and add the following rules:
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | IPTABLES=`which iptables`
| |
− | LAN_ADDRESS="172.16.50.0/24"
| |
− |
| |
− | $IPTABLES -A INPUT -p udp -s $LAN_ADDRESS --dport 69 -j ACCEPT
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− |
| |
− | ==Test the server==
| |
− |
| |
− | 1. Create a file on the server
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | vim /var/lib/tftpboot/hello.txt
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− |
| |
− | 2. Connect to the server
| |
− |
| |
− | Install TFTP client:
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | apt-get install tftp-hpa
| |
− | </syntaxhighlight>
| |
− |
| |
− | Connect to the server and get file:
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | tftp 192.168.1.156
| |
− | get hello.txt
| |
− | quit
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− | Check the received file:
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | cat hello.txt
| |
− | </syntaxhighlight>
| |
| | | |
| | | |
Line 117: |
Line 19: |
| | | |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
− | cd /var/lib/tftpboot/ | + | cd /tftpboot/ |
− | mkdir amd64 | + | mkdir rescue |
− | cd amd64 | + | cd rescue |
| wget http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/netboot.tar.gz | | wget http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/netboot.tar.gz |
| tar -xzvf netboot.tar.gz | | tar -xzvf netboot.tar.gz |
| rm netboot.tar.gz | | rm netboot.tar.gz |
| </syntaxhighlight> | | </syntaxhighlight> |
| + | |
| + | |
| | | |
| | | |
Line 146: |
Line 50: |
| # These files should be at the root of your TFTP server | | # These files should be at the root of your TFTP server |
| # Note: The file name can be add in the "host" section too. Then, the "host" will override the current setting | | # Note: The file name can be add in the "host" section too. Then, the "host" will override the current setting |
− | filename "amd64/pxelinux.0"; | + | filename "rescue/pxelinux.0"; |
| # set the server that serve this NETBOOT file | | # set the server that serve this NETBOOT file |
| next-server 172.16.50.2; | | next-server 172.16.50.2; |
Line 154: |
Line 58: |
| | | |
| | | |
− | Mind the "amd64/" in the ''filename'' section. | + | Mind the "rescue/" in the ''filename'' section. |
| | | |
| | | |
Line 167: |
Line 71: |
| | | |
| | | |
− |
| |
− |
| |
− | =Custom NetBoot configuration=
| |
− |
| |
− |
| |
− | ==Basic configuration==
| |
− |
| |
− | You can setup your own netboot configuration.
| |
− |
| |
− | To do so, you can re-use one of the syslinux templates:
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | # Create folders
| |
− | mkdir /var/lib/tftpboot/custom
| |
− | mkdir /var/lib/tftpboot/custom/pxelinux.cfg
| |
− |
| |
− | # Create configuration files
| |
− | cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot/custom
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− | The ''pxelinux.cfg'' folder is mandatory. Inside you can provide:
| |
− | * configuration for a specific IP @ or hostname
| |
− | * configuration for a group
| |
− | * default configuration (required)
| |
− |
| |
− |
| |
− | Create the default configuration file:
| |
− | <syntaxhighlight lang="bash">
| |
− | vim /var/lib/tftpboot/custom/pxelinux.cfg/default
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− | Put the following:
| |
− | <syntaxhighlight lang="bash">
| |
− | # Ubuntu 14.04
| |
− | LABEL TRUSTY
| |
− | kernel trusty/vmlinuz
| |
− | initrd trusty/initrd.img
| |
− |
| |
− | # Prompt user for selection
| |
− | PROMPT 0
| |
− |
| |
− | TIMEOUT 30
| |
− | </syntaxhighlight>
| |
− |
| |
− | * Each LABEL is a specific configuration that will displayed on the NetBoot menu.
| |
− | * PROMPT 1 = enable user prompt so you can choose the configuration
| |
− | * TIMEOUT 30 = timeout (in seconds) before the default option is choosen
| |
− |
| |
− |
| |
− | Note that I used a reference to "trusty/", that's a folder I need to create later on.
| |
− |
| |
− |
| |
− |
| |
− | ==Create boot files==
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | mkdir /var/lib/tftpboot/custom/trusty
| |
− | # Copy current boot files
| |
− | cp /boot/vmlinuz-3.2.0-4-amd64 /var/lib/tftpboot/custom/trusty/
| |
− | cp /boot/initrd.img-3.2.0-4-amd64 /var/lib/tftpboot/custom/trusty/
| |
− | # Create symlinks
| |
− | ln -s /var/lib/tftpboot/custom/trusty/vmlinuz-3.2.0-4-amd64 /var/lib/tftpboot/custom/trusty/vmlinuz
| |
− | ln -s /var/lib/tftpboot/custom/trusty/initrd.img-3.2.0-4-amd64 /var/lib/tftpboot/custom/trusty/initrd.img
| |
− | </syntaxhighlight>
| |
− |
| |
− |
| |
− |
| |
− | =TFTP management=
| |
− |
| |
− | Just use the "service" command:
| |
− |
| |
− | <syntaxhighlight lang="bash">
| |
− | service tftpd-hpa {status|restart|start|stop}
| |
− | </syntaxhighlight>
| |
| | | |
| | | |
NetBoot using PXE and TFTP. See NetBoot server principle
Setup NetBoot files
Use an Ubuntu ISO image as NetBoot
Download the latest Ubuntu netboot image for the target architecture(s) from: http://cdimage.ubuntu.com/netboot/
You have to take the netboot.tar.gz archive.
cd /tftpboot/
mkdir rescue
cd rescue
wget http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/netboot.tar.gz
tar -xzvf netboot.tar.gz
rm netboot.tar.gz
Register files in DHCP server
Edit your DHCP server configuration:
Adjust it like that:
#### NETBOOT settings
# PXE file to serve.
# >> elilo.efi => for ia64 clients;
# >> pxelinux.0 => for x86
# These files should be at the root of your TFTP server
# Note: The file name can be add in the "host" section too. Then, the "host" will override the current setting
filename "rescue/pxelinux.0";
# set the server that serve this NETBOOT file
next-server 172.16.50.2;
# Ensure that the new client (the one booting) is not stealing someone else IP @
ping-check = 1;
Mind the "rescue/" in the filename section.
You can always override that setting later on for each host.
Restart the DHCP server
service isc-dhcp-server restart
Next step: Diskless server / workstation