Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transfer boot file base on client's MAC
2014-03-07, 08:51
Post: #1
Transfer boot file base on client's MAC
Hi there,

I see this script on the homepage:

Code:
if exists user-class and option user-class = "iPXE" {
      filename "http://my.web.server/real_boot_script.php";
  } else {
      filename "undionly.kpxe";
  }

Can you show me how to make the script "real_boot_script.php" change the filename based on client's MAC ?

For example, a client with MAC aa-bb-cc-dd-ee-ff requests the DHCP. I want DHCP to transfer the boot script aa-bb-cc-dd-ee-ff.php to it. If this file is not existed, the default.php will be chose.
Find all posts by this user
Quote this message in a reply
2014-03-10, 10:58
Post: #2
RE: Transfer boot file base on client's MAC
This is how I do it with an iPXE script instead of having to declare it all in the DHCP server. https://gist.github.com/robinsmidsrod/2234639

Check boot.ipxe which optionally loads an override script for a specific machine (based on hostname, ip, uuid, mac or nic driver) and boot/testvm.ipxe which is a customization based on the hostname assigned to the machine.
Visit this user's website Find all posts by this user
Quote this message in a reply
2014-03-10, 15:01
Post: #3
RE: Transfer boot file base on client's MAC
(2014-03-07 08:51)vielktus Wrote:  Can you show me how to make the script "real_boot_script.php" change the filename based on client's MAC ?

You can include ${mac} within the DHCP filename, e.g.:

Code:
filename "http://my.web.server/boot.php?mac=${mac}";

Alternatively, you can use an iPXE script. This gives you the option to fall back to an alternative script if the one you want doesn't exist. For example:

Code:
#!ipxe
chain http://my.web.server/${mac:hexhyp}.php || chain http://my.web.server/default.php

(Note the use of the ":hexhyp" settings type to obtain the MAC address with hyphen separators rather than colons, since colons are generally not valid in filenames.)

Michael
Visit this user's website Find all posts by this user
Quote this message in a reply
2014-03-23, 13:44
Post: #4
RE: Transfer boot file base on client's MAC
The "mac:hexhyp" and "github" saved my day.
Thank you so much mcb30 and robin.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)