您的位置:首页 > 理论基础 > 计算机网络

PXE+kicstart+Vsftpd/NFS/HTTP无人值守批量网络安装

2015-06-13 04:49 851 查看







一、DHCP-Server上的配置
1)设置网卡eth0的IP地址
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:a3:1e:a3
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.10.2
GATEWAY=192.168.10.2
TYPE=Etherne
2)安装DHCP-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 dhcp-3.0.5-23.el5.i386.rpm
3)配置DHCP-Server
[root@localhost ~]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
[root@localhost ~]# vim /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
default-lease-time 21600;
max-lease-time 43200;
option subnet-mask 255.255.255.0;
filename "pxelinux.0"; //PXE引导文件
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
range dynamic-bootp 192.168.10.128 192.168.10.254;
next-server 192.168.10.1; //TFTP服务器IP地址
}
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;
}
4)启动DHCP-Server服务
[root@localhost ~]# service dhcpd start
启动dhcpd: [确定]
[root@localhost ~]# chkconfigdhcpd on
二、DHCP-Relay服务器上的配置
1)设置eth0 eth1 eth2 eth3网卡IP地址
[root@localhost ~]# ipaddr
1: lo: mtu 16436 qdiscnoqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdiscpfifo_fastqlen 1000
link/ether 00:0c:29:b5:15:28 brdff:ff:ff:ff:ff:ff
inet 192.168.10.1/24 brd 192.168.10.255 scope global eth0
inet6 fe80::20c:29ff:feb5:1528/64 scope link
valid_lft forever preferred_lft forever
3: eth1: mtu 1500 qdiscpfifo_fastqlen 1000
link/ether 00:0c:29:b5:15:32 brdff:ff:ff:ff:ff:ff
inet 192.168.1.1/24 brd 192.168.1.255 scope global eth1
inet6 fe80::20c:29ff:feb5:1532/64 scope link
valid_lft forever preferred_lft forever
4: eth2: mtu 1500 qdiscpfifo_fastqlen 1000
link/ether 00:0c:29:b5:15:3c brdff:ff:ff:ff:ff:ff
inet 192.168.2.1/24 brd 192.168.2.255 scope global eth2
inet6 fe80::20c:29ff:feb5:153c/64 scope link
valid_lft forever preferred_lft forever
5: eth3: mtu 1500 qdiscpfifo_fastqlen 1000
link/ether 00:0c:29:b5:15:46 brdff:ff:ff:ff:ff:ff
inet 192.168.3.1/24 brd 192.168.3.255 scope global eth3
inet6 fe80::20c:29ff:feb5:1546/64 scope link
valid_lft forever preferred_lft forever
6: sit0: mtu 1480 qdiscnoop
link/sit 0.0.0.0 brd 0.0.0.0
2)安装DHCP-Relay服务
[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 dhcp-3.0.5-23.el5.i386.rpm
3)修改DHCP-Relay配置文件
[root@localhost ~]# vim /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 1 //开启转发功能
[root@localhost ~]# sysctl –p //文件生效
[root@localhost ~]# vim /etc/sysconfig/dhcrelay
# Command line options here
INTERFACES="eth0 eth1 eth2 eth3" //监听网卡
DHCPSERVERS="192.168.10.2"//DHCP地址
4)启动DHCP-Server服务
[root@localhost ~]# service dhcrelay start
启动dhcrelay: [确定]
[root@localhost ~]# chkconfigdhcrelay on
[root@localhost ~]# dhcrelay 192.168.10.2
三、TFTP服务器上的配置
1)安装TFTP服务器
[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.49-2.i386.rpm
3)配置TFTP
[root@localhost ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/ //PXE引导文件
[root@localhost ~]# cp -rpf /media/isolinux/* /tftpboot/ //系统引导文件
[root@localhost ~]# mkdir /tftpboot/pxelinux.cfg
[root@localhost ~]# cp /tftpboot/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@localhost ~]# chmodu+w /tftpboot/pxelinux.cfg/default //系统网卡文件
[root@localhost ~]# vim /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 6
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.10.1/ks.cfg//系统交互式文件
[root@localhost ~]# gethostip 192.168.1.0
192.168.1.0 192.168.1.0 C0A80100 //16进制网卡名
[root@localhost ~]# gethostip 192.168.2.0
192.168.2.0 192.168.2.0 C0A80200
[root@localhost ~]# gethostip 192.168.3.0
192.168.3.0 192.168.3.0 C0A80300
[root@localhost ~]# cd /tftpboot/pxelinux.cfg/
[root@localhostpxelinux.cfg]# cp -p default C0A801
[root@localhostpxelinux.cfg]# cp -p default C0A802
[root@localhostpxelinux.cfg]# cp -p default C0A803
[root@localhostpxelinux.cfg]# vim 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.imgks=ftp://192.168.1.1/ks1.cfg
[root@localhostpxelinux.cfg]# vim 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.imgks=ftp://192.168.1.1/ks2.cfg
[root@localhostpxelinux.cfg]# vim 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.imgks=ftp://192.168.1.1/ks3.cfg
[root@localhostpxelinux.cfg]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no //YES改为NO
per_source = 11
cps = 100 2
flags = IPv4
4)启动TFTP服务器
[root@localhostpxelinux.cfg]# service xinetd restart
停止xinetd: [确定]
启动xinetd: [确定]
[root@localhostpxelinux.cfg]# chkconfigxinetd on
四、VSFTP服务器上的配置
1)安装vsftp服务
[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 vsftpd-2.0.5-16.el5_4.1.i386.rpm
4)配置vstfp
[root@localhost ~]# cp -rpf /media/* /var/ftp/pub/
[root@localhost ~]# chmod 777 /var/ftp/pub/
5)配置kickstart
[root@localhost ftp]# cp /root/anaconda-ks.cfg /var/ftp/ks.cfg
[root@localhost ftp]# cd /var/ftp/
[root@localhost ftp]# vim ks.cfg
# Kickstart file automatically generated by anaconda.
install
url --url=ftp://192.168.10.1/pub
key --skip
lang zh_CN.UTF-8
…..........(省略)
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.2 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.2
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1024 --grow --maxsize=2048
reboot
%packages
@admin-tools
@base
@chinese-support
@core
@development-libs
[root@localhost ftp]# cpks.cfg ks1.cfg
[root@localhost ftp]# cpks.cfg ks2.cfg
[root@localhost ftp]# cpks.cfg ks3.cfg
[root@localhost ftp]# vim ks1.cfg
# Kickstart file automatically generated by anaconda.
install
url --url=ftp://192.168.10.1/pub
key --skip
lang zh_CN.UTF-8
…..........(省略)
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.2 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.2
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1024 --grow --maxsize=2048
reboot
%packages
@admin-tools
@base
@chinese-support
@core
@development-libs
.....................(省略)
mesa-libGLU-devel
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
%post
for nm in user1; do
useradd $nm
echo "123" |passwd --stdin $nm
done
[root@localhost ftp]# vim ks2.cfg
# Kickstart file automatically generated by anaconda.
install
url --url=ftp://192.168.10.1/pub
key --skip
lang zh_CN.UTF-8
…..........(省略)
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.2 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.2
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1024 --grow --maxsize=2048
reboot
%packages
@admin-tools
@base
@chinese-support
@core
@development-libs
.....................(省略)
mesa-libGLU-devel
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
%post
for nm in user2; do
useradd $nm
echo "123" |passwd --stdin $nm
done
[root@localhost ftp]# vim ks3.cfg
# Kickstart file automatically generated by anaconda.
install
url --url=ftp://192.168.10.1/pub
key --skip
lang zh_CN.UTF-8
…..........(省略)
# not guaranteed to work
clearpart --all --initlabel
part /boot --fstype ext3 --size=100 --ondisk=sda
part pv.2 --size=0 --grow --ondisk=sda
volgroup VolGroup00 --pesize=32768 pv.2
logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=1024 --grow --maxsize=2048
reboot
%packages
@admin-tools
@base
@chinese-support
@core
@development-libs
.....................(省略)
mesa-libGLU-devel
xorg-x11-utils
xorg-x11-server-Xnest
xorg-x11-server-Xvfb
%post
for nm in user3; do
useradd $nm
echo "123" |passwd --stdin $nm
done

五客户端测试
1)获得IP,启动文件,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>,up,lower_up>



2)安装进行中,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>,up,lower_up>


,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>,multicast,up,lower_up>,up,lower_up>
本文出自 “江湖笑笑生” 博客,请务必保留此出处http://hashlinux.blog.51cto.com/9647696/1661473
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: