实施DHCP服务增加网络引导扩展服务(+PXE启动+网络HTTP安装操作系统)

来源:互联网 发布:知乎 高中 书包 编辑:程序博客网 时间:2024/04/28 22:35

、介绍

简单原理介绍:无光驱服务器和主机通过PXE网卡启动,从DHCP服务器获取IP 通过TFTP取到PXE启动用配置文件,并按配置文件通过HTTP服务提供的安装文件进行引导系统安装。

 

二、环境说明

测试环境及用到的软件

操作系统:LinuxCentOS)内核=2.6.18-164.15.1.el5PAE

操作系统启用服务:标准DHCP服务和TFTP服务(端口号:69),使用的IP地址为192.168.4.4

注:可根据实际需要,如只有一台服务器的情况下在系统中同时启用HTTP服务。

 

三、安装配置过程及基本讲解:

安装相应的软件:

#yum -y install dhcp* nfs*[l1]  tftp*

 

1TFTP服务配置:

TFTP安排根目录及PXE启动默认项

# mkdir /tftpboot/pxelinux.cfg

# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

(如果没有pxelinux.0,可以先安装syslinux,再到/usr/share/syslinux/里面去找)

再从光盘或ISO镜像中COPY相应文件

[isolinux]# cp isolinux.cfg /tftpboot/pxelinux.cfg/default

[isolinux]# cp *.msg /tftpboot/

[images/pxeboot]# cp initrd.img /tftpboot/initrd.img

[images/pxeboot]# cp vmlinuz /tftpboot/vmlinuz

 

再对TFTP配置文件进行修改

# more /etc/xinetd.d/tftp

# vi /etc/xinetd.d/tftp

# 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 /tftpboot[l2] 

#       server_args             = -u nobody[l3]  -s /tftpboot

#       disable                 = yes

        disable                 = no

        per_source              = 11

        cps                     = 100 2

        flags                   = IPv4

}

 

配置好后,重启xinetd服务:

chmod 777 –R /tftpboot

#/etc/init.d/xinetd restart

查看是否启动成功:

#chkconfig --list | grep tftp

这就可以让DHCP中的BOOT?不是,还要加引导及启动安装文件等等



2、配置nfs或使用HTTP模式

NFS用的是UDP-2049接收客户端请求,随机取用724以下的端口传输。

注意:RPC服务重启后,NFS服务也要重启以获得新的注册。

 

先做准备工作:

挂载的镜像文件或挂载光驱(我这边挂在WEB服务器HTTP根的CentOS5.5目录下)

如果用HTTP模式安装操作系统则

#mount /var/www/CentOS-5.5-i386-bin-DVD.iso /var/www/html/CentOS5.5 -o loop

 (最好把这个内容写到 /etc/rc.local 里作为启动后最后加载的目录

如果用NFS模式安装操作系统则

#mount /iso/CentOS-5.5-i386-bin-DVD.iso /mnt/CentOS5.5 -o loop

 

再设置共享的目录,用于实现PXE启动后的NFS支持的安装

#echo "/tftpboot *(ro,sync)" > /etc/exports

#echo "/mnt *(ro,sync)" >> /etc/exports

使共享配置生效

#exportfs -a

启动(重启)PORTMAP服务和NFS服务

#/etc/init.d/portmap restart

#/etc/init.d/nfs restart

看查共享的目录

#showmount -e localhost

 

3、配置DHCP

配置系统的DHCP服务设置文件

# vi /etc/dhcpd.conf

# more /etc/dhcpd.conf

#开放网络引导

allow bootp;

allow booting;

 

#subnet (on eth0) = VLAN 12

subnet 192.168.4.0 netmask 255.255.255.0 {

       option domain-name "test.hdzx";

       range dynamic-bootp 192.168.4.20 192.168.4.100;

       option routers 192.168.4.1;

       option broadcast-address 192.168.4.255;    

    # Group the PXE bootable hosts together

# PXE-specific configuration directives...

确立查找BOOTP的服务器TFTP服务地址

next-server 192.168.4.4;

初始引导的文件路径

    filename "/pxelinux.0";

}

配置完后,启动服务

# /etc/init.d/dhcpd restart

如果查错,比如没有正常启动则

# tail -n 50 /var/log/messages

 

4、验收

启动服务器,一般是按F12选择进入PXE网络启动。这时就会自动获取IP并进入

Boot: 界面。按linux text 进入。之后选择NFSHTTP安装系统。


 


 [l1]如果不用WEB服务提供安装软件的PACKET,可加装NFS服务。
 [l2]是将后面的路径作为服务的根目录
 [l3]是将nobody作为默认登录的用户类型
原创粉丝点击