Shell脚本之DNS正向解析与pxe装机

Shell脚本之DNS正向解析与pxe装机

一、正向解析

#!/bin/bash
yum install -y bind
sed -i -e '13 s/127.0.0.1/any/' -e '19 s/localhost/any/' /etc/named.conf
sed -i -e '19 s/localhost/ng.com/' -e '21 s/named.localhost/ng.com.zone/' /etc/named.rfc1912.zones
cd /var/named
cp -p named.localhost ng.com.zone
sed -i -e '9 s/127.0.0.1/192.168.117.30/' -e '10c www IN A 192.168.117.100' /var/named/ng.com.zone
sed -i '2c  nameserver 192.168.117.30' /etc/resolv.conf
systemctl stop firedwalld
setenforce 0
systemctl restart named

在这里插入图片描述
在这里插入图片描述

二、PXE

#!/bin/bash
systemctl stop firewalld
setenforce 0
yum install -y tftp-server xinetd &> /dev/null
sed -i -e '10 s/yes/no/' -e '14 s/yes/no/' /etc/xinetd.d/tftp
systemctl start tftp
systemctl enable tftp
systemctl start xinetd
systemctl enable xinetd
yum install -y dhcp &> /dev/null
cd /usr/share/doc/dhcp-4.2.5
cp dhcpd.conf.example /etc/dhcp/dhcpd.conf
echo -e 'y \n'  
sed -i '14 s/#//' /etc/dhcp/dhcpd.conf
sed -i '14a next-server 192.168.117.30;' /etc/dhcp/dhcpd.conf
sed -i '15a filename "pxelinux.0";' /etc/dhcp/dhcpd.conf
sed -i -e '34 s/10.254.239.0/192.168.117.0/' -e '34 s/224/0/' /etc/dhcp/dhcpd.conf
sed -i '35c range 192.168.117.100 192.168.117.200;' /etc/dhcp/dhcpd.conf
sed -i '36c option routers 192.168.117.30;' /etc/dhcp/dhcpd.conf 
systemctl start dhcpd
systemctl enable dhcpd
cd /mnt/images/pxeboot
cp initrd.img vmlinuz /var/lib/tftpboot
yum install -y syslinux &> /dev/null
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
yum install -y vsftpd &> /dev/null
mkdir /var/ftp/centos7 
cp -rf /mnt/* /var/ftp/centos7
systemctl start vsftpd
systemctl enable vsftpd
mkdir /var/lib/tftpboot/pxelinux.cfg
touch /var/lib/tftpboot/pxelinux.cfg/default
echo 'default auto                              
prompt 1                                

label auto                      
kernel vmlinuz          
append initrd=initrd.img method=ftp://192.168.117.30/centos7

label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.117.30/centos7

label linux rescue                              
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.117.30/centos7' > /var/lib/tftpboot/pxelinux.cfg/default

在这里插入图片描述
已验证可以进行pxe装机

猜你喜欢

转载自blog.csdn.net/Ryu_hayabusa/article/details/114794442