CentOS 7 64-bit installation and configuration of PXE Server

Source: Internet
Author: User
Tags file transfer protocol ftp protocol

CentOS 7 64-bit installation and configuration of PXE Server

This article describes how to install and configure a PXE Server on the RHEL/CentOS 764-bit with a local image installed repository. The repository source is provided by the ISO image of CentOS 7 DVD, DNS is provided by the DNSMASQ server.

This machine provides DNS and DHCP services for the Syslinux package for network boot and guidance, TFTP-Server-provides a boot image that can be downloaded using the small File Transfer Protocol over the network, and the VSFTPD server that provides locally Mounted DVD images-it will assume the role of the Official RHEL/CentOS 7 image installation repository, where the installer will extract the required package.

Step 1: install and configure the DNSMASQ Server

1. you do not need to be reminded to determine your network interface card. Unless your server has multiple network interface cards, the NIC must have a static IP address, the IP address must be in the network segment where you want to provide the PXE service.

Then, after you have configured the static IP address, update your system and perform other initial settings. Run the following command to install the DNSMASQ process.

  1. # Yum install dnsmasq

Install the dnsmasq package

2. The default main configuration file of DNSMASQ is located in the/etc directory. Although it can be understood without any instructions, it is indeed quite difficult to edit, even if there are detailed descriptive annotations.

First, make sure that you have backed up the file so that you can recover it later. Then, use your favorite text editor to create a new empty configuration file. The command is as follows.

  1. # Mv/etc/dnsmasq. conf/etc/dnsmasq. conf. backup
  2. # Nano/etc/dnsmasq. conf

3. copy and paste the following configuration to the dnsmasq. conf file, and make sure to modify the configuration according to the following instructions to adapt to your network settings.

  1. Interface = eno16777736, lo
  2. # Bind-interfaces
  3. Domain = centos7.lan
  4. # DHCP range-leases
  5. Dhcp-range = eno16777736, 192.168.1.3, 192.168.1.253, 255.255.255.0, 1 h
  6. # PXE
  7. Dhcp-boot = pxelinux.0, pxeserver, 192.168.1.20
  8. # Gateway
  9. Dhcp-option = 3, 192.168.1.1
  10. # DNS
  11. Dhcp-option = 6, 92.161.1, 8.8.8.8
  12. Server = 8.8.4.4
  13. # Broadcast Address
  14. Dhcp-option = 28, 10.0.0.255
  15. # NTP Server
  16. Dhcp-option = 42, 0.0.0.0
  17. Pxe-prompt = "Press F8 for menu.", 60
  18. Pxe-service = x86PC, "Install CentOS 7 from network server 192.168.1.20", pxelinux
  19. Enable-tftp
  20. Tftp-root =/var/lib/tftpboot

Dnsmasq Configuration

The statements you need to modify include the following:

  • Interface-the network interface that the server needs to listen to and provide services.
  • Bind-interfaces-uncomment to bind to this network interface
  • Domain-Replace with your domain name.
  • Dhcp-range-replace the network segment defined for your network mask.
  • Dhcp-boot-replace this IP address with your network interface IP address.
  • Dhcp-option = 3, 192.168.1.1-replace this IP address with the gateway of your network segment.
  • Dhcp-option = 6, 92.161.1-replace this IP address with your DNS server IP-you can define multiple IP addresses.
  • Server = 8.8.4.4-the IP address of the DNS forwarding server is placed here.
  • Dhcp-option = 28, 10.0.0.255-replace the IP address with the network broadcast address-optional.
  • Dhcp-option = 42, 0.0.0.0-put the network clock server here -- Optional (0.0.0.0 Address indicates refer to itself ).
  • Pxe-prompt-keep default -- press F8 to enter the menu and wait for 60 seconds.
  • Pxe = service-use x86PC as the 32/64-bit architecture, and enter the menu description prompt in the string quote. Other types of values can be: PC98, IAEFI, Alpha, ArcX86, IntelLeanClient, IA32EFI, BCEFI, XscaleEFI and X86-64EFI.
  • Enable-tftp-enable the built-in TFTP server.
  • Tftp-root-use/var/lib/tftpboot-location of all network startup files.

For other advanced options related to the configuration file, see the dnsmasq manual.

Step 2: Install SYSLINUX Boot Loader

4. After editing and saving the main configuration file of DNSMASQ, we will continue to install SyslinuxPXE to start the loader. The command is as follows.

  1. # Yum install syslinux

Install Syslinux Boot Loader

5. the PXE Boot Loader file is located in the absolute path of the/usr/share/syslinux system. You can view it by listing the content in this path. This step is not required, but you may need to know the path, because in the next step, we will copy all the content under this path to the TFTP server path.

  1. # Ls/usr/share/syslinux

Syslinux File

Step 3: Install TFTP-Server and add SYSLINUX to load the starter

6. Now, let's go to the next step and install TFTP-Server. Then, copy the Syslinux package in the above location to provide all the boot loader files to the/var/lib/tftpboot path. The command is as follows.

  1. # Yum install tftp-server
  2. # Cp-r/usr/share/syslinux/*/var/lib/tftpboot

Install the TFTP Server

Step 4: Set the PXE Server Configuration File

7. generally, the PXE Server is located in pxelinux. read the configuration from a group of specified files in the cfg folder (first the GUID file, then the MAC file, and finally the Default file ), this folder must be located in the directory specified by the tftp-root statement in the DNSMASQ main configuration file.

Create the required directory pxelinux. cfg and add the default file to the directory. The command is as follows.

  1. # Mkdir/var/lib/tftpboot/pxelinux. cfg
  2. # Touch/var/lib/tftpboot/pxelinux. cfg/default

8. Now, you should edit the PXE Server configuration file and add appropriate installation options for the Linux release. Note that all paths used in this file must be relative to the/var/lib/tftpboot directory.

Below, you can see the sample configuration file, you can use this template, but please modify the installation image (kernel and initrd file), Protocol (FTP, HTTP, HTTPS, NFS) and maps the IP addresses of the source repository and path installed on your network.

  1. # Nano/var/lib/tftpboot/pxelinux. cfg/default

Add the following section to the file.

  1. Defaultmenu. c32
  2. Prompt0
  3. Timeout300
  4. ONTIMEOUTlocal
  5. Menu title ########## PXE Boot Menu ##########
  6. Label1
  7. Menu label ^ 1) InstallCentOS7x64withLocalRepo
  8. Kernel centos7/vmlinuz
  9. Append initrd = centos7/initrd. img method = ftp: // 192.168.1.20/pub devfs = nomount
  10. Label2
  11. Menu label ^ 2) InstallCentOS7x64withhttp: // developer.centos.org Repo
  12. Kernel centos7/vmlinuz
  13. Append initrd = centos7/initrd. img method = http://mirror.centos.org/centos/7/ OS /x86_64/ devfs = nomount ip = dhcp
  14. Label3
  15. Menu label ^ 3) InstallCentOS7x64withLocalRepousingVNC
  16. Kernel centos7/vmlinuz
  17. Append initrd = centos7/initrd. img method = ftp: // 192.168.1.20/pub devfs = nomount inst. vnc inst. vncpassword = password
  18. Label4
  19. Menu label ^ 4) Bootfromlocaldrive

Configure the PXE Server

As you can see, CentOS 7 boot image (kernel and initrd) is located in the directory named centos7, this directory is the relative path of the/var/lib/tftpboot directory (the absolute path of the system is/var/lib/tftpboot/centos7 ), the installer repository is located in the 192.168.1.20/pub network location that can be accessed through the FTP protocol-in this example, these repositories are located locally because the IP address is the same as the PXE Server address.

At the same time, menu label 3 specifies that the client installation should be implemented from a remote location through VNC (replace the VNC password with a robust password here). If you install it on a client without input or output, menu label 2 specifies an official CentOS 7 Internet image as the installation source (in this case, the client is required to connect to the Internet through DHCP and NAT ).

Important: As you can see in the above configuration, we use CentOS 7 for demonstration, but you can also define a RHEL 7 image. The entire description and configuration below are only based on CentOS 7, so pay attention to it when selecting the release version.

Step 5: Add CentOS 7 boot image to PXE Server

9. For this step, the CentOS kernel and initrd files are required. To obtain these files, you need a CentOS 7 dvd iso image. Therefore, download the CentOS DVD image and then burn it (to a CD) to your DVD drive and mount the image to the/mnt path. For the command, see the following.

The reason for using a DVD instead of minimizing the CD image is that we will later use the content of this DVD to create a local installer repository for the FTP source.

  1. # Mount-o loop/dev/cdrom/mnt
  2. # Ls/mnt

Mount CentOS DVD

If your machine does not have a DVD drive, you can also use the wget or curl tool to download and mount the CentOS 7 dvd iso from the CentOS image site.

  1. # Wget http://mirrors.xservers.ro/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso
  2. # Mount-o loop/path/to/centos-dvd.iso/mnt

10. After the content of the DVD is available, create the centos7 directory and copy the startup kernel and initrd image files of CentOS 7 from the Mount location of the DVD to the centos7 folder.

  1. # Mkdir/var/lib/tftpboot/centos7
  2. # Cp/mnt/images/pxeboot/vmlinuz/var/lib/tftpboot/centos7
  3. # Cp/mnt/images/pxeboot/initrd. img/var/lib/tftpboot/centos7

Copy CentOS boot files

In the future, you may create an independent directory in the/var/lib/tftpboot path and add other Linux distributions to the PXE menu, you won't mess up the entire directory structure.

Step 6: Create a CentOS 7 Local Image installation Source

11. Although you can install the source image through multiple protocols, such as HTTP, HTTPS, or NFS, I chose to use the FTP protocol for this guide. With vsftpd, you can easily configure it and it is stable.

Next, install the vsftpd process and copy the content in all the DVD Mount directories to the default vsftpd server path (/var/ftp/pub). This takes some time, it depends on your system resources. Set the read permission for the path. The command is as follows.

  1. # Yum install vsftpd
  2. # Cp-r/mnt/*/var/ftp/pub/
  3. # Chmod-R 755/var/ftp/pub

Install the Vsftpd Server

Copy Files to the FTP path

Set FTP path Permissions

Step 7: START and enable processes within the system

12. Since the PXE Server configuration has been completed, start the DNSMASQ and VSFTPD servers. Verify their status and enable them on the system so that these services can be started with the system after each system restart. The command is as follows.

# systemctl start dnsmasq# systemctl status dnsmasq# systemctl start vsftpd# systemctl status vsftpd# systemctl enable dnsmasq# systemctl enable vsftpd

Start the Dnsmasq Service

Start Vsftpd

Step 8: Open the firewall and test the FTP installation Source

13. To obtain the list of ports to be opened in the firewall so that the client can access and start from the PXE Server, run the netstat command and add CentOS 7 firewall rules according to the dnsmasq and vsftpd listener lists.

  1. # Netstat-tulpn
  2. # Firewall-cmd -- add-service = ftp -- permanent # Port 21
  3. # Firewall-cmd -- add-service = dns -- permanent # Port 53
  4. # Firewall-cmd -- add-service = dhcp -- permanent # Port 67
  5. # Firewall-cmd -- add-port = 69/udp -- permanent # Port for TFTP
  6. # Firewall-cmd -- add-port = 4011/udp -- permanent # Port for ProxyDHCP
  7. # Firewall-cmd -- reload # Apply rules

Check listening port

Enable the port on the firewall

14. to test the FTP installation source network path, open a browser (lynx can do this) on your local computer or another computer, and enter the IP address of the PXE Server where you set up the FTP service, add the/pub network location after the entered URL, and the result should be the same as that seen in.

  1. Ftp: // 192.168.1.20/pub

Access FTP files through a browser

15. To solve the problem caused by the final configuration or other information of the PXE Server, diagnose the problem in live mode and run the following command:

  1. # Tailf/var/log/messages

Check PXE log errors

16. The final step is to uninstall the CentOS 7 DVD and remove the physical media.

  1. # Umount/mnt Step 9: configure the client to start from the network

    17. Now, your client can use their system BIOS or press the specified key during BIOS boot self-check to configure network boot as the preferred boot device. For details, see the motherboard instruction manual.

    To select Network startup, press F8 to enter the PXE installation interface when the first PXE prompt appears, and then press enter to continue to enter the PXE menu.

    PXE network startup

    PXE network OS startup

    18. Once you enter the PXE menu, select your CentOS 7 installation type and press enter to continue the installation process, just as if you were using the local boot media for installation.

    Remember this. Use variant 2 in the menu to activate the Internet connection on the target client. On the screen below, you can view the remotely installed instance through VNC.

    PXE menu

    Remote Installation of Linux Through VNC

    Remote Installation of CentOS

    The above is all the content configured to minimize the PXE Server on CentOS 7. In my next article in this series, I will discuss other issues related to PXE Server Configuration, such as how to use the Kickstart file to configure automatic installation of CentOS 7, and add other Linux distributions to the PXE menu-Ubuntu Server and Debian 7.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.