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

How to configure PXE server on Ubuntu system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article focuses on "how to configure a PXE server on a Ubuntu system". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to configure a PXE server on a Ubuntu system.

Overview of PXE

PXE (preboot execute environment, pre-boot execution environment) is the latest technology developed by Intel, which works in the network mode of Client/Server. It supports workstations to download images from remote servers through the network, and thus supports booting the operating system through the network. During the startup process, the terminal requires the server to assign an IP address. Then use TFTP (trivial file transfer protocol) or MTFTP (multicast trivial file transfer protocol) protocol to download a startup software package to the local memory for execution, by this startup software package to complete the terminal (customer? Basic software settings to boot the terminal operating system pre-installed in the server

To put it simply, a PXE server is a DHCP server + TFTP server. The network startup process is something like this (perhaps not rigorous): the client sends a broadcast packet with a dynamic IP address to the network, and after receiving the broadcast packet, the DHCP server sends a response packet to the client that assigns an IP address. After receiving the response packet, the client sets its own IP address, and then obtains the IP address of the startup server from the DHCP server (DHCP Server 066 option). This is the IP address of the TFTP server) and the startup file name (option DHCP server 067, where the startup file name is pxelinux.0 or grub4dos grldr that supports pxe, of course, it can also be startrom.n12 or pxe startup menu file created using 3com Image Edit, in short, it should be a fixed format executable file specified by the pxe startup specification) Then the client contacts the startup server (TFTP server) to get the startup file and execute it, which basically completes the pxe startup process.

Under Unix or Linux systems, DHCP servers and TFTP servers are generally set up separately, and the two servers can even be set up on two different machines. In fact, the settings under Windows are the same, but under Windows, we can do this by using HaneWin DHCP server software or TFTPD32 software (I personally recommend using HaneWin DHCP server software, but TFTPD32 is easier to set up, but it is somewhat inefficient) You only need to know that when setting up the PXE server, you should set up DHCP and TFTP servers, in which the DHCP server should set the startup server name (option 066) and the startup file name (option 067).

Configure the network

Before you start, you need to set up the PXE server to use static IP. To use static IP addresses on your system, you need to edit the "/ etc/network/interfaces" file.

Open the "/ etc/network/interfaces" file.

The code is as follows:

Sudo nano / etc/network/interfaces

Make the following modifications:

The code is as follows:

# Loopback network interface

Auto lo

Iface lo inet loopback

# Primary network interface

Auto eth0

Iface eth0 inet static

Address 192.168.1.20

Netmask 255.255.255.0

Gateway 192.168.1.1

Dns-nameservers 8.8.8.8

Save the file and exit. This will set its IP address to "192.168.1.20". Then restart the network service.

The code is as follows:

Sudo / etc/init.d/networking restart

Install DHCP, TFTP, and NFS:

DHCP,TFTP and NFS are important components of the PXE server. First, you need to update your system and install all the required software packages.

To do this, run the following command:

The code is as follows:

Sudo apt-get update

Sudo apt-get install isc-dhcp-Server inetutils-inetd tftpd-hpa syslinux nfs-kernel-Server

Configure the DHCP service:

DHCP stands for the dynamic host configuration protocol Dynamic Host Configuration Protocol, which is mainly used to dynamically assign network configuration parameters, such as IP addresses for interfaces and services. In a PXE environment, the DHCP server allows the client to request and automatically obtain an IP address to access the network.

1. Edit the "/ etc/default/dhcp3-server" file.

The code is as follows:

Sudo nano / etc/default/dhcp3-server

Make the following modifications:

The code is as follows:

INTERFACES= "eth0"

Save (Ctrl + o) and exit (Ctrl + x) file.

2. Edit the "/ etc/dhcp3/dhcpd.conf" file:

The code is as follows:

Sudo nano / etc/dhcp/dhcpd.conf

Make the following modifications:

The code is as follows:

Default-lease-time 600

Max-lease-time 7200

Subnet 192.168.1.0 netmask 255.255.255.0 {

Range 192.168.1.21 192.168.1.240

Option subnet-mask 255.255.255.0

Option routers 192.168.1.20

Option broadcast-address 192.168.1.255

Filename "pxelinux.0"

Next-Server 192.168.1.20

}

Save the file and exit.

3. Start DHCP service.

The code is as follows:

Sudo / etc/init.d/isc-dhcp-server start

Configure the TFTP server:

TFTP is a file transfer protocol similar to FTP, but it does not require user authentication and cannot list directories. The TFTP server always listens for requests from PXE clients on the network. When it detects that a PXE client requests a PXE service on the network, it provides a network packet containing the boot menu.

1. When configuring TFTP, you need to edit the "/ etc/inetd.conf" file.

The code is as follows:

Sudo nano / etc/inetd.conf

Make the following modifications:

The code is as follows:

Tftp dgram udp wait root / usr/sbin/in.tftpd / usr/sbin/in.tftpd-s / var/lib/tftpboot

Save the file and exit.

2. Edit "/ etc/default/tftpd-hpa" file.

The code is as follows:

Sudo nano / etc/default/tftpd-hpa

Make the following modifications:

The code is as follows:

TFTP_USERNAME= "tftp"

TFTP_DIRECTORY= "/ var/lib/tftpboot"

TFTP_ADDRESS= "[: 0.0.0.0:]: 69"

TFTP_OPTIONS= "--secure"

RUN_DAEMON= "yes"

OPTIONS= "- l-s / var/lib/tftpboot"

Save the file and exit.

3. Use xinetd to make the boot service start automatically every time the system is powered on, and start the tftpd service.

The code is as follows:

Sudo update-inetd-enable BOOT

Sudo service tftpd-hpa start

4. Check the status.

The code is as follows:

Sudo netstat-lu

It will look like this:

The code is as follows:

Proto Recv-Q Send-Q Local Address Foreign Address State

Udp 0 0 *: tftp *: *

Configure the PXE startup file

Now, you need to put the PXE boot file "pxelinux.0" in the TFTP root directory. Create a directory structure for TFTP and copy all bootstrap files provided by syslinux from "/ usr/lib/syslinux/" to "/ var/lib/tftpboot/", as follows:

The code is as follows:

Sudo mkdir / var/lib/tftpboot

Sudo mkdir / var/lib/tftpboot/pxelinux.cfg

Sudo mkdir-p / var/lib/tftpboot/Ubuntu/14.04/amd64/

Sudo cp / usr/lib/syslinux/vesamenu.c32 / var/lib/tftpboot/

Sudo cp / usr/lib/syslinux/pxelinux.0 / var/lib/tftpboot/

Set up the PXELINUX profile

The PXE configuration file defines the menu that appears when the PXE client starts, which can boot and associate with the TFTP server. By default, when a PXE client starts, it uses its own MAC address to specify the configuration file to read, so we need to create a default file that contains a list of bootable kernels.

Edit the PXE server configuration file to use valid installation options.

Edit "/ var/lib/tftpboot/pxelinux.cfg/default":

The code is as follows:

Sudo nano / var/lib/tftpboot/pxelinux.cfg/default

Make the following modifications:

The code is as follows:

DEFAULT vesamenu.c32

TIMEOUT 100

PROMPT 0

MENU INCLUDE pxelinux.cfg/PXE.conf

NOESCAPE 1

LABEL Try Ubuntu 14.04 Desktop

MENU LABEL Try Ubuntu 14.04 Desktop

Kernel Ubuntu/vmlinuz

Append boot=casper netboot=nfs nfsroot=192.168.1.20:/var/lib/tftpboot/Ubuntu/14.04/amd64

Initrd=Ubuntu/initrd.lz quiet splash

ENDTEXT

LABEL Install Ubuntu 14.04 Desktop

MENU LABEL Install Ubuntu 14.04 Desktop

Kernel Ubuntu/vmlinuz

Append boot=casper automatic-ubiquity netboot=nfs nfsroot=192.168.1.20:/var/lib/tftpboot/Ubuntu/14.04/amd64

Initrd=Ubuntu/initrd.lz quiet splash

ENDTEXT

Save the file and exit.

Edit the / var/lib/tftpboot/pxelinux.cfg/pxe.conf file.

The code is as follows:

Sudo nano / var/lib/tftpboot/pxelinux.cfg/pxe.conf

Make the following modifications:

The code is as follows:

MENU TITLE PXE Server

NOESCAPE 1

ALLOWOPTIONS 1

PROMPT 0

MENU WIDTH 80

MENU ROWS 14

MENU TABMSGROW 24

MENU MARGIN 10

MENU COLOR border 30th 44 # ffffffff # 00000000 std

Save the file and exit.

Add a Ubuntu 14.04 desktop boot image to the PXE server

The Ubuntu kernel and initrd files are required for this step. To get these files, you need a Ubuntu 14.04 desktop ISO image. You can download the Ubuntu 14.04 ISO image to the / mnt directory with the following command:

The code is as follows:

Sudo cd / mnt

Sudo wget http://releases.ubuntu.com/14.04/ubuntu-14.04.3-desktop-amd64.iso

Note: the URL used for download may change because the ISO mirror will be updated. If the above URL is not accessible, take a look at this website for the latest download link.

Mount the ISO file and copy all files to the TFTP folder using the following command:

The code is as follows:

Sudo mount-o loop / mnt/ubuntu-14.04.3-desktop-amd64.iso / media/

Sudo cp-r / media/* / var/lib/tftpboot/Ubuntu/14.04/amd64/

Sudo cp-r / media/.disk / var/lib/tftpboot/Ubuntu/14.04/amd64/

Sudo cp / media/casper/initrd.lz / media/casper/vmlinuz / var/lib/tftpboot/Ubuntu/

Configure the exported ISO directory to the NFS server

Now, you need to set up "install Source Mirror (Installation Source Mirrors)" through the NFS protocol. You can also use HTTP and FTP to install the source image. Here, I have used NFS to output ISO content.

To configure the NFS server, you need to edit the "/ etc/exports" file.

The code is as follows:

Sudo nano / etc/exports

Make the following modifications:

The code is as follows:

/ var/lib/tftpboot/Ubuntu/14.04/amd64 * (ro,async,no_root_squash,no_subtree_check)

Save the file and exit. For the changes to take effect, output and start the NFS service.

The code is as follows:

Sudo exportfs-a

Sudo / etc/init.d/nfs-kernel-server start

Your PXE server is now ready.

Configure the Network Boot PXE client

The PXE client can be any computer system that supports PXE network boot. Now, your client only needs to set the "boot from the network (Boot From Network)" option in the system's BIOS to launch and install the Ubuntu 14.04 desktop.

Now get ready to go-start your PXE client computer with a network boot, and you should now see a submenu showing the menu items for the Ubuntu 14.04 desktop we created.

At this point, I believe you have a deeper understanding of "how to configure a PXE server on a Ubuntu system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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