Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Pure Python2 PXE (DHCP/TFTP/HTTP) Server
branch: master


This repository contains code that provides a working PXE server (via HTTP, TFTP, DHCP, and/or iPXE) implemented purely in Python. Currently, only Python 2.6 and newer is supported. Please read for further explanation of the PyPXE project as well as recommended use. See the issues page for open issues, bugs, and enhancements/improvements.

DISCLAIMER: None of thes implemented services are fully compliant with any standards or specifications. However, the true specifications and standards were followed when building PyPXE and while they work for PXE any other uses are purely coincidental. Use at your own risk.


Using PyPXE as a Library

PyPXE implements the following services for the purpose of creating a Python-based PXE environment: TFTP, HTTP, and DHCP. Each PyPXE service must be imported individually. For example, to import the TFTP service simply use:

from pypxe import tftp

or, if you prefer, you can use:

import pypxe.tftp

For more information on how each service works and how to manipulate them, see

QuickStart uses all three services in combination with the option of enabling/disabling them individually while also setting some options. Edit the settings to your preferred settings or run with --help or -h to see what command line arguments you can pass. Treat the provided netboot directory as tftpboot that you would typically see on a TFTP server, put all of your network-bootable files in there and setup your menu(s) in netboot/pxelinux.cfg/default.

Note: Python 2.6 does not include the argparse module, it is included in the standard library as of 2.7 and newer. The argparse module is required to take in command line arguments and will not run without it.

Simply run the following command and you will have an out-of-the-box PXE-bootable server that runs TFTP and serves files out of the netboot directory!

$ sudo python

If you require the ability to handle DHCP PXE requests then you can either enable the built-in DHCP server (after configuring, of course)...

$ sudo python --dhcp

...or start in ProxyDHCP mode rather than a full DHCP server to prevent DHCP conflicts on your network...

$ sudo python --dhcp-proxy

PyPXE Server Arguments

The following are arguments that can be passed to when running from the command line

  • Main Arguments
    • --ipxe
      • Description: Enable iPXE ROM
      • Default: False
    • --http
      • Description: Enable built-in HTTP server
      • Default: False
    • --dhcp
      • Description: Enable built-in DHCP server
      • Default: False
    • --dhcp-proxy
      • Description: Enable built-in DHCP server in proxy mode (implies --dhcp)
      • Default: False
    • --no-tftp
      • Description: Disable built-in TFTP server which is enabled by default
      • Default: False
    • --debug
      • Description: Enable selected services in DEBUG mode
        • This adds a level of verbosity so that you can see what's happening in the background. Debug statements are prefixed with [DEBUG] and indented to distinguish between normal output that the services give.
      • Default: False
  • DHCP Service Arguments each of the following can be set one of two ways, you can use either/or
    • -s DHCP_SERVER_IP or --dhcp-server-ip DHCP_SERVER_IP
      • Description: Specify DHCP server IP address
      • Default:
    • -p DHCP_SERVER_PORT or --dhcp-server-port DHCP_SERVER_PORT
      • Description: Specify DHCP server port
      • Default: 67
    • -b DHCP_OFFER_BEGIN or --dhcp-begin DHCP_OFFER_BEGIN
      • Description: Specify DHCP lease range start
      • Default:
    • -e DHCP_OFFER_END or --dhcp-end DHCP_OFFER_END
      • Description: Specify DHCP lease range end
      • Default:
    • -n DHCP_SUBNET or --dhcp-subnet DHCP_SUBNET
      • Description: Specify DHCP subnet
      • Default:
    • -r DHCP_ROUTER or --dhcp-router DHCP_ROUTER
      • Description: Specify DHCP lease router
      • Default:
    • -d DHCP_DNS or --dhcp-dns DHCP_DNS
      • Description: Specify DHCP lease DNS server
      • Default:
    • -c DHCP_BROADCAST or --dhcp-broadcast DHCP_BROADCAST
      • Description: Specify DHCP broadcast address
      • Default: '<broadcast>'
    • -f DHCP_FILESERVER_IP or --dhcp-fileserver-ip DHCP_FILESERVER_IP
      • Description: Specify DHCP file server IP address
      • Default:
  • File Name/Directory Arguments
    • -a NETBOOT_DIR or --netboot-dir NETBOOT_DIR
      • Description: Specify the local directory where network boot files will be served
      • Default: 'netboot'
    • -i NETBOOT_FILE or --netboot-file NETBOOT_FILE
      • Description: Specify the PXE boot file name
      • Default: automatically set based on what services are enabled or disabled, see for further explanation


  • Core.iso located in netboot is from the TinyCore Project and is provided as an example to network boot from using PyPXE
  • chainload.kpxe located in netboot is the undionly.kpxe from the iPXE Project
  • ldlinux.c32, libutil.c32, pxelinux.0, menu.c32, and memdisk located in netboot are from the SYSLINUX Project version 6.02
Something went wrong with that request. Please try again.