One click to build the PXE automatic machine

Source: Internet
Author: User
Tags file transfer protocol


1. What is a DHCP server? What are the parameters that can be assigned?


Dynamic Host Configuration Protocol, mainly simplifies the management of host IP address assignment


Parameters that can be assigned


IP address/Subnet mask/broadcast address


Gateway


DNS server address


2. Benefits of using DHCP


Reduce the workload for administrators


Reduce the possibility of input errors


Avoid IP collisions


When the network changes IP segment Yes, you do not need to reconfigure the IP for each computer


Computer move does not have to reconfigure TCP/IP information


Increase IP Address utilization


########################################################################################################

Building a basic DHCP server

Installing DHCP Packages

[[email protected] ~]# yum-y Install DHCP

Modifying the master configuration file

[Email protected] ~]# vim/etc/dhcp/dhcpd.conf

Read in configuration file

R:/usr/share/doc/dhcp*/dhcpd.conf.sample

[Email protected] ~]# tail-7/etc/dhcp/dhcpd.conf

Subnet 192.168.4.0 netmask 255.255.255.0 {

Range 192.168.4.10 192.168.4.50;

Option Domain-name-servers 192.168.4.5;

Option routers 192.168.4.254;

Default-lease-time 600;

Max-lease-time 7200;

}

Start the DHCP service [[email protected] ~]#/ETC/INIT.D/DHCPD restart

pc205

Modify the eth0 NIC configuration file

[Email protected] ~]# Vim/etc/sysconfig/network-scripts/ifcfg-eth0

Bootprotr=dhcp

Restart Network

[Email protected] ~]#/etc/init.d/network restart

Svr5

If starting DHCP fails the query port is occupied

[Email protected] ~]# NETSTAT-ANPTU | grep 67

UDP 0 0 0.0.0.0:67 0.0.0.0:* 2189/dnsmasq

Kill Port Occupancy

[Email protected] ~]# Killall DNSMASQ

Restart SVR5 DHCP again

[Email protected] ~]#/ETC/INIT.D/DHCPD restart


Querying the port again to see if it occupies

[Email protected] ~]# NETSTAT-ANPTU | grep 67

UDP 0 0 0.0.0.0:67 0.0.0.0:* 3110/DHCPD

######################################################################################################

Server-side UDP 67, client UDP 68


There should be at least one static IP address that belongs to the specified scope

Temporary configuration/testing, we recommend the use of Dhcplient

Format Dhclient-d Network interface

Option-D debug Mode-R release address


############################################################################################################

PXE Network installation Deployment

Advantages of network installed

Scale: Assemble multiple hosts at the same time

Automatic installation system configuration of various services

Remote implementations do not require physical installation media such as USB flash drive discs

What's the PXE network

Pxe

Pre-boot execution environment before the operating system runs

Can be used for remote installation to build diskless workstations

Working mode PXE integrated in the NIC ROM

BIOS puts PXE Clint into memory execution when calculating boot

Get PXE server configuration display menu download remote operating system to run locally based on user selection

PXE component and Process analysis

Need those services

DHCP service assigns IP address locator bootstrapper

DNS service assigns host names to clients

TFTP service provides bootstrapper download

The FTP service (or HTTP/NFS) provides a Yum installation source

The conditions the client should have

The NIC ROM must support the PXE protocol

Motherboard Support Network boot

############################################################################################################### ###################

Building DNS

Modifying the master configuration file

[Email protected] ~]# vim/etc/named.conf

Options {

Directory "/var/named";

};




Zone "4.168.192.in-addr.arpa" in {

Type master;

File "192.168.4.zone";

};




Modify the Address library file

[Email protected] ~]# Vim/var/named/192.168.4.zone


NS svr5.tedu.cn.

$GENERATE 10-50 $ PTR stu$.tedu.cn.

Restart named service

[Email protected] ~]#/etc/init.d/named restart

Native validation

[email protected] ~]# nslookup 192.168.4.10 192.168.4.5

Server:192.168.4.5

Address:192.168.4.5#53


10.4.168.192.in-addr.arpaname = stu10.tedu.cn.



#######################################################################################################

Configure DHCP

Modifying the master configuration file

[Email protected] ~]# vim/etc/dhcp/dhcpd.conf

Next-server 192.168.4.5; Specify who the next server is

FileName "pxelinux.0"; Specify the name of the download boot file

}


Restart DHCPD Service

[Email protected] ~]#/ETC/INIT.D/DHCPD restart

#######################################################################################################

TFTP configuration

TFTP: Simple File Transfer Protocol UDP 69

Temporary services

Installing temporary Services

[Email protected] ~]# yum-y install Tftp-server


Handing over temporary services to xinetd Butler

[[email protected] ~]# chkconfig tftp on

Restart the Xinete

[Email protected] ~]#/etc/init.d/xinetd restart

Query port number

[Email protected] ~]# NETSTAT-ANPTU |grep xinetd

UDP 0 0 0.0.0.0:69 0.0.0.0:* 4783/xinetd


TFTP: Default shared file path/var/lib/tftpboot/

1. Prepare the pxelinux.0 (NIC boot file)

Query the pxelinux generated by that one package in the warehouse. 0

[Email protected] ~]# Yum-y provides */pxelinux.0

Installation


[Email protected] ~]# yum-y install Syslinux-nonlinux

Query path


[Email protected] ~]# rpm-ql syslinux-nonlinux |grep pxelinux.0

/usr/share/syslinux/gpxelinux.0

/usr/share/syslinux/pxelinux.0

Copy pxelinux.0

[Email protected] ~]# cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/,

Query pxelinux.0

[Email protected] ~]# ls/var/lib/tftpboot/

pxelinux.0


#######################################################################################################


2 preparing the Kernel and drivers

Mounting discs

[Email protected] ~]# mount/dev/cdrom/mnt

Mount:block Device/dev/sr0 is write-protected, mounting read-only

Copy files

[Email protected] ~]# cp/mnt/isolinux/vmlinuz/var/lib/tftpboot/

[Email protected] ~]# cp/mnt/isolinux/initrd.img/var/lib/tftpboot/

View Files

[Email protected] ~]# ls/var/lib/tftpboot/

Initrd.img pxelinux.0 Vmlinuz


3. Prepare the menu file

Create File Ka

[Email protected] ~]# mkdir/var/lib/tftpboot/pxelinux.cfg

Copy renaming default must be named

[Email protected] ~]# Cp/mnt/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default

Permissions 644

[Email protected] ~]# chmod 644/var/lib/tftpboot/pxelinux.cfg/default


Modifying a configuration file

[Email protected] ~]# Vim/var/lib/tftpboot/pxelinux.cfg/default

[Email protected] ~]# Cat/var/lib/tftpboot/pxelinux.cfg/default

Default Linux defaults to select that one label

Timeout 60 read seconds 6 seconds 1/10 seconds


Label Linux label name

Kernel Vmlinuz Loading kernel

Append initrd=initrd.img Load Driver


##################################################################################################

FTP Setup

[[email protected] ~]# rpm-q vsftpd Check if RPM is installed

Vsftpd-2.2.2-14.el6.x86_64

[[email protected] ~]#/ETC/INIT.D/VSFTPD status program is running

VSFTPD (PID 1818) is running ...

[[email protected] ~]# ls/var/ftp/query file

Anon.txt Pub

[[email protected] ~]# mkdir/var/ftp/rhel6 Create RHEL6 folder

[[email protected] ~]# mount/dev/cdrom/var/ftp/rhel6 mount file to Rhel6

Mount:block Device/dev/sr0 is write-protected, mounting read-only mounted successfully


Test Firefox ftp://192.168.4.5/rhel6 on a real machine


###########################################################################################################

Unattended Installation Kickstart answer file

Installation

1. Installing the Yum-y install System-config-kickstart graphics generate answer File tool

2. Running the System-config-kickstart program

View Ks.cfg

[Email protected] ~]# ls/root/ks.cfg

/root/ks.cfg

The file should be placed in the./var/ftp

[Email protected] ~]# cp/root/ks.cfg/var/ftp/


[Email protected] ~]# ls/var/ftp/ks.cfg

/var/ftp/ks.cfg

######################################################################################################

Last Step Modify Menu file

[Email protected] ~]# Vim/var/lib/tftpboot/pxelinux.cfg/default

[Email protected] ~]# tail-9/var/lib/tftpboot/pxelinux.cfg/default

Default Linux

Timeout 60


Label Linux

Kernel Vmlinuz

Append initrd=initrd.img ks=ftp://192.168.4.5/ks.cfg



#######################################################################################################

Summarize ideas


DHCP----------->ip next-server.pxelinux.0

TFTP (initrd.img vmlinuz pxelinux.0 default)

Default (Load initrd.img load vmlinuz ks file)

KS File Installation Source


################################################################################################


This article from "Summer" blog, declined reprint!

One click to build the PXE automatic machine

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.