iPXE discussion forum
set net0.dhcp/hostname not working as expected - Printable Version

+- iPXE discussion forum (https://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: set net0.dhcp/hostname not working as expected (/showthread.php?tid=8064)



set net0.dhcp/hostname not working as expected - mysterysmith - 2016-05-08 15:53

Perhaps my expectations are off but, if I have the following script:

iPXE> dhcp
iPXE> show net0.dhcp/hostname
iPXE> net0.dhcp/hostname:string = host-192-168-100-3
iPXE> set net0/next-server 192.168.100.39
iPXE> set net0.dhcp/hostname abc.123
iPXE> show net0.dhcp/hostname:string = abc.123
iPXE> chain tftp://192.168.100.39/pxelinux.0

This works, however my Linux kickstart installation still sees host-192-168-100-3

Any ideas on what I'm doing wrong?


RE: set net0.dhcp/hostname not working as expected - mcb30 - 2016-05-10 10:07

(2016-05-08 15:53)mysterysmith Wrote:  Perhaps my expectations are off but, if I have the following script:

iPXE> dhcp
iPXE> show net0.dhcp/hostname
iPXE> net0.dhcp/hostname:string = host-192-168-100-3
iPXE> set net0/next-server 192.168.100.39
iPXE> set net0.dhcp/hostname abc.123
iPXE> show net0.dhcp/hostname:string = abc.123
iPXE> chain tftp://192.168.100.39/pxelinux.0

This works, however my Linux kickstart installation still sees host-192-168-100-3

Any ideas on what I'm doing wrong?

You are not doing anything that will pass iPXE's concept of the hostname through to your Linux OS.

You are currently going via pxelinux, so you would need to find a way to get pxelinux to pass a hostname through to your OS. If you avoid using pxelinux and instead use iPXE to load your kernel+initrd directly, then you can pass iPXE's hostname as a kernel command-line parameter. For example:

Code:
kernel vmlinuz hostname=${hostname}
initrd initrd.img
boot

If you then examine /proc/cmdline from within the running OS, you will see "hostname=abc.123" as expected.

Unfortunately, each Linux distro handles networking command-line parameters in a different way. You will need to find out what syntax your distro requires in order to set the hostname via a kernel command-line parameter.

Michael


RE: set net0.dhcp/hostname not working as expected - NiKiZe - 2016-05-10 22:43

Also it is possible to set the hostname on kernel level if ip autoconfiguration is enabled in the kernel, for details see the kernel nfsroot documentation depending on the distro it might work (depending on if there is script that overrides the kernel set hostname or ip configuration)


RE: set net0.dhcp/hostname not working as expected - bothwell - 2019-01-07 10:33

Thanks for this. I would like to ask how something similar can be done when ipxe booting a windows OS ?

can you perhaps guide me in the correct direction. basically would like
to dynamically assign computer name at boot.


[You are not doing anything that will pass iPXE's concept of the hostname through to your Linux OS.

You are currently going via pxelinux, so you would need to find a way to get pxelinux to pass a hostname through to your OS. If you avoid using pxelinux and instead use iPXE to load your kernel+initrd directly, then you can pass iPXE's hostname as a kernel command-line parameter. For example:

Code:
kernel vmlinuz hostname=${hostname}
initrd initrd.img
boot

If you then examine /proc/cmdline from within the running OS, you will see "hostname=abc.123" as expected.

Unfortunately, each Linux distro handles networking command-line parameters in a different way. You will need to find out what syntax your distro requires in order to set the hostname via a kernel command-line parameter.

Michael

[/quote]


RE: set net0.dhcp/hostname not working as expected - NiKiZe - 2019-01-07 19:14

(2019-01-07 10:33)bothwell Wrote:  Thanks for this. I would like to ask how something similar can be done when ipxe booting a windows OS ?
Could you explain how you are booting windows from iPXE?

(2019-01-07 10:33)bothwell Wrote:  can you perhaps guide me in the correct direction. basically would like
to dynamically assign computer name at boot.

AFAIK there is nothing that can do this in normal Windows from example iSCSI device.
To do this on WinPE (via wimboot) it might be possible to change the computername inside WinPE before wpeinit has run - but I have not found anything about how other than possible modifying the registry.

But it is highly likely that this isn't possible either.


RE: set net0.dhcp/hostname not working as expected - bothwell - 2019-01-07 20:01

Thanks. I am booting Windows with ISCSI device.