Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed deployment process of PXE server under Linux system

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the detailed deployment process of the PXE server under the Linux system". In the daily operation, I believe that many people have doubts about the detailed deployment process of the PXE server under the Linux system. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "the detailed deployment process of the PXE server under the Linux system". Next, please follow the editor to study!

When installing servers on a large scale, batch automation is needed to install servers to reduce daily workload.

But the foundation of the batch automatic installation server is the network boot server (bootserver).

Next, we will introduce the installation and configuration of the network startup server for everyone to practice!

1. Interpretation of terms used in this article

PXE

PXE (Pre-boot Execution Environment) is a protocol designed by Intel that enables computers to boot over the network rather than from local hard drives, optical drives, and other devices. Modern network cards are generally embedded with ROM chips that support PXE. When the computer is booted, BIOS calls the PXE client into memory to execute and displays the command menu. After being selected by the user, PXE client will download the remote operating system to run locally through the network.

DHCP

DHCP (Dynamic Host Control Protocol) dynamic host control protocol. Used to centrally and dynamically assign IP addresses to clients.

TFTP

TFTP (trivial file transfer protocol), a low-overhead file transfer protocol, has a syntax similar to ftp. Because of its simplicity and efficiency, it is often used for OS and configuration updates of network devices.

2. PXE principle

2.1. PXE Client Api (Architecture)

Figure PXE API architecture diagram. (photo source: PXE Specification Version 2.1)

The image above shows that when BIOS loads PXE Client into memory, it has the ability of DHCP Client and TFTP Client.

PXE Client has DHCP Client capability and can obtain IP address through DHCP Server.

PXE Client has the ability to TFTP Client, and files such as kernel image can be downloaded through TFTP.

2.2. PXE Startup flowchart (pxe boot)

The startup process shown in the figure above is as follows:

PXE Client broadcasts DHCPDDISCOVER messages to UDP port 67.

After receiving the broadcast message, DHCP SERVER or DHCP Proxy sends a DHCPOFFER (including ip address) message to port 68 of PXE Client.

PXE Client sends a DHCPREQUEST message to DHCP SERVER to get the startup file (boot file name).

DHCP SERVER sends a DHCPACK (including Network Bootstrap Program file name) message to PXE Client.

PXE Client gets the NBP (Network Bootstrap Program) file from Boot Server.

PXE Client downloads NBP from TFTP SERVER, and then executes the NBP file on the client

Note: after NBP initializes, NBP downloads other required configuration files from TFTP SERVER by default.

At this time, the PXE startup process has been completed, and the rest of the work is performed by NBP.

For example: pxelinux.0 (NBP) he will download the default configuration file to display the menu and start different kernel image.

If it is the NBP of RIS (window installation), Windows boot loader will be launched to perform the task of installing and deploying widows.

3. PXE BOOT Server configuration process

The following configuration and testing are completed on Centos5, other systems please refer to as appropriate!

3.1. Installation and configuration of DHCP

During the PXE boot process, PXE Client gets the ip address and the name of the NBP file through DHCP Server, then downloads the NBP file from TFTP SERVER and executes it on the client, thus starting the computer.

Please confirm that the dhcp package is installed in the system

Edit the / etc/dhcpd.conf configuration file, which contains the following

The code is as follows:

[root@linux] # cat / etc/dhcpd.conf

Ddns-update-style interim

Allow booting; # definition can be started by PXE

Allow bootp; # definition supports bootp

IP address of next-server 192.168.0.1; # TFTP Server

Filename "pxelinux.0"; # bootstrap file (NBP)

Default-lease-time 1800

Max-lease-time 7200

Ping-check true

Option domain-name-servers 192.168.0.1

Subnet 192.168.0.0 netmask 255.255.255.0

{

Range 192.168.0.128 192.168.0.220

Option routers 192.168.0.1

Option broadcast-address 192.168.0.255

}

Note: filename "pxelinux.0" in the / etc/dhcpd.conf configuration file; the file directory is relative to the root directory of tftp (default is / tftpboot)

So the absolute path to the file is: / tftpboot/pxelinux.0 "; of course, it can also be specified as another path.

After the configuration is complete, restart the DHCP service and set it to boot automatically

The code is as follows:

[root@linux] # / etc/init.d/dhcpd start

Start dhcpd: [OK]

[root@linux] # chkconfig-- level 35 dhcpd on

3.2. Install and configure TFTP server

During the PXE boot process, PXE Client uses the TFTP protocol to download the bootstrap file from the TFTP server and execute it.

Please confirm that the tftp-server package is installed in the system

Configure the tftp service, which is managed by the xinetd service

Edit the / etc/xinetd.d/tftp file and change disable = yes to: disable = no. The configuration file is as follows:

The code is as follows:

[root@linux] # cat / etc/xinetd.d/tftp

# default: off

# description: The tftp server serves files using the trivial file transfer\

# protocol. The tftp protocol is often used to boot diskless\

# workstations, download configuration files to network-aware printers,\

# and to start the installation process for some operating systems.

# default: off

# description: The tftp server serves files using the trivial file transfer\

# protocol. The tftp protocol is often used to boot diskless\

# workstations, download configuration files to network-aware printers,\

# and to start the installation process for some operating systems.

Service tftp

{

Socket_type = dgram

Protocol = udp

Wait = yes

User = root

Server = / usr/sbin/in.tftpd

Server_args =-s / tftpboot

Disable = no

Per_source = 11

Cps = 100 2

Flags = IPv4

}

Note: the root directory of the TFTP server is / tftpboot. Restart the xinetd service after configuration to make the TFTP server effective.

The code is as follows:

[root@linux] # / etc/init.d/xinetd restart

Bootstrap file configuration (NBP), where pxelinux.0 is used

The bootstrap file is provided by the syslinux package. We just need to install syslinux and copy the pxelinux.0 file to the / tftpboot directory:

The code is as follows:

[root@linux] # rpm-ql syslinux | grep "pxelinux.0"

/ usr/lib/syslinux/pxelinux.0

[root@linux] # cp / usr/lib/syslinux/pxelinux.0 / tftpboot/

Configure the profile used by pxelinux.0 (NBP)

Next, create the / tftpboot/pxelinux.cfg/ directory, which is used to store the client's configuration files

The code is as follows:

[root@linux] # mkdir / tftpboot/pxelinux.cfg

The default configuration file, default, contains the following,

The code is as follows:

[root@linux] # cat / tftpboot/pxelinux.cfg/default

Default linux # starts the boot kernel marked in 'label linux' by default

Prompt 1 # displays the prompt 'boot:'

Timeout 60 # wait for the timeout period (in 10 seconds). After the timeout, the default label is started automatically.

Display boot.msg # displays the contents of boot.msg, and the file path is relative to the root directory of tftp server (default / tftpboot), so the absolute path of boot.msg file is / tftpboot/boot.msg.

F1 boot.msg # Files displayed after pressing the 'F1' key

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

Label 1 # 'label' specifies the keywords you enter at the' boot:' prompt.

Kernel linux/rh54-x86-32/vmlinuz

Append initrd=linux/rh54-x86-32/initrd.img ramdisk_size=8192 ks= http://install.test.com/conf/ks_module.cfg ksdevice=link

Label 2

Kernel linux/rh54-x86-64/vmlinuz

Append initrd=linux/rh54-x86-64/initrd.img ramdisk_size=8192 ks= http://install.test.com/conf/ks_module.cfg ksdevice=link

Label 3

Kernel linux/rh56-x86-64/vmlinuz

Append initrd=linux/rh56-x86-64/initrd.img ramdisk_size=8192 ks= http://install.test.com/conf/ks_module.cfg ksdevice=link

Label 4

Kernel linux/rh56-x86-32/vmlinuz

Append initrd=linux/rh56-x86-32/initrd.img ramdisk_size=8192 ks= http://install.test.com/conf/ks_module.cfg ksdevice=link

Label 5

Kernel image/linux/rh48-x86-32/vmlinuz

Append initrd=image/linux/rh48-x86-32/initrd.img ramdisk_size=8192 ks= http://install.test.com/conf/ks_module.cfg ksdevice=link

Label 6

Kernel linux/rh48-x86-64/vmlinuz

Append initrd=linux/rh48-x86-64/initrd.img ramdisk_size=8192 ks= http://install.test.com/conf/ks_module.cfg ksdevice=link

Note: the default pxelinux.0 and pxelinux.cfg must be in the same directory

3.3. Pxelinx.0 (NBP) program configuration file search order

Because multiple clients can boot from a PXE server, the PXE boot image uses a complex configuration file search method to find the configuration file for the client.

Assuming that the MAC address of the Nic of the client server is 88:99:AA:BB:CC:DD and the corresponding IP address is 192.168.1.195, the search order of the client pxelinux.0 program is as follows:

First, use the MAC address as the file name to match the configuration file, if it does not exist, continue to search.

Secondly, the IP address is used to find it. According to the IP address hexadecimal named configuration file lookup, from small to large (subnet mask from small to large), if it does not exist, continue to search.

Finally try the default file

Overall, the order in which pxelinux.0 searches for files is (results can be obtained through tcpdum):

The code is as follows:

/ tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd

/ tftpboot/pxelinux.cfg/C0A801C3

/ tftpboot/pxelinux.cfg/C0A801C

/ tftpboot/pxelinux.cfg/C0A801

/ tftpboot/pxelinux.cfg/C0A80

/ tftpboot/pxelinux.cfg/C0A8

/ tftpboot/pxelinux.cfg/C0A

/ tftpboot/pxelinux.cfg/C0

/ tftpboot/pxelinux.cfg/C

/ tftpboot/pxelinux.cfg/default

At this point, the study on "the detailed deployment process of the PXE server under the Linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report