在网上也找了很多教程然后综合一下
1、需要安装的程序
tftp-server、dhcp、syslinux
2、安装和配置程序
yum install dhcp tftp-server syslinux
简单配置一下dhcp,vim /etc/dhcp/dhcp.c
option domain-name "example.org";
option domain-name-servers 61.139.2.69;
default-lease-time 600;
max-lease-time 7200;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
#subnet 172.20.128.0 netmask 255.255.255.0{
# range 172.20.128.200 172.20.128.220;
# option routers 172.20.128.1;
# netxt-server 172.20.28.1;
# filename "pxelinux.0";
#}
subnet 192.168.139.0 netmask 255.255.255.0{
range 192.168.139.200 192.168.139.220;
option routers 192.168.139.208;
#next-server 192.168.139.208;
filename "centos/6/isolinux/pxelinux.0";
}
注意:1、因为我的tftp也在本机所以next-server可以注释,filename是tftp的根目录到pxelinux.0。
2、注意网段,如果你的局域网有dhcp我建议以就设置在同一个网段
配置tftp,vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
注意:1、disable =no
拷贝文件到tftp中去
挂载光盘:mount /dev/cdrom /mnt
拷贝文件:cp /mnt/isolinux/* /var/lib/tftpboot/centos/6/isolinux/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/centos/6/isolinux/
创建一个目录mkdir /var/lib/tftpboot/centos/6/isolinux/pxelinux.cfg
拷贝配置:cp /var/lib/tftpboot/centos/6/isolinux/isolinux.cfg /var/lib/tftpboot/centos/6/isolinux/pxelinux.cfg/default
注意:1、centos/6/isolinux是我自己创建的目录
启动服务
1、centos6
service dhcpd restart
service tftp restart
2、centos7
systemctl restart dhcpd
systemctl restart tftp
注意:1、手动打的字如果有错,请提一下,我可以修改。谢谢