How to Setup PXE Server

Published on January 2017 | Categories: Documents | Downloads: 40 | Comments: 0 | Views: 274
of 11
Download PDF   Embed   Report

Comments

Content

Howto setup PXE server
This is HOWTO for installing PXE (Preboot eXecution Environment) server on Centos 6.2 server. This HOWTO is writen by: Daniel Milas ([email protected]) and it is free to: use, share, modify, burn and every thing you can imagine. :-) Please don't send me e-mail's because i'm linux begginer. Internet reasoures that helped me are: http://www.smtps.net/pxe-kickstart.html http://www.server-world.info/en/note?os=CentOS_6&p=pxe&f=3 http://www.server-world.info/en/note?os=CentOS_6&p=pxe&f=2 http://secnut.blogspot.com/2010/04/pxe-kickstart-automating-centosredhat.html http://secnut.blogspot.com/2010/04/pxe-kickstart-automating-centosredhat.html http://secnut.blogspot.com/2010/04/building-kickstart-install-server.html http://wiki.centos.org/HowTos/PXE/Rescue_PXE http://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-netboot-pxe-config.html http://ckozler.net/?p=292 BIG THANKS TO ALL!!! You can find Centos 6.2 install (ISO) files on: http://www.centos.org/ This PXE server is used to install this operating system on PXE clients: - Centos 6.2 Desktop This PXE server is also used to run Clonezilla Live on PXE clients: - Clonezilla Live You can find Clonezilla Live on: http://clonezilla.org/ If you need more than this two operating system to be installed, you can do it also, just follow procedure and change names, add things and so. This procedure is written by absolute LINUX begginer. !!!! There is no WARNITY what so ever !!!! !!!! You using this on your own risk !!!! Just to remind YOU that this procedure when selected Centos 6.2 installation !!!!!ERASE ALL DATA ON CLINET!!!!! If You need tho change this, look at ks.cfg (kickstart config) file and change this option. For security reasons DO NOT put this system in production environment. Security aspect of this system is not taken (YUST MAKE PXE TO WORK). So let's begin!

Part: 1 Install Centos 6.2 on one PC with 1Gb RAM and 80Gb HDD. PC need LAN card. Some starting points are: PXE server operation system: Centos 6.2 (desktop install) IP Address: 192.168.1.15/24; Gateway: 192.168.1.1 (ADSL Router) DNS Server: 192.168.1.15 (ADSL Router) NO OTHER DHCP on network; Network install for Centos 6.2 distro Network install for Clonezilla Live distro Part: 2 I USE gedit COMMAND TO EDIT FILES (not using vi editor because don't know how to use it) First setup Centos 6.2 on one machine with at least 1Gb of RAM and 80Gb HDD, and disable firewall, log in as root. ---------------------------------------------------------------------------------### Install THIS Services first they are needed for this to work ### sudo yum install update sudo yum install httpd sudo yum install samba sudo yum install dhcp sudo yum install xinetd sudo yum install syslinux sudo yum install tftp-server sudo yum install tftp sudo yum install vsftpd sudo yum install system-config-kickstart ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### Set services allways ON, so when PXE Server is restarted it is ON ### ### DHCP chkconfig dhcpd on ### FTP chkconfig vsftpd on ### HTTPD chkconfig httpd on ### TFTP chkconfig xinetd on ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### BEFORE MAKE ANY CHANGES TO CONFIG FILES - !!! MAKE BACKUP !!! ### ### This commands are used to make copy of config files ### ### dhcpd.conf - DHCPD - DHCP Server config file ### cp /etc/dhcp/dhcpd.conf /home/dhcpd.conf.bak ### httpd.conf - HTTPD - HTTP Server config file ### cp /etc/httpd/conf/httpd.conf /home/httpd.conf.bak ### tftp - TFTP -TFTP server config file ### cp /etc/xinetd.d/tftp /home/tftp.bak

### vsftpd.conf - VSFTPD - FTP server config file ### cp /etc/vsftpd/vsftpd.conf /home/vsftpd.conf.bak ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### This commands are for starting selected services ### ### Please see note for some of services, because ### they need to be configured before starting. ### Start DHCP service !!!! BEFORE STARTING SERVICE MAKE CONFIGURATION !!!! ### Start DHCP service SEE ### DHCPD CONFIG LINE ### /etc/rc.d/init.d/dhcpd start ### Start FTP service !!!! BEFORE STARING SERVICE MAKE CONFIGURATION !!!! ### Start FTP service SEE ### VSFTPD CONFIG LINE ### /etc/rc.d/init.d/vsftpd start ### Start HTTPD service !!!! BEFORE STARTING SERVICE MAKE CONFIGURATION !!!! ### Start HTTPD service SEE ### HTTPD CONFIG LINE ### /etc/rc.d/init.d/httpd start ### Before start TFTP service !!!! YOU NEED TO EDIT CONFIG FILE FIRST !!!! gedit /etc/xinetd.d/tftp #line 14: change FROM yes > no disable = no ### Start TFTP Service !!! WHEN FINISHED EDITING CONFIG FILE START SERVICE !!!! /etc/rc.d/init.d/xinetd start ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### When finished with configuration restart all needed services ### ### Restart DHCP Service /etc/rc.d/init.d/dhcpd restart ### Restart FTP Service /etc/rc.d/init.d/vsftpd restart ### Restart HTTP service /etc/rc.d/init.d/httpd restart ### Restart TFTP Service /etc/rc.d/init.d/xinetd restart ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### DHCPD CONFIG FILE EDIT COMMAND ### gedit /etc/dhcp/dhcpd.conf #### DHCPD CONFIG LINE - BEGIN #### # Defaul file location # /etc/dhcp/dhcpd.conf # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # see 'man 5 dhcpd.conf' # ddns-update-style interim; ignore client-updates; authoritative; allow booting; allow bootp;

allow unknown-clients; subnet 192.168.1.0 netmask 255.255.255.0 { # default gateway option routers 192.168.1.1; option subnet-mask 255.255.255.0; option domain-name "mynetwork.local"; option domain-name-servers 192.168.1.1; option broadcast-address 192.168.1.255; # EST Time Zone option time-offset -18000; # Client IP range range dynamic-bootp 192.168.1.100 192.168.1.199; default-lease-time 21600; max-lease-time 43200; # PXE Server IP next-server 192.168.1.15; filename "pxelinux.0"; } #### DHCPD CONFIG LINE - END #### ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### VSFTPD CONFIG FILE EDIT COMMAND ### gedit /etc/vsftpd/vsftpd.conf #### VSFTPD CONFIG LINE - BEGIN #### listen=YES anonymous_enable=NO local_enable=YES userlist_deny=NO userlist_enable=YES write_enable=YES connect_from_port_20=NO #port_enable=YES local_root=/var/ftp pam_service_name=vsftpd tcp_wrappers=YES #### VSFTPD CONFIG LINE - END #### ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### Before making any configuration to httpd file run this commands to ensure ### removing all files that is not needed ### REMOVE welcome page rm -f /etc/httpd/conf.d/welcome.conf ### REMOVE default error page rm -f /var/www/error/noindex.html ### CREATE a link for Perl ln -s /usr/bin/perl /usr/local/bin/perl ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### HTTPD CONFIG FILE EDIT COMMAND ### gedit /etc/httpd/conf/httpd.conf #### HTTPD CONFIG LINE - BEGIN #### ##Configure HTTPD Options # line 44: change

ServerTokens Prod # line 76: change to ON KeepAlive On # line 262: Admin's address ServerAdmin [email protected] # line 276: change to your server's name ServerName www.pxe.local:80 # line 331: change (enable CGI and disable Indexes) Options FollowSymLinks ExecCGI # line 338: change AllowOverride All # line 402: add file name that it can access only with directory's name DirectoryIndex index.html index.cgi index.php # line 536: change ServerSignature Off # line 759: make it comment #AddDefaultCharset UTF-8 # line 796: uncomment and add file-type that apache looks them CGI AddHandler cgi-script .cgi .pl #### HTTPD CONFIG LINE - END #### ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### HTTPD TEST - Create this files to test HTTPD Service #### ### Create a HTML test page and access to it with web browser. ### It's OK if following page is shown. -----------------------------------------------------------------------------------### Create and edit index.html ### and paste conntent in it gedit /var/www/html/index.html #### index.html - BEGIN #### <html> <body> <div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;"> PXE Local Test Page YEAAAAAA!!!! </div> </body> </html> #### index.html - END #### -----------------------------------------------------------------------------------### Create and edit index.cgi ### and paste conntent in it gedit /var/www/html/index.cgi #### index.cgi - BEGIN #### #!/usr/local/bin/perl print "Content-type: text/html\n\n"; print "<html>\n<body>\n"; print "<div style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\">\n"; print "CGI Test Page"; print "\n</div>\n"; print "</body>\n</html>\n"; #### index.cgi - END #### -----------------------------------------------------------------------------------### Permisions need to be changed to index.cgi file ### Change permission on this file chmod 705 /var/www/html/index.cgi ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### After MAKING this changes restart all services

### Restart Services ### ### Restart DHCP Service /etc/rc.d/init.d/dhcpd restart ### Restart FTP Service /etc/rc.d/init.d/vsftpd restart ### Restart HTTPD service /etc/rc.d/init.d/httpd restart ### Restart TFTP Service /etc/rc.d/init.d/xinetd restart ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### This is end of system preparations ### ### This is only note ### Default TFTP DIR ### /var/lib/tftpboot/ ### Default FTP DIR ### /var/ftp/ ### Default HTTPD DIR ### /var/www/html/ ### Default SYSLINUX DIR ### /usr/share/syslinux/ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### Prepare install files ### ### Make DIR on FTP for install files for Centos 6.2 mkdir -p /var/ftp/install/centos62 ### Make MOUNT Point for ISO file: mkdir -p /mnt/iso/ ### Download Centos 6.2 DVD and rename is to "centos62.iso" ### Put that iso file in /home/ folder "/home/centos62.iso" ### Mount /home/centos62.iso to /mnt/iso/ mount -t iso9660 -o loop /home/centos62.iso /mnt/iso ### Copy all files from ISO (mounted) to FTP dir cp -avr /mnt/iso/* /var/ftp/install/centos62/ ### List FOLDER CONTENT with this command - i'm no linux expert ls -a /var/ftp/install/centos62/ ### If it is ok UNMOUNT ISO FILE WITH THIS COMMAND umount /mnt/iso/ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### Create folder for boot files on tftp mkdir -p /var/lib/tftpboot/images/centos62 ### Copy PXE BOOT Files from ftp folder to tftp folder ### This TWO files are needed for PXE boot "vmlinuz" and "initrd.img" cp /var/ftp/install/centos62/images/pxeboot/vmlinuz /var/lib/tftpboot/images/centos62/ cp /var/ftp/install/centos62/images/pxeboot/initrd.img /var/lib/tftpboot/images/centos62/ ### Copy this files to TFTPBOOT folder

### See also pxelinux documentation for this files ### If you want to put picture in menu specify this in pxelinux.cfg/default ### and upload splash.png image to TFTPBOOT ### FILE: menu.c32 -> enables basic menu style ### FILE: vesamenu.c32 -> enables advanced menu style ### FILE: pxelinux.0 -> instruct installer ??? cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/ cp /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot/ cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ ### copy image to tftpboot to have background ### Image location is /home/splash.png cp /home/splash.png /var/lib/tftpboot/ ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### Create pxelinux.cfg DIR on /var/lib/tftpboot/ mkdir -p /var/lib/tftpboot/pxelinux.cfg ### Create default config for PXE boot gedit /var/lib/tftpboot/pxelinux.cfg/default #### pxelinux.cfg/default - BEGIN #### default vesamenu.c32 timeout 300 menu width 78 menu margin 4 menu rows 13 menu background splash.png menu color border 0 #ffffffff #ee000000 std menu color title 0 #ffffffff #ee000000 std menu color sel 0 #ffffffff #85000000 std menu color unsel 0 #ffffffff #ee000000 std menu color hotkey 0 #ff00ff00 #ee000000 std menu color hotsel 0 #ffffffff #85000000 std MENU TITLE ###### PXE Server BI-Systems ###### LABEL 1 MENU LABEL ^1) Install Centos 6.2 full - AUTOMATIC KERNEL images/centos62/vmlinuz append vga=normal initrd=images/centos62/initrd.img ramdisk_size=32768 ks=http://192.168.1.15/ks/ks.cfg devfs=nomount LABEL 2 MENU LABEL ^2) Boot from local drive localboot #### pxelinux.cfg/default - END #### -----------------------------------------------------------------------------------### Play with this config file !THIS IS MINE! ### Put something like HACKER MENU or something else ### I know i did first time i have made it working :-)) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------### Kickstart file is unatended way to install system ### Make kickstart folder in /var/www/html/ ### name that folder ### It looks like /var/www/html/ks/ ### so it is avaiable to PXE mkdir -p /var/www/html/ks/ ### For making YOUR own ks.cfg file use this command system-config-kickstart ### Save it in /var/www/html/ks/ks.cfg ------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------### Don't forget to make FTP USER so it can access install files ### Put this user info in kickstart config file ### I have lost 1 days to find this option BIG THANKS TO INTERNET ### EDIT this file and put YOUR username for ftp access in this list gedit /etc/vsftpd/user_list ### My user is "ftpinstall" ### Make user on system with this command this is my user ### When you make user it is disabled by default ### This user need some password (i have lost my hair on this) useradd ftpinstall ### Set password for user "ftpinstall" passwd ftpinstall ### Password is: TEST1234ftp ### Now when you try to ftp to PXE you get error ### Run this command to see output getsebool -a | grep ftp #### getsebool -a | grep ftp - BEGIN - Output #### allow_ftpd_anon_write --> off allow_ftpd_full_access --> off allow_ftpd_use_cifs --> off allow_ftpd_use_nfs --> off ftp_home_dir --> off --> THIS IS WHAT WEE NEED TO CHANGE ftpd_connect_db --> off httpd_enable_ftp_server --> off tftp_anon_write --> off #### getsebool -a | grep ftp - END - Output #### ### Run this command to change this FTP option ### setsebool -P ftp_home_dir on #### getsebool -a | grep ftp - BEGIN - Output #### allow_ftpd_anon_write --> off allow_ftpd_full_access --> off allow_ftpd_use_cifs --> off allow_ftpd_use_nfs --> off ftp_home_dir --> on --> NOW WE SPEEKING ftpd_connect_db --> off httpd_enable_ftp_server --> off tftp_anon_write --> off #### getsebool -a | grep ftp - END - Output #### ### Try to ftp to this machine from other one ftp 192.168.1.15 U: ftpinstall P: TEST1234ftp OK OK OK OK OK OK ----------------------------------------------------------------------------------------------------------------------------------------------------------------------#### /var/www/html/ks/ks.cfg - BEGIN #### ############# MY kickstart config is ################ # WARNING WARNING WARNING WARNING WARNING WARNING WARNING #platform=x86, AMD64 ili Intel EM64T #version=DEVEL

# Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use network installation url --url="ftp://ftpinstall:[email protected]/install/centos62" # Root password rootpw --iscrypted $1$x4V/0Ka/$IlUJ/XYZnz0DkNGTNYmfO1 # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical firstboot --disable # System keyboard keyboard croat # System language lang hr_HR # SELinux configuration selinux --enforcing # Installation logging level logging --level=info # System timezone timezone --isUtc Europe/Sarajevo # Network information network --bootproto=dhcp --device=eth0 --onboot=on # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr yes # Partition clearing information clearpart --all yes # auto disk partition part /boot --size 128 --fstype=ext4 --asprimary part / --size 512 --fstype=ext4 --asprimary part swap --size 512 part /tmp --size 512 --fstype=ext4 part /var --size 512 --fstype=ext4 part /usr --size 4096 --fstype=ext4 part /home --size 2048 --fstype=ext4 #%packages --nobase #@core #%end %packages @base @client-mgmt-tools @core @croatian-support @debugging @basic-desktop @desktop-debugging @desktop-platform @directory-client @fonts @general-desktop @graphical-admin-tools @input-methods @internet-applications @internet-browser @java-platform @legacy-x @network-file-system-client @office-suite @print-client @remote-desktop-clients

@server-platform @server-policy @x11 mtools pax oddjob sgpio genisoimage wodim abrt-gui certmonger pam_krb5 krb5-workstation gnome-pilot libXmu %post yum -y update %end #### /var/www/html/ks/ks.cfg - END #### ----------------------------------------------------------------------------------------------------------------------------------------------------------------------Step: 3 Use Clonezilla live. This is how: Prepare a PXE server, see Step: 2 ### We assume the pxelinux config file is in: /var/lib/tftpboot/pxelinux.cfg/default ### Default location on tftp server /var/lib/tftpboot/pxelinux.cfg/default ### Image files are in: /var/lib/tftpboot/images/ /var/lib/tftpboot/images/ ### Download Clonezilla live zip file (!!! You have to use Clonezilla live 1.2.0-25 or later !!!) ### Put that file in /home/ dir ### Unzip the required files (vmlinuz, initrd.img, and filesystem.squashfs in dir live) /tftpboot/images/clonezilla/ ### First make /var/lib/tftpboot/images/clonezilla/ mkdir -p /var/lib/tftpboot/images/clonezilla/ ### Now extract files to: /var/lib/tftpboot/images/clonezilla/ ### Run something like this: unzip -j /home/clonezilla-live-*.zip live/vmlinuz live/initrd.img live/filesystem.squashfs -d /tftpboot/images/clonezilla ### Replace clonezilla-live-*.zip with the file name you just downloaded ### This is my path unzip -j /home/clonezilla-live-1.2.12-10-i486.zip live/vmlinuz live/initrd.img live/filesystem.squashfs -d /var/lib/tftpboot/images/clonezilla/ ### Now edit your PXElinux config file gedit /var/lib/tftpboot/pxelinux.cfg/default and append the following: ----------LABEL 2 MENU LABEL ^2) Clonezilla-live KERNEL images/clonezilla/vmlinuz append initrd=images/clonezilla/initrd.img boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_keymap="" ocs_live_batch="no" ocs_lang="" vga=788 nosplash noprompt fetch=tftp://192.168.1.15/images/clonezilla/filesystem.squashfs

LABEL 3 MENU LABEL ^3) Boot from local drive localboot ----------END. Now try client witx PXE boot option first. It took me 3 days to make it working from zero.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close