« HOWTO: Setup and install NUT to work with FedoraHOWTO: Setup dnsmasq on Fedora as DNS DHCP and tftp for PXE »

HOWTO: setup a pxe server on Fedora with dnsmasq

17/07/11

HOWTO: setup a pxe server on Fedora with dnsmasq

To setup a PXEserver with dnsmasq and fedora is really simple the second time :D. This is how I do mine.

Setup dnsmasq so it is providing DNS and DHCP first. See my mini HOWTO.

decide where you are going to put the files for your PXE server. The files I mean are the copies of the install CD/DVD, the menus and configuration for the tftp server. I put mine in tftp and then in sub directories pxeboot and webroot. Create the empty directory structure now. From now on when I refer to pxeboot I mean /tftp/pxeboot and for webroot I mean /tftp/webroot. Also when I'm talking about http://localhost you can substitute the local ghost for a host name or IP address.

We will be needing a working HTTP server I use Apache as it is already used for a number of other things on my server/Nas machine. without further ado lets get on! Install apache, in fedora the package is called httpd.

sudo yum install httpd

The web server should have it's root directory pointing at /tftp/webroot. The simplest config file for this is

/etc/httpd/conf.d/pxe_webroot.conf
&lt&#59;Directory /tftp/webroot/>
</Directory>
Alias           /webroot        /tftp/webroot

sudo service httpd start

To test the basic http service use the url http://localhost you should see the Fedora Apache web page.

To test the webroot directories, lets create a simple index.html page and check it displays in a browser. Create the file /tftp/webroot/index.html with the following text. Save it so it is readable by everyone.

/tftp/webroot/index.html
<html><body><h1> Default Webroot start page</h1>
<p>This is the default web page for the webroot server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>

Now reload the apache configuration

sudo service httpd reload

in your browser use the URL http://localhost/webroot/ and you should see the text from the index.html you save above. If you do not you did it wrong, please try again and follow all the steps in order.&amp;#58;&amp;#62;

One more test to check that weget is working as expected. go to your HOME directory and get the index.html file from webroot.

cd
wget
">http://localhost/webroot/index.html[/khakisample]

This should look something like this

$ wget http://localhost/webroot/index.html
--2011-07-17 09:51:35--  http://localhost/webroot/index.html
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5533 (5.4K) [text/html]
Saving to: `index.html'
100%[=====================================================>] 5,533       --.-K/s   in 0s      
2011-07-17 09:51:35 (178 MB/s) - `index.html' saved [5533/5533]

Configuration for dnsmasq for a tftp server

To change a working install of Dnsmasq to work as a PXE server we need to turn on a few settings.

Edit the file /etc/dnsmasq.conf to turn on the following options, seethe comments in the file for what they do.

/etc/dnsmasq.conf
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/tftp/pxeboot

get dnsmasq to reload the changes

sudo service dnsmasq restart

Creating the PXE server content

Download the latest Fedora installation DVD, not the live CD. This needs to be copied to webroot. I have a subdirectory structure that allows for continuous expansion and makes it easy to update from one version to another.

webroot
|-- common_files
|   |-- mailserver
|   `-- scripts
|-- f14
|   |-- i386
|   |   |-- files
|   |   |-- img
|   |   |   |-- EFI
|   |   |   |-- images
|   |   |   |-- isolinux
|   |   |   |-- Packages
|   |   |   `-- repodata
|   |   `-- ks
|   `-- x86_64
|       |-- files
|       |-- img
|       |   |-- EFI
|       |   |-- images
|       |   |-- isolinux
|       |   |-- Packages
|       |   `-- repodata
|       `-- ks
`-- f15
    `-- x86_64
        |-- files
        |-- img
        |   |-- EFI
        |   |-- images
        |   |-- isolinux
        |   |-- Packages
        |   `-- repodata
        `-- ks

Mount the Fedora install DVD and copy everything over to the img directory for the correct release (f14, f15) and architecture (i386, X86_64). See my mini howto for that.

While that is copying over we can create the PXE server stuff in pxeboot. Create a subdirectory boot and then another subdirectory under that for the release of fedora, (f14, f15). Rather then copy the PXE boot files over again make a symbolic link back to the isolinux subdirectoy from the img directory you are copying from the DVD. In my case I use:

ln -s ../../../webroot/f14/x86_64/img/isolinux x84_64

Create another subdirectory under pxeboot this time called pxelinux.cfg. This will hold your Menu configuration files.

Now get a copy of pxelinux.0 this can be found in the syslinux RPM, install it and copy it over from /usr/share/syslinux/pxelinux.0
also copy over a copy of the file vesamenu.c32 you can also get this from the isolinux directory this is common over a number of fedora release.

So assuming you are working with Fedora 15, the current version, lets create a simple menu to boot up from.

Using PXElinux it will eventually load the pxelinux.0/default. A quick and dirty one option menu would be

pxeboot/pxelinux.cfg/default
UI vesamenu.c32
LABEL f15_desktop
        MENU LABEL ^1) Install Desktop
        KERNEL boot/f15/x86_64/vmlinuz
        APPEND initrd=boot/f15/x86_64/initrd.img ks=http://192.168.0.2/webroot/f15/x86_64/ks/generic_desktop.ks ksdevice=eth0

NOTE: The last line, APPEND, must be all on one line.

Useful links

  • Text files in /usr/share/doc/syslinux-<version>
  • Specifically:
    • pxelinux.txt
    • menu.txt
  • /thekelleys.org.uk/dnsmasq/doc.html">Home page for Dnsmasq
  • Dnsmasq Man page
  • PXE Linux home

No feedback yet

Here are a collection of Mini-HOWTOs some of which are too short even for that grand title. I keep them around as it is easier to remember where to look these up that to remember the content of the mini-HOWTO

Search

Contents

free blog tool