Tue, 31 Mar 2009

pxebooting on centos/rhel

Setting up pxebooting is simple and incredibly useful. To do so you need to install a dhcp server and a tftp server, and a dns server fairly nice in this situation as well.


So step 1, install a dhcp server

 # yum install dhcp 

configuration is fairly simple, a config like this is fine
ddns-update-style interim;
ignore client-updates;
option domain-name                              "example.domain";

subnet 10.0.42.0 netmask 255.255.255.0 {
        range   10.0.42.20      10.0.42.250;
        option subnet-mask                              255.255.255.0;
        option domain-name-servers              10.0.42.1;
        next-server     10.0.42.1;	#ip of tftp server
        filename "pxelinux.0";		#filename that will be grabbed from tftp
        default-lease-time                              3600;
        max-lease-time                                  7200;
}

also a few notes on the dhcp config, next-server isnt explictly required if dhcp and tftp are on the same box, but it doesnt hurt to specify. Also dhcpd will only run on interfaces that are on dhcp hosted subnets.

Next up is installing and configuring tftp
install tftp with yum

 # yum install tftp-server 

this will also install xinetd, running tftp off this is simple, as is configuration
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

pretty much all that needs to be done here is the disable line to "no" from "yes"

now its just setting up files, copy pxelinux.0 from /usr/lib/syslinux/

# cp /usr/lib/syslinux/pxelinux.0 /tftpboot 

note, /tftpboot will be created when you install tftp-server. At this point its a good idea to test your tftp setup.
 tftp ip.of.server
	tftp> get pxelinux.0

now pxelinux config needs to be setup, create a directory called "pxelinux.cfg" and put a file inside called "default". default should look something like this:
prompt 1
default basic
timeout 100

label basic
kernel kernfile
append initrd=initrd.img ramdisk_Size=9216

kernfile and the initrd.img mentioned in the config should be copied into /tftpboot . at this point its time to fire up a machine to test with, if things dont boot up , try testing with the dhcp options with scapy's dhcp_request function

posted at: 06:56 | Tags | path: /sysadmin | permanent link to this entry