NOTE: I’m gonna make reference to “CD” a lot in this post. Replace “CD” with basically any round disc based media that may be appropriate.

Every time someone makes a post somewhere about “burn an ISO to a CD” or “Just make a bootable USB flash drive” I laugh. The amount of work/waste behind it is laughable. Not to mention that once a CD is burnt, it’s forever. Unless you have a rewritable, but those are expensive. Plus you need pesky CD drives. Or spare USB Flash Drives. With the advent of the internet and Dropbox (Shameless referral link. If you don’t have Dropbox by now, please sign up using the link. You get an additional 250MB if you use the referral.) there’s very little use for flash drives any more.
And with those new fangled netbooks not having CD Drives and external CD drives costing money, there’s more and more reason to have your own PXE server.

Having a little server somewhere serving up all sorts of bootable goodness is frickin’ awesome. No more hunting for that stack of blank CDs or using program after program to make that USB Flash Drive bootable. Plus if you have some of the fancier IP phones, you can auto provision the device via TFTP. But that’s another show.
Here’s a step by step tutorial on how to get your own PXE server.

Before you get started, make sure that the DHCP server on your network supports DHCP Option 66 and 67. Mikrotik and pfSense both support this. Consumer routers do not. Some 3rd party firmwares might. I’ll cover configuration on Mikrotik and pfSense. Otherwise you’ll have to also install a DHCP server that does.

First, set up a server with Debian Squeeze on it. It doesn’t matter what kind of server, but in this case a Virtual Machine is probably best. Unless you have a room full of techs, this machine will probably sit idle 99.99% of the time. At least if it’s on a Virtual Server, the host can allocate most of the cycles elsewhere when it’s idle.

Let’s get all the packages installed.

apt-get install tftpd-hpa syslinux unzip

You could use dnsmasq if you like, especially if you have a router with a DHCP server that fails. But for simplicity sake, this tutorial will use tftpd-hpa.

tftpd-hpa is gonna ask where you want to serve files up from. The default location is fine. Change it if you like.
Bonus points if you have a file server mounted and have it serving up files from a directory there. This way you don’t have to screw with SCP. For now, we’ll leave it as /srv/tftp

Let’s make sure TFTP is running.

netstat -a | grep tftp

If you see something like

udp 0 0 *:tftp *:*

you’re good to go.

Time to copy some basic files and make a directory:

mkdir /srv/tftp/pxelinux.cfg
cp /usr/lib/syslinux/pxelinux.0 /srv/tftp
cp /usr/lib/syslinux/menu.c32 /srv/tftp
cp /usr/lib/syslinux/memdisk /srv/tftp
cp /usr/lib/syslinux/mboot.c32 /srv/tftp
cp /usr/lib/syslinux/chain.c32 /srv/tftp
touch /srv/tftp/pxelinux.cfg/default

Now edit /srv/tftp/pxelinux.cfg/default and shove this in it:

default menu.c32
prompt 0
timeout 100
ONTIMEOUT local
MENU TITLE Main Menu

LABEL local
        MENU LABEL --Boot Local Disk--
        LOCALBOOT 0

You’ll need to add more to this file later. This is basically a placeholder until we fill it with useful stuff.
This file basically just tells PXE to boot from the local disk, so you can leave all your machines with network booting enabled. After 10 seconds (or however many 1/10th of a second you specify as a timeout) it automatically chooses whatever label is specified in “ONTIMEOUT”. For most people, Local Disk is best, but if you have some sort of network bootable OS, you’d want to change it to that.

Now is a good time to make note of the IP of your TFTP server, and perhaps give it a static entry in your DHCP server.
For those COMPLETELY new to Linux, the command is:

ifconfig

The TFTP side is finished, so it’s time to setup routers.
As I mentioned, consumer routers don’t have this capability. Some of the better consumer routers that support 3rd party firmwares MAY have this capability, but I cannot guarantee it.
Since I it’s my article, I’m only listing instructions for DH Stamp-of-Approval equipment.
So here’s Mikrotik and pfSense:

Mikrotik:
Login to your router. Assuming the firmware is up to date enough, just use webfig. Otherwise you’ll have to Winbox.

http://[URL of Mikrotik]/webfig/#IP:DHCP_Server.Networks.1

(If that link doesn’t work, login to Winbox/WebFig -> IP -> DHCP Server -> Networks -> [Double Click First Network]

Set “Next Server” and “Boot File Name” to look like this:

pfSense 2.0:
Log into pfSense.

https://[IP of pfSense]/services_dhcp.php

If that doesn’t work, it’s under Services -> DHCP Server

Scroll down to network booting. Change it to look like this:

That’s pretty much it. Obviously this is only the beginning, since the only thing it currently does is ask you if you want to boot from the local disk. Part 2 will include entries for booting various network tools and how to boot ISOs. Windows will have to wait til Part 3 as they’re always 1000x more complicated than it needs to be.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

 
   
© 2012 The Mind of DH Suffusion theme by Sayontan Sinha