iPXE discussion forum

Full Version: Boot based on MAC
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to have clients boot from a specific server based on their MAC address. I have tried using this script:

Code:
#!ipxe

ifopen

:mac-check
iseq ${netx/mac} EC:A8:6B:F5:44:9F && goto server2 ||

:server1
imgfree
echo Attempting to boot from Server 1
kernel tftp://192.168.1.11/ltsp/i386/vmlinuz root=/dev/nbd0 init=/sbin/init-ltsp vt.handoff=7 nbdroot=192.168.1.11:ltsp_i386 || goto second
initrd tftp://192.168.1.11/ltsp/i386/initrd.img || goto second
boot ||

:server2
imgfree
echo Attempting to boot from Server 2
kernel tftp://192.168.1.12/ltsp/i386/vmlinuz root=/dev/nbd0 init=/sbin/init-ltsp vt.handoff=7 nbdroot=192.168.1.12:ltsp_i386 || goto first
initrd tftp://192.168.1.12/ltsp/i386/initrd.img || goto first
boot || goto first

But the client with MAC address EC:A8:6B:F5:44:9F still boots from server1, not server2 as it should. Where am I going wrong?
You need to use netX, not netx.
Thank you! The devil's in the details Wink

Working perfectly now, magic.

Here's the script for anyone who wants to do anything similar:

Code:
#!ipxe

ifopen

:mac-check
iseq ${netX/mac} ec:a8:6b:f5:45:94 && goto server2 ||                   #PC10

:server1
imgfree
echo Attempting to boot from Server 1
kernel tftp://192.168.1.11/ltsp/i386/vmlinuz root=/dev/nbd0 init=/sbin/init-ltsp vt.handoff=7 nbdroot=192.168.1.11:ltsp_i386 || goto server2
initrd tftp://192.168.1.11/ltsp/i386/initrd.img || goto server2
boot ||

:server2
imgfree
echo Attempting to boot from Server 2
kernel tftp://192.168.1.12/ltsp/i386/vmlinuz root=/dev/nbd0 init=/sbin/init-ltsp vt.handoff=7 nbdroot=192.168.1.12:ltsp_i386 || goto server1
initrd tftp://192.168.1.12/ltsp/i386/initrd.img || goto server1
boot || goto server1
Reference URL's