实战:Pxe+dhcp+nfs+tftp网络安装Centos

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

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

二、环境说明

本文测试环境及用到的软件

Server: centos 5.2  dhcp nfs tftp  ip:192.168.1.251 (此IP只需要与服务器网卡相连,不管是什么都可以)

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

安装相应的软件:yum –y install dhcp* nfs* tftp*

1、 配置tftp more /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:
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:           on

2、 配置nfs

mount /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:
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  启动服务

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyfxsd.html