角色
IP地址
DHCP-Server
RHEL5)
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: [确定]
四、配置vsftpd服务器
1)安装vsftpd服务器
[root@localhost ~]# rpm -ivh /media/Server/vsftpd-2.0.5-12.el5.i386.rpm
2)配置vsftpd服务器
[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf
27 anon_upload_enable=YES
28 #
29 # Uncomment this if you want the anonymous FTP user to be able to create
30 # new directories.
31 anon_mkdir_write_enable=YES
[root@localhost ~]# chmod 777 /var/ftp/pub/
[root@localhost ~]# service vsftpd start
为 vsftpd 启动 vsftpd: [确定]
[root@localhost ~]# chkconfig vsftpd on
[root@localhost ~]# cp -rpf /media/* /var/ftp/pub/
[root@localhost ~]# cp /root/anaconda-ks.cfg /var/ftp/ks.cfg
3)修改ks.cfg文件
[root@localhost ~]# vi /var/ftp/ks.cfg
1 # Kickstart file automatically generated by anaconda.
2
3 install
4 url --url=ftp://192.168.0.1/pub #[FTP服务器模式]
(url --url =http://192.168.0.1/pub #[web服务器模式]
url --server –dir=/var/ftp/pub #[NFS服务器模式])
key –skip
5 clearpart --all --initlabel
7 part /boot --fstype ext3 --size=100 --ondisk=sda
8 part pv.2 --size=0 --grow --ondisk=sda
9 volgroup VolGroup00 --pesize=32768 pv.2
10 logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
11 logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512
12 lang zh_CN.UTF-8
13 keyboard us
……………………
32 reboot
33 %packages
……………………
%post
for in tom jim green; do
useradd $i
echo “123456” |passwd –stdin $i
done
[root@localhost ~]# vi /var/ftp/ks1.cfg
1 # Kickstart file automatically generated by anaconda.
2
3 install
4 url --url=ftp://192.168.0.1/pub #[FTP服务器模式]
(url --url =http://192.168.0.1/pub #[web服务器模式]
url --server –dir=/var/ftp/pub #[NFS服务器模式])
key –skip
5 clearpart --all --initlabel
7 part /boot --fstype ext3 --size=100 --ondisk=sda
8 part pv.2 --size=0 --grow --ondisk=sda
9 volgroup VolGroup00 --pesize=32768 pv.2
10 logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
11 logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512
12 lang zh_CN.UTF-8
13 keyboard us
……………………
32 reboot
33 %packages
……………………
%post
for in zhangsan lisi wangwu; do
useradd $i
echo “123456” |passwd –stdin $i
done
[root@localhost ~]# vi /var/ftp/ks2.cfg
1 # Kickstart file automatically generated by anaconda.
2
3 install
4 url --url=ftp://192.168.0.1/pub #[FTP服务器模式]
(url --url =http://192.168.0.1/pub #[web服务器模式]
url --server –dir=/var/ftp/pub #[NFS服务器模式])
key –skip
5 clearpart --all --initlabel
7 part /boot --fstype ext3 --size=100 --ondisk=sda
8 part pv.2 --size=0 --grow --ondisk=sda
9 volgroup VolGroup00 --pesize=32768 pv.2
10 logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
11 logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512
12 lang zh_CN.UTF-8
13 keyboard us
……………………
32 reboot
33 %packages
8
10. 17
%post
for in accp benet ; do
useradd $i
echo “123456” |passwd –stdin $i
done
[root@localhost ~]# vi /var/ftp/ks3.cfg
1 # Kickstart file automatically generated by anaconda.
2
3 install
4 url --url=ftp://192.168.0.1/pub #[FTP服务器模式]
(url --url =http://192.168.0.1/pub #[web服务器模式]
url --server –dir=/var/ftp/pub #[NFS服务器模式])
key –skip
5 clearpart --all --initlabel
7 part /boot --fstype ext3 --size=100 --ondisk=sda
8 part pv.2 --size=0 --grow --ondisk=sda
9 volgroup VolGroup00 --pesize=32768 pv.2
10 logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
11 logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=256 --grow --maxsize=512
12 lang zh_CN.UTF-8
13 keyboard us
……………………
32 reboot
33 %packages
……………………
%post
for in obama wjf pujing; do
useradd $i
echo “123456” |passwd –stdin $i
done
4)测试