centos網絡安裝

一、 介紹
簡單原理介紹:無光軟驅服務器通過PXE網卡啓動,從dhcp服務器獲取IP 通過tftp 下載pxelinux.0文件找到pxelinux.cfg裏的配置文件,按配置文件找着vmlinuz引導centos進入安裝界面,之後選擇NFS方式安裝系統。
另: 如需要實現全自動安裝 要安裝 Kickstart 軟件包並配置。本文並不討論
二、環境說明
本文測試環境及用到的軟件
Server: centos 5.2 dhcp nfs tftp ip:192.168.1.251 (此IP只需要與服務器網卡相連,不管是什麼都可以)
三、安裝配置過程及基本講解:
安裝相應的軟件:yum –y install dhcp* nfs* tftp*
1、 配置tftp more /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.
# trad: liuyu
# blog: liuyu.blog.51cto.com
# bbs: www.britepic.org
service tftp
{
disable = no #默認是yes 改爲no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -u nobody -s /tftpboot #添加nobody可以訪問
per_source = 11
cps = 100 2
flags = IPv4
}
複製代碼重啓xinetd服務: /etc/init.d/xinetd restart
查看tftp 是否啓動:# chkconfig --list |grep tftp
tftp: on
2、 配置nfs
mount /iso/CentOS-5.2-i386-bin-1of6.iso /mnt -o loop #我是掛載的鏡像文件,你們可以掛載光驅
echo "/tftpboot *(ro,sync)" > /etc/exports
echo "/mnt *(ro,sync)" > /etc/exports #此二步設置共享的目錄
exportfs –a #使配置生效
/etc/init.d/portmap start &&/etc/init.d/nfs start #重啓服務
Showmount –e localhost #看查共享的目錄
Export list for localhost:
/mnt *
/tftpboot *
3、配置dhcp
直接copy我的配置
# more /etc/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
# trad: liuyu
# blog: liuyu.blog.51cto.com
# bbs: www.britepic.org
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
subnet 192.168.1.0 netmask 255.255.255.0 {
option routers 192.168.1.251;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.251; #本地IP
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.1.12 192.168.1.254; #要分區的IP
default-lease-time 21600;
max-lease-time 43200;
# Group the PXE bootable hosts together
# PXE-specific configuration directives...
next-server 192.168.1.251;
filename "/pxelinux.0"; #方便查找配置文件
}
複製代碼/etc/init.d/dhcpd start 啓動服務
4、 配置pxe所需要的文件 Mkdir /tftpboot/pxelinux.cfg
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
cp /mnt/isolinux/vmlinuz /tftpboot/
cp /mnt/isolinux/initrd.img /tftpboot/
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
複製代碼四、測試
啓動服務器,一般是按F12選擇進入PXE網絡啓動。這時就會自動獲取IP並進入
Boot: 界面。按linux text 進入。之後選擇NFS安裝系統。
五、配置文件詳解
dhcpd.conf配置的有關說明:
parameters(參數):
ddns-update-style 配置DHCP-DNS互動更新模式
default-lease-time 指定缺省租賃時間的長度,單位是秒
max-lease-time 指定最大租賃時間長度,單位是秒
hardware 指定網卡接口類型和MAC地址
server-name 通知DHCP客戶服務器名稱
get-lease-hostnames flag 檢查客戶端使用的IP地址
fixed-address ip 分配給客戶端一個固定的地址
authritative 拒絕不正確的IP地址的要求
declarations(聲明):
shared-network 用來告知是否一些子網絡分享相同網絡
subnet 描述一個IP地址是否屬於該子網
range 起始IP 終止IP 提供動態分配IP 的範圍
host 主機名稱 參考特別的主機
group 爲一組參數提供聲明
allow unknown-clients或deny unknown-client 是否動態分配IP給未知的使用者
allow bootp或deny bootp 是否響應激活查詢
allow booting或deny booting 是否響應使用者查詢
filename 開始啓動文件的名稱,應用於無盤工作站
next-server 設置服務器從引導文件中裝如主機名,應用於無盤工作站
option(選項):
subnet-mask 爲客戶端設定子網掩碼
domain-name 爲客戶端指明DNS名字
domain-name-servers 爲客戶端指明DNS服務器IP地址
host-name 爲客戶端指定主機名稱
routers 爲客戶端設定默認網關
broadcast-address 爲客戶端設定廣播地址
ntp-server 爲客戶端設定網絡時間服務器IP地址
time-offset 爲客戶端設定和格林威治時間的偏移時間,單位是秒
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章