00 - PXE | 环境准备

00 - PXE | 环境准备

1. TFTP服务搭建

安装环境Centos7.3

1.1 安装

# yum install xinetd  
# yum install tftp
# yum install tftp-server

如果不能上网,可以直接安装提供的rpm包:

sudo rpm -ivh xinetd-2.3.14-18.fc9.i386.rpm
sudo rpm -ivh tftp-0.48-3.fc9.i386.rpm
sudo rpm -ivhtftp-server-0.48-3.fc9.i386.rpm

1.2 配置

查看哪个分区空间较大,设置为tftp目录df -h

# mkdir /data/tftpboot
# chmod  777 /data/tftpboot

vim /etc/xinetd.d/tftp

service tftp
{
       socket_type             = dgram
       protocol                = udp
       wait                    = yes
       user                    = root
       server                  = /usr/sbin/in.tftpd
       server_args             = -s /data/tftpboot -c # 修改目录位置
       disable                 = no # 修改为no
       per_source              = 11
       cps                     = 100 2
       flags                   = IPv4
}

修改/etc/sysconfig/selinux文件,关闭selinux
SELINUX=disabled
systemctl restart xinetd
查看tftp服务是否开启:
netstat -a | grep tftp
显示结果为 udp 0 0 *:tftp : 表示服务已经开启,tftp配置成功

加入iptables

vi /etc/sysconfig/iptables
加一行
-A INPUT -p udp --dport 69 -j ACCEPT

保存

重启iptables

service iptables restart

chkconfig tftp  on
chkconfig xinetd  on
service xinetd  restart
service tftp restart

2. 安装HTTP服务

yum install httpd

配置文件所在位置/etc/httpd/conf/httpd.conf
修改如下参数:

DocumentRoot "/data" #设定主目录
<Directory />
    AllowOverride none
    Require all granted # deny修改为granted
</Directory>

其他限制条件可自行搜索进行限制。

systemctl restart httpd即可启动。
ss -tnl 可用于查看监听端口

3. 安装DHCP服务

yum install dhcp
配置文件位置/etc/dhcpd/dhcpd.conf

ddns-update-style interim;
ignore client-updates;
allow unknown-clients;
allow bootp;
allow booting;
ping-check true;
default-lease-time 1800;
max-lease-time 1800;
subnet 10.24.10.0 netmask 255.255.255.128 {
    option routers 10.24.10.126;
    option subnet-mask 255.255.255.128;
    next-server 10.24.16.151;
    range dynamic-bootp 10.24.10.41 10.24.10.80;
    filename "/pxelinux.0";
}
shared-network 10.25.18.128 {
    subnet 10.25.18.128 netmask 255.255.255.128 {
        option routers 10.25.18.254;
        option subnet-mask 255.255.255.128;
        next-server 172.18.5.73;
        range  dynamic-bootp 10.25.18.170 10.25.18.210;
        filename "/pxelinux.0";
    }
    host server_SN {
        next-server 172.18.5.73;
        hardware ethernet server_ILO_MAC;
        fixed-address 10.25.18.150;
        filename "/pxelinux.0";
    }

监听端口/etc/sysconfig/dhcpd修改里面的DHCPDARGS=参数。假如需要监听多个端口,则建议不要填写。

DHCP服务一定要把本机网口所在的网段写入到dhcp.conf中,否则服务起不来

posted @ 2019-08-22 08:48  人生何处是归途  阅读(199)  评论(0编辑  收藏  举报