DHCP passing options/variables to iPXE - Printable Version +- iPXE discussion forum (https://forum.ipxe.org) +-- Forum: iPXE user forums (/forumdisplay.php?fid=1) +--- Forum: General (/forumdisplay.php?fid=2) +--- Thread: DHCP passing options/variables to iPXE (/showthread.php?tid=3735) |
DHCP passing options/variables to iPXE - jpwise - 2012-08-08 11:46 Morning all. I've just over to the new built in menu support courtesy of a few examples from robinsmidsrod setup. (Thanks!) Right now however i'm working on trying to pass an alternate 'base-url' into iPXE so I can work on it from different locations. Normally the base-url is referenced to a local lan address where iPXE is run, but I also back up a copy to a webhost which I use when i'm working on tweaks from home. The base-url needs then needs to be set to the webhost address instead. I've been looking at the dhcp options that can be specified and spotted the 'scriptlet' option which looks promising as a solution, but i can't seem to find any way to actually have iPXE recognise it.. I've updated the dhcpd.conf for my home network to have the following specified: Code: option space ipxe; As I understand it, the scriptlet may actually have to point to a proper ipxe script, but if i break the boot sequence with CTRL-B after the initial undionly.kpxe load, and go into config the scriptlet variable still shows as as <not specified>. Likewise if i let it boot normally to the menu and then go into the config no change. I also tried using some other option variables with the same results. Right now i'm running the undionly.kpxe from boot.ipxe.org/undionly.kpxe, and haven't got as far as re-checking if the option is enabled in that version or not, but thought i'd ask the question since I can't find alot of information on passing variables like this. Essentially at the end of the day I don't need it to be the scriptlet variable, but basically the aim is to have the script interpret in the following manner: isset ${dhcp-url-variable} && set base-url ${dhcp-url-variable} || set base-url http://local.address.lan Thoughts? RE: DHCP passing options/variables to iPXE - mcb30 - 2012-08-08 12:05 (2012-08-08 11:46)jpwise Wrote: As I understand it, the scriptlet may actually have to point to a proper ipxe script, but if i break the boot sequence with CTRL-B after the initial undionly.kpxe load, and go into config the scriptlet variable still shows as as <not specified>. Likewise if i let it boot normally to the menu and then go into the config no change. I also tried using some other option variables with the same results. Firstly, you'll need to issue a new DHCP request from within iPXE before going into config. Secondly, the scriptlet variable is intended to contain a sequence of iPXE commands: it's an alternative to using an embedded image. It's not relevant to your situation. Use the site-local DHCP options (128-135) instead, e.g.: Code: option site-local-128 code 128 = string; and then Code: iPXE> dhcp Michael RE: DHCP passing options/variables to iPXE - jpwise - 2012-08-08 12:30 Excellent! - Exactly what I was after. I was already doing the dhcp to request the updated settings, but looks like i did miss mentioning it. Either way, the site-local-128 was exactly what i was after. Have just implemented it now and it's working a charm. Thank you again for your help. RE: DHCP passing options/variables to iPXE - mcb30 - 2012-08-14 14:45 (2012-08-08 12:30)jpwise Wrote: Excellent! - Exactly what I was after. As a follow-up note, you should also be able to use custom encapsulated options. For example: Code: option space myopts; and then, from within iPXE: Code: echo ${128.1:string} RE: DHCP passing options/variables to iPXE - jpwise - 2012-08-15 13:57 (2012-08-14 14:45)mcb30 Wrote: As a follow-up note, you should also be able to use custom encapsulated options. For example: Think i might re-tweak things a bit now i know that. Was up to 3 variables being passed for different purposes. You mentioned earlier dhcp options 128-135 were locally definable, do you now what the limit is using encapsulation? 1-255? The three variables so far for anyone thats curious are base-url, nfs-ip, and dev-menu - using iseq to display an extra menu entry if dev menu is set to 'yes'. it gives me somewhere to test new tools with and then just relocate in script to enable for everyone else. Thanks again. Jp. RE: DHCP passing options/variables to iPXE - mcb30 - 2012-08-15 14:03 (2012-08-15 13:57)jpwise Wrote: You mentioned earlier dhcp options 128-135 were locally definable, do you now what the limit is using encapsulation? 1-255? 1-254 inclusive. 0 has a special meaning as "pad byte", and 255 has a special meaning as "end of options". (255 is redundant within an encapsulated-options field, but avoid it anyway.) Michael RE: DHCP passing options/variables to iPXE - jpwise - 2012-08-15 14:13 Cool. Thank you again for the quick response and clarification. |