www.zeroshell.org Forum Index www.zeroshell.org
Linux Distribution for server and embedded devices
 SearchSearch  RegisterRegister  UsergroupsUsergroups 
 ProfileProfile  Log inLog in  Log in to check your private messagesPrivate Message 

DHCP Global Options HowTo (or, using gPXE with Zeroshell)

Post new topic   Reply to topic    www.zeroshell.org Forum Index -> ZeroShell
View previous topic :: View next topic  
Author Message

Joined: 07 Jun 2011
Posts: 1

PostPosted: Tue Jun 07, 2011 3:19 am    Post subject: DHCP Global Options HowTo (or, using gPXE with Zeroshell) Reply with quote

DHCP Global Options HowTo
(or, How to Make gPXE or iPXE work with Zeroshell)

  • The situation:
    Zeroshell is my network-wide DHCP server.
    I have an iSCSI device presenting iSCSI disk LUNs to my network.
    I want a diskless, thin client PC that can boot from the iSCSI disks provided.

  • The method:
    Booting from an iSCSI device (or any other device) requires a bootloader to make the initial connections before passing control to your OS.
    IDE Hard drives have the initial bootloader in BIOS, SCSI hard drives have the BIOS addon on the SCSI card, network booting has PXE.
    However, PXE booting requires specialized server software (for Windows) and is fairly limited in what it can boot. Enter gPXE (now iPXE [http://www.ipxe.org]). This has extended the standard PXE environment to boot by many other network methods, including attaching an iSCSI disk LUN and booting from it as if it were a local disk. There are also many ways to start gPXE or iPXE, including USB, ISO, or (easiest for me) a network option ROM that replaces the standard PXE boot ROM.

  • The problem:
    gPXE (and iPXE) get their configuration settings for where and how to boot from the DHCP server, as DHCP options. A few settings, such as "root-path" or "filename", are defined and available by use in ISC DHCPd, used in ZeroShell. However, many are not. They are custom options defined and encapsulated in an unused DHCP option, option 175. In order to use these settings, they must first be defined in the global area of dhcp.conf (see http://www.ipxe.org/howto/dhcpd).
    Zeroshell does not allow that. Yes, advanced options (custom settings like this) are available, but as part of a subnet definition, not global, which is where these settings must be defined.
    Manually editing the dhcp.conf file is ALSO available, but a reboot or ANY changes to your DHCP settings in the GUI will wipe it out.

  • The solution:
    In a method identical to the "Subnet Advanced Options", store my "Global Advanced Options" in a separate file and modify the scripts to include them when rebuilding dhcp.conf. The chosen insert point was just after the default global options were added, inserting a line into the script to read the contents of the extra file and add them to the configuration. Also, the advanced options testing script creates a temporary dhcp.conf to use as well, so the same line must be inserted there as well.

    • The DHCP configuration file, dhcp.conf, is stored at:
      $REGISTER/system/dhcp/dhcp.conf (/Database/var/register/system/dhcp/dhcp.conf)
    • The DHCP configuration build script, dhcp_configfile, is stored at:
      /root/kerbynet.cgi/scripts/dhcp_configfile (in RAM)
    • The "Subnet Advanced Options" Test script, dhcp_checkopt, is located at:
      /root/kerbynet.cgi/scripts/dhcp_checkopt (in RAM)
    • The "Subnet Advanced Options" config file, Parameters, is located at:
    • The NEW "Global Advanced Options" config file, Global_Parameters, is located at:
      $REGISTER/system/dhcp/Global_Parameters (/Database/var/register/system/dhcp/Global_Parameters)

Modification steps:

  1. Add the following code to your preboot script:
    # Patch DHCP config scripts to include a Global_Parameters section, and pass config testing
    touch /Database/var/register/system/dhcp/Global_Parameters
    sed -i 's/^EOF$/EOF\ncat \$REGISTER\/system\/dhcp\/Global_Parameters/g' /root/kerbynet.cgi/scripts/dhcp_configfile
    sed -i 's/echo \"ignore client-updates;\" >>\$FILE/echo \"ignore client-updates;\" >>\$FILE\ncat \$REGISTER\/system\/dhcp\/Global_Parameters >>\$FILE/g' /root/kerbynet.cgi/scripts/dhcp_checkopt

  2. Using your favorite method, create your /Database/var/register/system/dhcp/Global_Parameters file. Mine is:
      # iPXE Options for hosts
      option space ipxe;
      option ipxe-encap-opts code 175 = encapsulate ipxe;
      option ipxe.priority code 1 = signed integer 8;
      option ipxe.keep-san code 8 = unsigned integer 8;
      option ipxe.skip-san-boot code 9 = unsigned integer 8;
      option ipxe.no-pxedhcp code 176 = unsigned integer 8;
      option ipxe.bus-id code 177 = string;
      option ipxe.bios-drive code 189 = unsigned integer 8;
      option ipxe.username code 190 = string;
      option ipxe.password code 191 = string;
      option ipxe.reverse-username code 192 = string;
      option ipxe.reverse-password code 193 = string;
      option ipxe.version code 235 = string;
      option iscsi-initiator-iqn code 203 = string;
      # iPXE Feature indicators
      option ipxe.pxeext code 16 = unsigned integer 8;
      option ipxe.iscsi code 17 = unsigned integer 8;
      option ipxe.aoe code 18 = unsigned integer 8;
      option ipxe.http code 19 = unsigned integer 8;
      option ipxe.https code 20 = unsigned integer 8;
      option ipxe.tftp code 21 = unsigned integer 8;
      option ipxe.ftp code 22 = unsigned integer 8;
      option ipxe.dns code 23 = unsigned integer 8;
      option ipxe.bzimage code 24 = unsigned integer 8;
      option ipxe.multiboot code 25 = unsigned integer 8;
      option ipxe.slam code 26 = unsigned integer 8;
      option ipxe.srp code 27 = unsigned integer 8;
      option ipxe.nbi code 32 = unsigned integer 8;
      option ipxe.pxe code 33 = unsigned integer 8;
      option ipxe.elf code 34 = unsigned integer 8;
      option ipxe.comboot code 35 = unsigned integer 8;
      option ipxe.efi code 36 = unsigned integer 8;
      option ipxe.fcoe code 37 = unsigned integer 8;

  3. Execute /root/kerbynet.cgi/scripts/dhcp_createconfig to create and activate your dhcp.conf (or reboot).

Now you can use these options in your host definitions, such as this one:

  • Description: Virtual Machine for Diskless Boot
  • Fixed IP: xx.xx.xx.126
  • MAC Address: 00:50:56:28:60:7E
  • Options:

    # Only give this data to iPXE clients (replace with gPXE if using the older client)
    if exists user-class and option user-class = "iPXE" {
      # Set iSCSI machine as router to avoid a wierd iSCSI routing error
      option routers xx.xx.xx.127;
      # Keep iSCSI drive connection mounted when control is transferred to OS
      option ipxe.keep-san 1;
      # Set blank if booting direct to drive, avoids boot conflict
      filename "";
      # Set iSCSI path to boot from (format iscsi:<servername>:[protocol]:[port]:[LUN]:<targetname>)
      # Empty [protocol] is TCP, empty [port] is 3260, empty [LUN] is 0
      # <targetname> is set on iSCSI target and is the target you wish to boot from
      option root-path "iscsi:xx.xx.xx.127::::iqn-of-server:boot-target";

Back to top
View user's profile Send private message

Joined: 29 Mar 2012
Posts: 10

PostPosted: Fri Apr 06, 2012 1:04 pm    Post subject: Reply with quote

Thank you very much!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    www.zeroshell.org Forum Index -> ZeroShell All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group