configure pxe server on centos76 to install suse

本文详细指导如何在 CentOS 7 简易服务器上设置 PXE 服务器,包括 DHCP 服务器配置、TFTP 服务、syslinux 配置、PXE 客户机安装引导流程,并禁用防火墙和SELinux以简化环境。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Scenario
My test box (pxe server) details are given below:

Operating System : CentOS 7 Minimal server.
IP Address : 10.238.154.60/24.
SELinux disabled on the PXE server.
IP tables stopped on the PXE server.
In this tutorial, we are going to see how to setup a PXE server On CentOS 7 server, and install CentOS 7 64 bit edition on our client system using the PXE server.

Install PXE Server
First, you should Install and configure DHCP server on your PXE server. To install and configure DHCP server, refer the following:

Install DHCP Server On CentOS
Now, install the following packages for setting up PXE environment:

yum install httpd xinetd syslinux tftp-server -y

Configure PXE Server
Go to /usr/share/syslinux/ directory:

cd /usr/share/syslinux/
Copy the following TFTP configuration files to the /var/lib/tftpboot/ directory.

cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /var/lib/tftpboot/
Edit file /etc/xinetd.d/tftp

vi /etc/xinetd.d/tftp
Enable TFTP server. To do this, change “disable=yes” to “no”.

# 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 /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

Mount SUSE installation ISO file to any directory of your choice, for example /mnt. I already have SLE-12-SP5-Server-DVD-x86_64-GM-DVD1 ISO image on my /root directory.

mount -o loop /root/SLE-12-SP5-Server-DVD-x86_64-GM-DVD1.iso /mnt/

Next, create a directory to store CentOS installation ISO image.

mkdir /var/lib/tftpboot/SLE-12-SP5-Server

Copy the ISO file contents to /var/lib/tftpboot/SLE-12-SP5-Server

cp -fr /mnt/* /var/lib/tftpboot/SLE-12-SP5-Server

Set the proper permissions to the above directory.

chmod -R 755 /var/lib/tftpboot/SLE-12-SP5-Server

Create a apache configuration file for PXE server under /etc/httpd/conf.d/ directory:

vi /etc/httpd/conf.d/pxeboot.conf
Add the following lines:

Alias /SLE-12-SP5-Server /var/lib/tftpboot/SLE-12-SP5-Server/

<Directory /var/lib/tftpboot/SLE-12-SP5-Server>
Options Indexes FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 192.168.1.0/24 10.238.154.0/24
</Directory>

Save and close the file.

Then, create a configuration directory for PXE server:

mkdir /var/lib/tftpboot/pxelinux.cfg
Now, create PXE server configuration file under the pxelinux.cfg:

vi /var/lib/tftpboot/pxelinux.cfg/default
Add the following lines:

PROMPT 0
NOESCAPE 0
ALLOWOPTIONS 0
TIMEOUT 100

DEFAULT menu.c32

MENU TITLE [ Boot Menu ]

LABEL install
menu default
menu label ^ubuntu Install
kernel installers/ubuntu/wily/amd64/linux
append vga=normal initrd=installers/ubuntu/wily/amd64/initrd.gz

LABEL install
menu label ^suse Install
kernel installers/suse/linux
append vga=normal initrd=installers/suse/initrd install=http://10.238.154.60/SLE-12-SP5-Server/

Save and close the file.

Configure DHCP Server
Now, we have to configure the DHCP server to work with PXE server.

Edit file /etc/dhcp/dhcpd.conf,

vi /etc/dhcp/dhcpd.conf
Add the following lines at the end:

allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server 10.238.154.60;
filename "pxelinux.0";

Save and close the file.

Now, We have come to the end of PXE server configuration. Restart all the services to complete the configuration.

systemctl restart xinetd
systemctl restart httpd
systemctl restart dhcpd
Enable all services to start automatically on every reboot.

systemctl enable xinetd
systemctl enable httpd
systemctl enable dhcpd
Congratulations! We have completed the PXE server configuration.

Disable Firewall and SELinux
To reduce complexity, I have disabled both firewall and SELinux in my PXE server.

To disable firewall, run the following commands:

systemctl disable firewalld
systemctl stop firewalld
To disable SELinux, edit file /etc/sysconfig/selinux:

vi /etc/sysconfig/selinux
Find the line: SELINUX=enforcing and change it to SELINUX=disabled

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
Save and close the file. Reboot your PXE server to take effect the saved changes.

Now, let us configure PXE clients.
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mounter625

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值