Pxe+dhcp+nfs+tftp网络安装修改版.doc
- 格式:docx
- 大小:1.62 MB
- 文档页数:15
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:
# 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服务
需要的软件包都安装好之后,使用vim编辑器编辑dhcp服务的配置文件/etc/dhcp.conf
由于是第一次编辑dhcp.conf所以里面的内容是空的,那么我们就需要将/usr/shar/doc/dhcp-3.0.5/dhcp.conf.sample 复制到/etc下并改名为dhcp.conf
复制之后,再进入配置文件可以看到以下内容,然后就可以进行相应的修改了。。。
修改后的内容如下:
ddns-update-style interim;
ignore client-updates;
next-server 10.1.24.1; TFTP的地址
filename "pxelinux.0";
subnet 10.1.24.0 netmask 255.255.255.0 { 注:设置子网
# --- default gateway
option routers 10.1.24.254; #网关地址
option subnet-mask 255.255.255.0; #子网掩码
default-lease-time 21600;
max-lease-time 43200;
range 10.1.24.20 10.1.24.200; #DHCP地址池
filename "/linuxinstall/ks.cfg"; (系统安装要求的配置文件位置,如果/tftpboot/pxelinux.cfg/default文件里面指定了路径,这个地方可以忽略)
}
option space PXE; (设置PXE)
class "PXE" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
option vendor-encapsulated-options 01:04:00:00:00:00:ff;
option boot-size 0x1;
filename "pxelinux.0";
option tftp-server-name "10.1.24.10";(tftp服务器的位置,与上面的next-server对应)
option vendor-class-identifier "PXEClient";
vendor-option-space PXE;
}
也可以根据系统默认的dhcpd.conf.sample稍做修改(如上图)关键是几个标
注的地方注意一下。
需要注意的是字段range是给待安装的机器分配的的IP地址池,filename 字段是ks.cfg的位置,即待安装机器所需要的安装配置文件,next-server 是tftp服务器的位置。和下面的tftp-server-name字段是对应的。
/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
复制代码(用下面的PXE配置文件)
配置ks.cfg文件
ks.cfg是待安装机器的所有的配置文件,每台机器在安装过linux系统以后都会自动生成一个ks.cfg文件里面记录了在安装系统的时候所做的所有操作,文件的位置位于/root目录下名为anaconda-ks.cfg。
图22 anaconda-ks.cfg文件