LINUX-DHCP Service, PXE network batch automatic machine

Source: Internet
Author: User
Tags file transfer protocol

Virtual Machine A

1. Set the firewall state to trusted

2.SELinux currently modified to permissive

3.SELinux permanent status modified to permissive

4. Clear the Yum cache to check if Yum is available


Virtual Machine B

1. Set the firewall state to trusted

2.SELinux currently modified to permissive

3.SELinux permanent status modified to permissive

4. Clear the Yum cache to check if Yum is available


/etc/selinux/config (Permanent status profile)


------------------------------------------------------------------------------------------


Complete Virtual Machine Access extranet


1. In the real machine implementation, bridge equipment creation (BR0)

[[email protected]/]# systemctl status NetworkManager (graphic)

[[email protected]/]# systemctl Status Network (command line)

[[email protected]/]# systemctl stop NetworkManager (graphic)

[[email protected]/]# systemctl Status Network (command line)


Vim/etc/sysconfig/network-scripts/ifcfg-br0


Device=br0 #设备名

Type=bridge #设备类型

Bootproto=none #手工配置IP地址

Onboot=yes #开机自起动

ipaddr=172.40.50.114

netmask=255.255.255.0

gateway=172.40.50.1


2. Let the real machine ENP2S0 Real network card, connect br0, append write

Vim/etc/sysconfig/network-scripts/ifcfg-enp2s0

Bridge=br0


3. Re-start the network


4. Virtual machine has a network card, select Br0 Bridge equipment

-----------------------------------------------------------------------------------------


Deploying a DHCP server

A local area network can have only one DHCP server, otherwise it will cause network paralysis.


Dynamic Host Configuration Protocol

– Dynamic Host Configuration Protocol, developed by the IETF (Internet Network Engineer Task Force) to simplify host address allocation management


The main distribution of the following network parameters

– IP address/subnet mask/broadcast address

– Default gateway address, DNS server address

Four sessions assigned by DHCP address

–discovery-and offer-REQUEST-->ack


if the virtual machine does not bridge the real network


Virtual Machine A:

1. Install the package DHCP

2. configuration file/etc/dhcp/dhcpd.conf

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

Last line: R/usr/share/doc/dhcp*/dhcpd.conf.example #读入其他文件


Subnet 192.168.4.0 netmask 255.255.255.0 {#分配的网段

Range 192.168.4.100 192.168.4.200; #分配的IP地址范围

Option Domain-name-servers 8.8.8.8; #分配DNS

Option routers 192.168.4.254; #分配网关

Default-lease-time 600; #IP地址默认租用时间

Max-lease-time 7200; #IP地址租用最大时间

}


3. Service DHCPD

[Email protected]/]# systemctl restart DHCPD

[Email protected]/]# Systemctl enable DHCPD

[Email protected] ~]# NMCLI connection modify eth0 Ipv4.method auto #将IP设为自动获取

[Email protected] ~]# nmcli connection up eth0 #激活

Successfully activated connection (D-bus activation path:/org/freedesktop/networkmanager/activeconnection/111)




Add: Route-n View Gateway

----------------------------------------------------------------------------------------

On virtual machine A:


Kill DNSMASQ,DNSMASQ in KVM virtualization will provide DHCP service, there will be conflicts


[Email protected]/]# NETSTAT-ANPTU | grep:67

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

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

[Email protected]/]# Killall DNSMASQ

[Email protected]/]# NETSTAT-ANPTU | grep:67


----------------------------------------------------------------------------------------

Pxe,pre-boot Execution Environment

– Pre-boot execution environment, run before operating system

– can be used for remote installation

Working mode

–PXE client integrated in the boot chip of the NIC

– When the computer boots, the PXE client is transferred from the NIC chip to the memory execution, the PXE server configuration, the Display menu, and the remote boot program is downloaded to the native run according to the user's choice



----------------------------------------------------------------------------------------

PXE Network installed server

DHCP: Provide IP address

TFTP (Simple Text Transfer Protocol): provides numerous boot files, hardware

FTP: Provides a wide range of RPM packages

DHCP, TFTP, and FTP are all built on a single server


I. Building a DHCP service

1. Specify the address of the next server IP

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


Subnet 192.168.4.0 netmask 255.255.255.0 {

Range 192.168.4.100 192.168.4.200;

Option Domain-name-servers 8.8.8.8;

Option routers 192.168.4.254;

Default-lease-time 600;

Max-lease-time 7200;

Next-server 192.168.4.7; #指定下一个服务器IP地址

FileName "pxelinux.0"; #指定网卡引导文件, file name

}


2. Restart DHCPD Service

pxelinux.0: Network card Boot file (installation instructions), binary file

Need to install a software, you can generate pxelinux.0

-------------------------------------------------------------------------------------------

Second, build TFTP service


TFTP: Simple File Transfer Protocol port: 69


Server-side program: Tftp-server provides a TFTP service package

Service Name: TFTP

Default share path:/var/lib/tftpboot


1. Installing Tftp-server

2. Start the TFTP service and set it to boot from

3. Deploying the pxelinux.0 File

# YUM provides */pxelinux.0 #查询仓库中哪一个包产生该文件

# yum-y Install Syslinux


# RPM-QL Syslinux #查询软件包的安装清单


# RPM-QL Syslinux | grep pxelinux.0 path to #找到pxelinux. 0


# cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/#复制到共享目录下


# ls/var/lib/tftpboot/

-------------------------------------------------------------------------------------------

Load Menu File Default

pxelinux.0-------------"/var/lib/tftpboot/pxelinux.cfg/default


4. Deploy default Menu file

# mkdir/var/lib/tftpboot/pxelinux.cfg #创建放置default文件的目录


# mount/dev/cdrom/mnt/#先确认虚拟机是否放入光盘文件


# cp/mnt/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default # "Isolinux.cfg" for the disc's menu file


# ls-l/var/lib/tftpboot/pxelinux.cfg/default


# chmod 644/var/lib/tftpboot/pxelinux.cfg/default #修改权限, easy to modify content, to the owner of this directory to attach written files


# ls-l/var/lib/tftpboot/pxelinux.cfg/default


5. Module VESAMENU.C32 for deploying graphics

# ls/mnt/isolinux/


# cp/mnt/isolinux/vesamenu.c32/var/lib/tftpboot/


# ls/var/lib/tftpboot/


6. Modify the menu file/var/lib/tftpboot/pxelinux.cfg/default


# Vim/var/lib/tftpboot/pxelinux.cfg/default

......

One menu title NSD1709 PXE Server!

......

The label Linux

^install menu Label RHEL7 # "^" means shortcut key I can jump to this item, you can remove

Kernel Vmlinuz #启动内核 (not the kernel of Linux), all the hardware in the explorer

Append initrd=initrd.img #驱动程序

You can remove it later.


7. Deploy the boot kernel and drivers

#cp/mnt/isolinux/initrd.img/mnt/isolinux/vmlinuz/var/lib/tftpboot/#同时拷贝两个文件


# ls/var/lib/tftpboot/


Initrd.img pxelinux.cfg Vmlinuz

pxelinux.0 VESAMENU.C32


---------------------------------------------------------------------------------------

pxelinux.0-------"/var/lib/tftpboot/pxelinux.cfg/default

Default------"VESAMENU.C32-----" vmlinuz, initrd.img

---------------------------------------------------------------------------------------


Three, FTP service, transmission RPM package


1. Build vsftpd service, share all contents of CD

2. Installing the VSFTPD Software

3. Set the VSFTPD service to start, set to boot from

4. Share all the contents of the disc

[Email protected]/]# MKDIR/VAR/FTP/RHEL7

[Email protected]/]# MOUNT/DEV/CDROM/VAR/FTP/RHEL7


[Email protected]/]# LS/VAR/FTP/RHEL7


[email protected]/]# Firefox FTP://192.168.4.7/RHEL7

--------------------------------------------------------------------------------

Iv. unattended installation, generating an answer file

1. Install the graphics generate answer file program: System-config-kickstart


2. Run the graphics program: System-config-kickstart


Read the local Yum warehouse information, require the Yum warehouse client configuration file, the warehouse is identified as


[Development]


3. Run the graphics program: System-config-kickstart generate the answer file ks.cfg


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

[Email protected]/]# vim/root/ks.cfg


4. Build vsftpd service, share answer file


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

[Email protected]/]# ls/var/ftp/

Ks.cfg Pub RHEL7



-------------------------------------------------------------------------------------------

V. Specify the ks.cfg answer file via the menu


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


The label Linux

RHEL7 Menu Label Install

Kernel Vmlinuz

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



----------------------------------------------------------------------------------------

Summarize:

DHCP------>IP Address, next-server, filename

TFTP------>pxelinux.0, default

Default---->VESAMENU.C32, Vmlinuz, initrd.img, ks.cfg

KS.CFG----> url= "FTP://192.168.4.7/RHEL7"

LINUX-DHCP Service, PXE network batch 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.