so_brave 发表于 2011-11-15 16:23

Pxe+dhcp+nfs+tftp 网络安装centos

Pxe+dhcp+nfs+tftp 网络安装centos





一、 介绍
简单原理介绍:无光软驱服务器通过PXE网卡启动,从dhcp服务器获取IP 通过tftp 下载pxelinux.0文件找到pxelinux.cfg里的配置文件,按配置文件找着vmlinuz引导centos进入安装界面,之后选择NFS方式安装系统。

另: 如需要实现全自动安装 要安装 Kickstart软件包并配置。本文并不讨论

二、环境说明
本文测试环境及用到的软件
Server: centos 5.2dhcp nfs tftpip:192.168.1.251 (此IP只需要与服务器网卡相连,不管是什么都可以)

三、安装配置过程及基本讲解:
安装相应的软件:yum ?y install dhcp* nfs* tftp*
1、 配置tftpmore /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.

•# trad: liuyu

•# blog: liuyu.blog.51cto.com

•# bbs: www.linuxtone.org

•service tftp

•{

•      disable = no   #默认是yes 改为no

•      socket_type             = dgram

•      protocol                = udp

•      wait                  = yes

•      user                  = root

•      server                  = /usr/sbin/in.tftpd

•      server_args             = -u nobody -s /tftpboot#添加nobody可以访问

•      per_source            = 11

•      cps                     = 100 2

•      flags                   = IPv4

•} 复制代码重启xinetd服务: /etc/init.d/xinetd restart
   查看tftp 是否启动:# chkconfig --list |grep tftp
                        tftp:         on2、 配置nfsmount /iso/CentOS-5.2-i386-bin-1of6.iso /mnt -o loop#我是挂载的镜像文件,你们可以挂载光驱
echo "/tftpboot *(ro,sync)" > /etc/exports
echo "/mnt *(ro,sync)" > /etc/exports   #此二步设置共享的目录
exportfs ?a   #使配置生效
/etc/init.d/portmap start&&/etc/init.d/nfs start    #重启服务
Showmount ?e localhost#看查共享的目录
Export list for localhost:
/mnt      *
/tftpboot *3、配置dhcp
直接copy我的配置# more /etc/dhcpd.conf

•#

•# DHCP Server Configuration file.

•#   see /usr/share/doc/dhcp*/dhcpd.conf.sample

•#

•# trad: liuyu

•# blog: liuyu.blog.51cto.com

•# bbs: www.linuxtone.org



•ddns-update-style interim;

•ignore client-updates;

•allow booting;

•allow bootp;

•subnet 192.168.1.0 netmask 255.255.255.0 {



•option routers 192.168.1.251;

•option subnet-mask 255.255.255.0;

•option domain-name-servers 192.168.1.251;   #本地IP

•option time-offset -18000; # Eastern Standard Time

•range dynamic-bootp 192.168.1.12 192.168.1.254;#要分区的IP

•default-lease-time 21600;

•max-lease-time 43200;

•# Group the PXE bootable hosts together

•# PXE-specific configuration directives...

•next-server 192.168.1.251;

•filename "/pxelinux.0";   #方便查找配置文件

•} 复制代码/etc/init.d/dhcpd start启动服务

4、 配置pxe所需要的文件Mkdir /tftpboot/pxelinux.cfg

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

•cp /mnt/isolinux/vmlinuz /tftpboot/

•cp /mnt/isolinux/initrd.img /tftpboot/

•cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default复制代码四、测试
启动服务器,一般是按F12选择进入PXE网络启动。这时就会自动获取IP并进入
Boot: 界面。按linux text 进入。之后选择NFS安装系统。

五、配置文件详解
dhcpd.conf配置的有关说明:

parameters(参数):
ddns-update-style 配置DHCP-DNS互动更新模式
default-lease-time 指定缺省租赁时间的长度,单位是秒
max-lease-time 指定最大租赁时间长度,单位是秒
hardware 指定网卡接口类型和MAC地址
server-name 通知DHCP客户服务器名称
get-lease-hostnames flag 检查客户端使用的IP地址
fixed-address ip 分配给客户端一个固定的地址
authritative 拒绝不正确的IP地址的要求

declarations(声明):
shared-network 用来告知是否一些子网络分享相同网络
subnet 描述一个IP地址是否属于该子网
range 起始IP 终止IP 提供动态分配IP 的范围
host 主机名称 参考特别的主机
group 为一组参数提供声明
allow unknown-clients或deny unknown-client 是否动态分配IP给未知的使用者
allow bootp或deny bootp 是否响应激活查询
allow booting或deny booting 是否响应使用者查询
filename 开始启动文件的名称,应用于无盘工作站
next-server 设置服务器从引导文件中装如主机名,应用于无盘工作站

option(选项):
subnet-mask 为客户端设定子网掩码
domain-name 为客户端指明DNS名字
domain-name-servers 为客户端指明DNS服务器IP地址
host-name 为客户端指定主机名称
routers 为客户端设定默认网关
broadcast-address 为客户端设定广播地址
ntp-server 为客户端设定网络时间服务器IP地址
time-offset 为客户端设定和格林威治时间的偏移时间,单位是秒。

king_819 发表于 2011-11-16 21:42

cobbler方便又好用
页: [1]
查看完整版本: Pxe+dhcp+nfs+tftp 网络安装centos