pxe和dhcp服务——引导安装操作系统

BootStraping:系统提供(OS Provision)

pxe –> preboot excution environment, Intel

cobbler –> Cobbler is a network install server.  Cobbler supports PXE, ISO virtualized installs, and re-installing existing Linux machines.

pxe:

     dhcp service (ip/nemask, gw, dns; filename, next-server)

     tftp server (bootloader, kernel, initrd)

     yum repository (ftp, http, https, nfs)

        

     kickstart

dhcp server:

DHCP:Dynamic Host Configuration Protocol

         arp –> address resolving Protocol

             IP –> MAC

         rarp –> reverse arp

             MAC –> IP

bootp –> boot protocol

    dhcp: lease time, bootp

工作流程:广播

         (1) Client:dhcp discover

         (2) Server: dhcp offer(IP/Netmask, GW, DNS Server, NTP Server, Wins Server, …)

         (3) Client:dhcp request

         (4) Server:dhcp ack

        

         lease time:租约期限;

             续租:50%, 75%, 87.5%, 93.75%

        

             dhcp discover,…

        

         续租:

                 dhcp request

                 dhcp ack|nak

实现:

         dhcp (isc.org) – The dhcp package provides the ISC DHCP service and relay agent.

         dnsmasq (dns, dhcp) – Dnsmasq is lightweight, easy to configure DNS forwarder and DHCP server. It is designed to provide DNS and, optionally, DHCP, to a small network.

dhcp:

程序环境:

         dhcp server:

                 /usr/sbin/dhcpd

                 IPV4网络:

                         /etc/dhcp/dhcpd.conf

                         /usr/lib/systemd/system/dhcpd.service

                 IPV6网络:

                         /etc/dhcp/dhcpd6.conf

                         /usr/lib/systemd/system/dhcpd6.service

         dhcrelay:

                 /usr/sbin/dhcrelay

                 /usr/lib/systemd/system/dhcrelay.service

监听的地址和端口:

         Server: 67/udp

         Client: 68/udp

配置文件:/etc/dhcp/dhcpd.conf

配置指令:

         option选项:配置给客户端的相信息

         指令:定义dhcp server的工作特性

配置有级别之分:

         全局配置

         子网配置

         主机配置

常用的配置:

         default-lease-time 600;

         max-lease-time 7200;

                

         option domain-name "search_domain.tld";

         option domain-name-servers DNS_SERVER1, DNS_SERVER2, DNS_SERVER3;

         option routers GW1, GW2, …;

         option broadcast-address BROADCAST_ADDRESS;

                

         subnet NETWORK  netmask MASK {

             range START_IP END_IP;

         }  定义网络作用域,即一个子网,主要用于指明地址池;

                

         host passacaglia {

                 hardware ethernet 0:0:c0:5d:bd:95;

                 fixed-address IP_ADDR;

         }

其它指令:

         filename:指明引导文件名称;

         next-server:指明引导文件所在的服务器的主机IP;

            

        示例:

         filename “pxelinux.0";

         next-server 10.1.0.6;  #指明tftp server地址

tftp server:

# yum install tftp-server tftp

         CentOS 7:

             systemctl start tftp.socket

            

         CentOS 6:

                 chkconfig tftp on

                 service xinetd restart

            

         69/udp

默认的文件根目录:/var/lib/tftpboot/

vsftpd server:

用作yum repository

# yum install vsftpd tftp

     CentOS 7:

         systemctl start vsftpd

    

     CentOS 6:

         chkconfig vsftpd on

把光盘挂载至/var/ftp/pub目录下,或者把光盘中的所有内容cp到/var/ftp/pub目录下

配置PXE环境:

CentOS 7: <基于http服务来提供yum repository>

yum  -y install syslinux httpd
mkdir /var/www/html/centos/7/x86_64
mount /dev/cdrom /var/www/html/centos/7/x86_64   #把光盘挂载至此目录
获取一个kickstart文件,放于/var/www/html目录下
    
cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img}  /var/lib/tftpboot
cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk}  /var/lib/tftpboot
    
mkdir /var/lib/tftpboot/pxelinux.cfg/
    
vim  /var/lib/tftpboot/pxelinux.cfg/default
    
    default menu.c32
    prompt 5
    timeout 30
    MENU TITLE CentOS 7 PXE Menu
        
    LABEL linux
    MENU LABEL Install CentOS 7 x86_64
    KERNEL vmlinuz
    APPEND initrd=initrd.img inst.repo=http://10.1.43.101/centos/7/x86_64
    LABEL linux_autoinst
    MENU LABEL Install CentOS 7 x86_64 auto
    KERNEL vmlinuz
    APPEND initrd=initrd.img inst.repo=http://10.1.43.101/centos/7/x86_64 ks=http://10.1.43.101/centos7.cfg

CentOS 6:

获取一个kickstart文件放在/var/ftp目录下
yum -y install syslinux-nolinux   #提供了/usr/share/syslinux/pxelinux.0文件
mount /dev/cdrom /var/ftp/pub
    
cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
cp /var/ftp/pub/images/pxeboot/{vmlinuz,initrd.img}  /var/lib/tftpboot/
cp /var/ftp/pub/isolinux/{boot.msg,vesamenu.c32,splash.jpg}  /var/lib/tftpboot/
    
mkdir /var/lib/tftpboot/pxelinux.cfg/
    
cp  /media/cdrom/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default
    
/var/lib/tftpboot/pxelinux.cfg/default 内容如下所示:
    
    display boot.msg
        
    menu background splash.jpg
    menu title Welcome to CentOS 6.7 MageEdu!
    menu color border 0 #ffffffff #00000000
    menu color sel 7 #ffffffff #ff000000
    menu color title 0 #ffffffff #00000000
    menu color tabmsg 0 #ffffffff #00000000
    menu color unsel 0 #ffffffff #00000000
    menu color hotsel 0 #ff000000 #ffffffff
    menu color hotkey 7 #ffffffff #ff000000
    menu color scrollbar 0 #ffffffff #00000000
        
    label autoinst
    menu label ^Auto Install CentOS
    menu default
    kernel vmlinuz
    append initrd=initrd.img ks=ftp://10.1.43.101/centos6.cfg
    label linux
    menu label ^Install or upgrade an existing system
    kernel vmlinuz
    append initrd=initrd.img
    label vesa
    menu label Install system with ^basic video driver
    kernel vmlinuz
    append initrd=initrd.img nomodeset
    label rescue
    menu label ^Rescue installed system
    kernel vmlinuz
    append initrd=initrd.img rescue
    label local
    menu label Boot from ^local drive
    localboot 0xffff
    label memtest86
    menu label ^Memory test
    kernel memtest
    append -

原创文章,作者:megedugao,如若转载,请注明出处:http://www.178linux.com/58319

(0)
megedugaomegedugao
上一篇 2016-11-05
下一篇 2016-11-05

相关推荐

  • liunx初探

    计算机的五大单元: 输出单元、输入单元、cpu内部控制单元、算术逻辑单元和内存。 计算机三大组成部分: 输入单元:键盘、鼠标等等 输出单元:屏幕、打印机等 中央处理器(CPU):含有算术逻辑、控制、记忆等 CPU种类有两种分别是:   精简指令集(RISC):这种cpu微指令比较精简,每个指令的执行时间都很短,完成的操作也很简单。常见的简单指令集C…

    Linux干货 2016-09-14
  • bond的常见使用方式和问题

    bond的简单建立于事项

    2017-09-09
  • 【26期】Linux第六周学习小总结

        时光匆匆,一周时光悠然而逝,带给我们的只有知识的充实,和每日强大的自信心,学习的日益深入,慢慢的然我们的思绪和状态带回高中时光,吃饭上课睡觉三点一线的生活,枯燥中透露出稍微的晨曦,让每个明天都充满着期待,那我们的本周的学习中磁盘管理算是占了很大的比重,毕竟关于磁盘的知识很是难理解,那我就把本周的知识回顾温习,同时分享给大家。 &n…

    2017-08-19
  • 实验:配额、RAID、LVM

    实验:在centos7实现光盘yum源 1yum install autofs 2现在启动systemctl start autofs 3开机启动systemctl enable autofs 4 cat /etc/yum.repos.d/base.repo[centos7]name=centos7 repobaseurl=file:///misc/cdgp…

    Linux干货 2017-04-25
  • 系统之锹sysdig:Linux服务器监控和排障利器

    当你需要追踪某个进程产生和接收的系统调用时,首先浮现在你脑海中的是什么?你可能会想到strace,那么你是对的。你会使用什么样的命令行工具来监控原始网络通信呢?如果你想到了tcpdump,你又作出了一个极佳的选择。而如果你碰到必须追踪打开的文件(在Unix意义上:一切皆文件)的需求,可能你会使用lsof。 strace、tcpdump以及lsof,确实是些伟…

    Linux干货 2015-02-09
  • DHCP及自动化安装Linux

    主机IP配置: 静态指定 静态IP 动态获取: bootp:bootprotocol MAC与IP一一静态对应 DHCP: Dynamic Host Configuration Protocol 动态主机配置协议基于UTP协议 主要用途:自动化分配IP地址,实现集中管理,解决IP地址不足的问题。 DHCP的4种报文 DHCP DISCOVER OFFER R…

    2017-09-18