Skip to content

Instantly share code, notes, and snippets.

@gdamjan
Created October 10, 2011 22:20
Show Gist options
  • Save gdamjan/1276752 to your computer and use it in GitHub Desktop.
Save gdamjan/1276752 to your computer and use it in GitHub Desktop.
Make and start a PXE server
#!/bin/sh
mkdir /home/tftproot
# install syslinux from package and symlink it or just download and extract it
ln -s /usr/lib/syslinux /home/tftproot/syslinux
mkdir /home/tftproot/pxelinux.cfg/
cat > /home/tftproot/pxelinux.cfg/default <<EOF
# file names relative to /home/tftproot
UI /syslinux/menu.c32
TIMEOUT 600
TOTALTIMEOUT 9000
ONTIMEOUT localboot 0
PROMPT 0
MENU TITLE PXE netboot server
LABEL memtest
MENU LABEL Boot Memtest86+ V4.20
KERNEL /misc/memtest86
APPEND -
# get the official Arch ISO file. Mount it in /mnt/arch then make a symlink
# /mnt/arch/arch/ <- /home/tftproot/arch/
LABEL arch
MENU LABEL Arch Linux i686
LINUX /arch/boot/i686/vmlinuz
INITRD /arch/boot/i686/archiso.img
APPEND ip=dhcp checksum=y archiso_http_srv=http://192.168.234.1/ archisobasedir=pxe/arch/
# get files from http://mirror.centos.plus.hr/centos/6.3/os/i386/images/pxeboot/
LABEL centos6.3
MENU LABEL Centos 6.3 (32-bit)
kernel centos/6.3/i386/vmlinuz
initrd centos/6.3/i386/initrd.im
EOF
#!/bin/sh
WAN=wlan0
LAN=eth0
NET=192.168.234
# setup LAN network
ip addr add ${NET}.1/24 dev $LAN
ip link set up dev $LAN
# start dns, dhcp, tftp, pxe server
dnsmasq --dhcp-range=${NET}.100,${NET}.200,2h -i $LAN -z -d \
--enable-tftp --tftp-root=/home/tftproot/ --dhcp-boot=/syslinux/gpxelinux.0
# setup NAT and enable routing
iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
sysctl -w net.ipv4.ip_forward=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment