PXE无人值守批量装机

DHCP服务器

 

eth0:192.168.0.2/24

gw:192.168.0.1

 

 

 

DHCP-Relay

TFTP-Server

Vsftp-Server

(RHEL5)

 

DHCP中继服务器

TFTP服务器

Vsftp服务器

 

eth0:192.168.0.1/24

eth1:192.168.1.1/24

eth2:192.168.2.1/24

        eth3:192.168.3.1/24

 

实验步骤:

一、DHCP服务器端配置

1设置网卡eth0的IP地址

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]

DEVICE=eth0

BOOTPROTO=none

ONBOOT=yes

HWADDR=00:0c:29:7c:1a:c4

NETMASK=255.255.255.0

IPADDR=192.168.0.2

GATEWAY=192.168.0.1

TYPE=Ethernet

2安装DHCP服务端

[root@localhost ~]# mount /dev/cdrom /media/

[root@localhost ~]# cd /media/Server/

[root@localhost Server]# rpm -ivh dhcp-3.0.5-18.el5.i386.rpm

3配置DHCP服务端

 [root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf

[root@localhost ~]# vi /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

option subnet-mask 255.255.255.0;

option domain-name-servers 192.168.1.1;

option time-offset -18000; # Eastern Standard Time

default-lease-time 21600;

max-lease-time 43200;

filename "pxelinux.0";

subnet 192.168.0.0 netmask 255.255.255.0 {

option routers 192.168.0.1;

range dynamic-bootp 192.168.0.128 192.168.0.254;

next-server 192.168.0.1;

}

subnet 192.168.1.0 netmask 255.255.255.0 {

option routers 192.168.1.1;

range dynamic-bootp 192.168.1.128 192.168.1.254;

next-server 192.168.1.1;

}

subnet 192.168.2.0 netmask 255.255.255.0 {

option routers 192.168.2.1;

range dynamic-bootp 192.168.2.128 192.168.2.254;

next-server 192.168.2.1;

}

subnet 192.168.3.0 netmask 255.255.255.0 {

option routers 192.168.3.1;

range dynamic-bootp 192.168.3.128 192.168.3.254;

next-server 192.168.3.1;

}

4) 启动DHCP服务

[root@localhost ~]# service dhcpd start

启动 dhcpd: [确定]

[root@localhost ~]# chkconfig dhcpd on

二、DHCP客户服务器上的配置

1)设置网卡eth0、eth1、eth2、eth3的IP地址

[root@localhost ~]# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue

inet 127.0.0.1/8 scope host lo

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000

inet 192.168.0.1/24 brd 192.168.0.255 scope global eth0

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000

inet 192.168.1.1/24 brd 192.168.1.255 scope global eth1

4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000

inet 192.168.2.1/24 brd 192.168.2.255 scope global eth2

5: eth3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000

inet 192.168.3.1/24 brd 192.168.3.255 scope global eth3

2)安装DHCP客户端服务器

[root@localhost ~]# mount /dev/cdrom /media/

[root@localhost ~]# cd /media/Server/

[root@localhost Server]# rpm -ivh dhcp-3.0.5-18.el5.i386.rpm

3)配置DHCP客户端服务器

[root@localhost ~]# vi /etc/sysconfig/dhcrelay

# Command line options here

INTERFACES="eth0 eth1 eth2 eth3"

DHCPSERVERS="192.168.0.2"

4)启动DHCP客户端服务器

[root@localhost ~]# service dhcrelay start

启动 dhcrelay: [确定]

[root@localhost ~]# chkconfig dhcrelay on

[root@localhost ~]# dhcrelay 192.168.0.2

三、TFTP-Server上的配置

1)安装TFTP-Server服务器

[root@localhost ~]# mount /dev/cdrom /media/

mount: block device /dev/cdrom is write-protected, mounting read-only

[root@localhost ~]# cd /media/Server/

[root@localhost Server]# rpm -ivh tftp-server-0.42-3.1.i386.rpm

2)对TFTP-Server的操作

[root@localhost ~]# rpm -ql syslinux |grep "pxe"

/usr/lib/syslinux/pxelinux.0

/usr/share/doc/syslinux-3.11/pxelinux.doc

[root@localhost ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

[root@localhost ~]# mkdir -p /tftpboot/pxelinux.cfg/

[root@localhost ~]# cp -rp /media/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default

[root@localhost ~]# chmod u+w /tftpboot/pxelinux.cfg/default

[root@localhost ~]# cp -rpf /media/isolinux/* /tftpboot/

3)编辑/tftpboot/pxelinux.cfg/default文件

[root@localhost ~]# vi /tftpboot/pxelinux.cfg/default

default linux

prompt 1

timeout 1

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

kernel vmlinuz

append initrd=initrd.img ks=ftp://192.168.0.1/ks.cfg

[root@localhost pxelinux.cfg]# gethostip 192.168.1.0

192.168.1.0 192.168.1.0 C0A801

[root@localhost pxelinux.cfg]# gethostip 192.168.2.0

192.168.2.0 192.168.2.0 C0A802

[root@localhost pxelinux.cfg]# gethostip 192.168.3.0

192.168.3.0 192.168.3.0 C0A803

[root@localhost pxelinux.cfg]# cat default > C0A801

[root@localhost pxelinux.cfg]# cat default > C0A802

[root@localhost pxelinux.cfg]# cat default > C0A803

[root@localhost pxelinux.cfg]# vi C0A801

default linux

prompt 1

timeout 1

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

kernel vmlinuz

append initrd=initrd.img ks=ftp://192.168.0.1/ks1.cfg

[root@localhost pxelinux.cfg]# vi C0A802

default linux

prompt 1

timeout 60

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

kernel vmlinuz

append initrd=initrd.img ks=ftp://192.168.0.1/ks2.cfg

[root@localhost pxelinux.cfg]# vi C0A803

default linux

prompt 1

timeout 600

display boot.msg

F1 boot.msg

F2 options.msg

F3 general.msg

F4 param.msg

F5 rescue.msg

label linux

kernel vmlinuz

append initrd=initrd.img ks=ftp://192.168.0.1/ks3.cfg

[root@localhost pxelinux.cfg]# ls

C0A801 C0A802 C0A803 default

4) 启动TFTP-Server服务器

[root@localhost ~]# vi /etc/xinetd.d/tftp

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /tftpboot

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}

[root@localhost ~]# service xinetd restart

停止 xinetd: [确定]

启动 xinetd: [确定]

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

转载注明出处:http://www.heiqu.com/bf967905733d55d13d7844d53ff4b35f.html