loading...

iPXE chainloading to use dnsmasq and proxydhcp

arachan profile image Yusuke arakawa ・5 min read

I want to try chainloading.
tftp is very slow and to transfer a little data.
http is fast and to able to transfer more heavy data.
It is underline figure that chainloading.

LAN Boot > dhcp-boot > undionly.kpxe from tftpd > boot_menu.ipxe from local httpd > global httpd boot

Environment

I'm not Network Administrator.
I cannot change DHCP-Server Setting.
So, I use Proxy DHCP.

The proxyDHCP server providing TFTP server IP address and name of the NBP only to PXE identified booting clients. 1

To use proxyDHCP Major software is Dnsmasq.
Dnsmasq provides network infrastructure.
Dnsmasq provides network boot and proxy-dhcp,too.
I use only network boot and proxy-dhcp.
Dnsmasq can install to use yum or apt-get.

  • Server
    • Debian Wheezy (Linux pxeserver 3.2.0-4-amd64 #1 SMP Debian 3.2.78-1 x86_64 GNU/Linux)
    • ECS 945GCT-M
    • Intel(R) Pentium(R) Dual CPU E2160 @1.80GHz
    • Dnsmasq 2.62-3+deb7u3
    • Proxy DHCP
    • iPXE (undionly.kpxe)
  • Clilent
    • Desktop PC
    • ECS G45T-M5
    • Realtec PCIe GBE Family Controller
    • Intel UNDI,PXE-2.0 (bulid 082)
    • Realtek RTL8139(A/B/C)/RTL8130 PCI Fast Ethernet Controller v2.11
  • Network
    • 172.20.0.0/16
    • GW
    • 172.20.0.254
    • DHCP-Server
    • 172.20.0.70

Setup

  1. dnsmasq install
  2. dnsmasq config Setting
  3. iPXE Source Get from git
  4. iPXE Build to undionly.kpxe
  5. deploy undionly.kpxe
  6. web boot ipxe menu
  7. Let's try boot.

Dnsmasq

At First,
I install dnsmasq.
I often use debian and ubuntu.
CentOS/RedHat's dnsmasq is same package name and same configuration file destination.

install

Debian/Ubuntu

$ sudo apt-get install dnsmasq

Redhat/CentOS

$ sudo yum install dnsmasq

Settings

Debian/Ubuntu/CentOS/Redhat

$ cat /etc/dnsmasq.conf | grep -v -e ^# -e ^$
dhcp-range=172.20.0.0,proxy
dhcp-boot=tag:!ipxe,undionly.kpxe,172.20.0.225
dhcp-match=set:ipxe,175 # gPXE/iPXE sends a 175 option.
dhcp-boot=tag:!ipxe,undionly.kpxe
dhcp-boot=http://172.20.0.225/a.ipxe,172.20.0.225,172.20.0.225
pxe-service=tag:!ipxe,x86PC,"splash",undionly.kpxe
enable-tftp
tftp-root=/var/ftpd
log-queries
conf-dir=/etc/dnsmasq.d

iPXE

It is easy to download from undionly.kpxe.
But I want to build source over one years age.
undionly.kpxe to build from source show parent code,
when chainloading.
I want to check parent hash code.
I want to check fix date from parent hash code.
So, I get source form git repository and build it.

Get Source

I need to install git.
I install git-core As described below

$ sudo apt-get install git-core

I need underline package to build iPXE.

  • gcc
  • binutils
  • make
  • perl
  • syslinux
  • liblzma
  • xz

I install underline.

$ sudo apt-get install gcc,binutils,make,perl
$ sudo apt-get install syslinux,lzma-dev,liblzma5

I get ipxe source to my current directory from git repository.

I execute git as underline.

$ cd ~
$ git clone git://git.ipxe.org/ipxe.git

Build

It is ipxe direcotry in current directory.
I enter into ipxe direcotry as underline and build undionly.kpxe.

$ cd ~/ipxe/source
$ make bin/undionly.kpxe

deploy

$ cd ~/ipxe/source
$ mv bin/undionly.kpxe /var/ftpd

httpd

I prepare apache2.

You may prepare httpd that you like nginx, perl's or python's simple one liner web server...etc.

Install

$ sudo apt-get install apache2

DocumentRoot

Debian and Ubuntu's apache2 is virtual host default on.
Default DocumentRoot is /var/www.

Check virtual hosts

$ cat /etc/apache2/apache2.conf | grep sites-enabled
#       `-- sites-enabled
# * Configuration files in the mods-enabled/ and sites-enabled/ directories
Include sites-enabled/

Check DocumentRoot

$ cat /etc/apache2/sites-enabled/000-default | grep DocumentRoot
        DocumentRoot /var/www

Boot Menu

I move web deploy folder, /var/www/.

I make boot.ipxe to use Editor.

Please,show underline.

$ sudo cd /var/www
$ sudo vi boot.ipxe
#!ipxe
menu install menu
item ubuntu Ubuntu installation
item centos7 Centos7 installation
item --gap
item back install menu
choose --timeout 20000 --default back target && goto ${target} || goto menu

:ubuntu
set ubuntu http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
initrd ${ubuntu}/initrd.gz
kernel ${ubuntu}/linux tasks=standard vga=788 -- quiet
boot

:centos7
set centos7 http://mirror.centos.org/centos/7/os/x86_64
initrd ${centos7}/image/pxeboot/initrd.img
kernel ${centos7}/image/pxeboot/vmlinuz vga=788 repo=${centos7}
boot

:back
exit

and Save boot.ipxe.

PXE Boot

Prepared OK!

I switch on Client PC.
First, BIOS show up.
show underline.
I want to show BBS(BIOS Boot Screen).
So,soon I press F11 Key when PC boot.

American
Megatrends

AMIBIOS(C) 2008 American Megatrends. Inc.
G43T-M5 BIOS Release 09/28/2009 for MCJ
CPU : Intel(R) Celeron(R) CPU E3300 @ 2.5GHz

Press DEL to run Setup
Press F11 for BBS POPUP
The MCH is operation with DDR2 800
DRAM Timing: Tcl:6/Tras:18/Trcd:6/Twr:6/Trfc:52/Twtr:3/Trrd:3/Trtp:3
Single Chanel Mode
2048MB OK (64MB Shared Memory SIze Used)
Auto-Detecting Pri Slave...IDE Hard Disk
Auto-Detecting 3rd Master..ATAPI CDROM
Pri Slave : SAMSUNG HD252HJ 1AC01118
            Ultra DMA Mode-5, S.M.A.R.T. Capable and Status OK
3rd Master: HL-DT-ST DVDDAM GH24NS50 XP01
            Ultra DMA Mode-5

client show BIOS Boot Screen.

I select Realtec Boot Agent and press Enter Key.

Press select boot device:
---------------------------
   SAMSUNG HD252HJ
   HL-DT-ST DVDRAM GH24NS50
   Genetic USB SD Reader
   Genetic USB CF Reader
   Genetic USB SM Reader
   Genetic USB MS Reader
-> Realtec Boot Agent

---------------------------
^ and ^ to menu selection
ENTER to select boot device
ESC to boot using defaults

Client change display.

Realtec RTL8111B/8111C Gigabit Boot Agent
Press Shift-F10 to configure ..........

Start PXE Boot Conlose.

Intel UNDI. PXE-2.1 (build 002)
Copyright (C) 1997-2000 Intel Corporation

For RealTek RTL8111B/8111C Gigabyte Ethernet Controller v2.14(000225)

CLIENT MAC ADDR: 00 25 11 CB 41 1B GUID 00020003-0004-0005-0006-00700080009
CLIENT IP: 172.20.10.83 MASK 255.255.0.0
DHCP IP: 172.20.0.70 PROXY IP:172.20.0.225
GATEWAY IP: 172.20.0.254

Auto-Select:
     splash

BOOT SERVER IP : 172.20.0.225

PXE-EB: !PXE at 9C3E:0070,entry point at 9C3E:0109
             UNDI code segment 9C3E:1A7A, data segment 923D:A010 (584-632kB)
             UNID device is PCI 02:00.0, type DIX+802.3
             584kB free base memory after PXE unload
iPXE initialising devices...ok

iPXE 1.0.0+ (55e4) -- Open Source Network Boot Firmware -- http://ipxe.org
Features: DNS HTTP iSCSI TFTP AoE ELF MBOOT PXE bzImage Menu PXEXT

Press Ctrl+B for the iPXE command line...

Boot Menu from Web Server.

Select Ubuntu installation or CentOS7 installation and Press Enter key.

Linux Installer boot from internet resource.

            Install Menu

Ubuntu installation
CentOS7 installation


References


  1. Preboot_Execution_Environment Integration Section 

Discussion

pic
Editor guide