欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

基于pxe+dhcp+ks实现自动安装系统

发布时间:2025/4/16 51 豆豆
生活随笔 收集整理的这篇文章主要介绍了 基于pxe+dhcp+ks实现自动安装系统 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

一、准备工作
1.添加一个网卡
2 .给这个新网卡配置IP 192.168.100.85/24
3. 修改新网卡的网络连接方式为vmnet3

[root@localhost ~]# mount /dev/cdrom /mnt/ [root@localhost ~]# service iptables stop [root@localhost ~]# setenforce 0

说明:本机第一个网卡地址为10.220.5.116

二、安装配置dhcp
1.安装dhcp

[root@localhost ~]# yum install dhcp dhcp-common

2.配置DHCP(虚拟网络vmnet)

[root@localhost ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf [root@localhost ~]# cd /etc/dhcp/ [root@localhost dhcp]# cp dhcpd.conf{,.bak} [root@localhost dhcp]# vim dhcpd.conf【只需要如下内容,其他的都可以删除】 option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org; default-lease-time 600; max-lease-time 7200; log-facility local7; subnet 192.168.100.0 netmask 255.255.255.0 {range 192.168.100.200 192.168.100.220;option routers 192.168.100.85;option domain-name-servers 8.8.8.8;}

3.启动dhcp

[root@localhost ~]# service dhcpd restart [root@localhost dhcp]# service dhcpd status [root@localhost dhcp]# ss -unl

4.测试dhcp功能
新开一台虚拟机网络连接模式设置为vmnet3,网卡配置文件如下图

重启网络,执行 ifconfig

# service network restart #ifconfig


这里看到这个主机的地址是 dhcp服务器从地址池中拿到的地址分配给了这台客户端的,说明dhcp配置成功。

三、配置tftp功能
1.安装tftp服务

[root@localhost ~]# yum install tftp tftp-server xinetd -y

2.启动

[root@localhost ~]# service xinetd restart [root@localhost ~]# chkconfig xinetd on [root@localhost ~]# chkconfig tftp on [root@localhost ~]# chkconfig --list | grep tftptftp: on

3.测试

这里我们可以看到能够通过tftp将/var/lib/tftpboot/ 的文件下载到/tmp下说明tftp配置成功。

四、准备pxe需要的相关文件
1.准备内核文件

[root@localhost ~]# cp /mnt/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/

2.准备界面相关文件

[root@localhost ~]# cp /mnt/isolinux/{boot.msg,splash.jpg,vesamenu.c32} /var/lib/tftpboot/

3.准备bootloader

[root@localhost ~]# yum install syslinux -y [root@localhost ~]# ls /usr/share/syslinux/pxelinux.0 [root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

4.准备配置文件

[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg [root@localhost ~]# cp /mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

五、修改dhcp配置文件,实现告知客户端tftp的地址信息

option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org; default-lease-time 600; max-lease-time 7200; log-facility local7; subnet 192.168.100.0 netmask 255.255.255.0 {range 192.168.100.200 192.168.100.220;option routers 192.168.100.85;option domain-name-servers 8.8.8.8;next-server 192.168.100.85;filename "pxelinux.0";}

六、重启所有服务

[root@localhost ~]# service xinetd restart [root@localhost ~]# service dhcpd restart

七、准备安装树

[root@localhost ~]# yum install httpd -y [root@localhost ~]# mkdir /var/www/html/installtree/ [root@localhost ~]# mount /dev/cdrom /var/www/html/installtree/ [root@localhost ~]# service httpd restart

通过浏览器测试一下,如下图显示说明安装树配置成功

八、准备kickstart文件

[root@localhost ~]# cd /var/www/html [root@localhost ~]# mkdir ks

将ks1.cfg文件放在/var/www/html/ks 下

[root@localhost html]# chmod -R +r ks [root@localhost html]# chmod +x ks

九、修改/var/lib/tftpboot/pxelinux.cfg/default文件

[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default


十、启动一个虚拟机,来测试pxe是否正常

总结

以上是生活随笔为你收集整理的基于pxe+dhcp+ks实现自动安装系统的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。