# option definitions common to all supported networks...
option domain-name "example.org";域名,改为主机名 dhcp
option domain-name-servers ns1.example.org, ns2.example.org; 名称服务器地址 设为DNS服务器地址 202.101.172.35;
default-lease-time 600; 默认租用时长可以根据需要做设定单位是s(秒)
max-lease-time 7200; 最大租用时长
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7; 日志设施
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
# This is a very basic subnet declaration.
所在的网络 所在的掩码
subnet 192.168.20.0 netmask 255.255.255.0 {
range 192.168.20.150 192.168.20.180;动态配置ip的范围,中间使用空格隔开
option routers 192.168.20.254; 指定做转发的地址(路由器的地址)【此处用网关】
}
。。。。
DHCP服务启动成功
[iyunv@dhcp ~]# ss -ulnp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
UNCONN 0 0 *:67 *:* users:(("dhcpd",2261,7))
UNCONN 0 0 *:68 *:* users:(("dhclient",1055,5))
工作在udp的67端口
2. 安装和部署tftp服务
查看与tftp相关的包
[iyunv@tftp ~]# yum list all *tftp*
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* test: mirrors.aliyun.com
* updates: centos.ustc.edu.cn
Available Packages
syslinux-tftpboot.noarch
4.04-3.el6 base
tftp.x86_64 0.49-7.el6 base
tftp-server.x86_64
0.49-7.el6 base
[iyunv@tftp ~]# yum install tftp-server 安装tftp-server
查看安装后生成了哪些文件
[iyunv@tftp ~]# rpm -ql tftp-server
/etc/xinetd.d/tftp
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-0.49
/usr/share/doc/tftp-server-0.49/CHANGES
/usr/share/doc/tftp-server-0.49/README
/usr/share/doc/tftp-server-0.49/README.security
/usr/share/doc/tftp-server-0.49/README.security.tftpboot
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot tftp服务器默认放置文件的目录
xinetd based services: 基于xinetd的服务
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
rsync: off
tcpmux-server: off
tftp: off
time-dgram: off
time-stream: off
启动xinetd,和上面显示的3,4,5级别on(此时的生效级别是要重启后才会在在对应的级别启动)没关系,需要手动启动xinetd
[iyunv@tftp ~]# service xinetd start
Starting xinetd: [ OK ]
启动基于xinetd的服务
方法1:
xinetd based services:
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
rsync: off
tcpmux-server: off
tftp: on 已经启动了
time-dgram: off
time-stream: off
获取内核,根文件系统镜像,bootloader等文件,我们可以通过挂载centos光盘来实现,也可以直接到官网下载,此处以光盘获取为例。
安装syslinux,得到pxelinux.0,把pxelinux.0复制到/var/lib/tftpboot目录下
[iyunv@tftp cdrom]# yum install syslinux
[iyunv@tftp cdrom]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
安装nfs在Centos 6上需要装rpcbind和nfs-utils这两个软件,查看是否安装了
[iyunv@nfs ~]# rpm -qi rpcbind
package rpcbind is not installed
[iyunv@nfs ~]# rpm -qi nfs-utils
package nfs-utils is not installed
两个包都没安装,用yum安装
[iyunv@nfs ~]# yum install rpcbind nfs-utils
启动rpcbind和nfs
[iyunv@nfs ~]# service rpcbind start
Starting rpcbind: [ OK ]
[iyunv@nfs ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
nfs服务的主要配置文件/etc/exports
[iyunv@nfs ~]# vim /etc/exports
[iyunv@nfs ~]# cat /etc/exports
/var/install 192.168.20.0/24(ro)
格式:[共享目录] [主机(权限)]
主机的设置:
可以使用完整的ip或者是网络号,比如192.168.20.89或192.168.20.0/24,或192.168.20.0/255.255.255.0.
可以使用主机名,前提是这个主机名必须要在/etc/hosts内,或可使用DNS找到该主机名。
ro是只读的,所有192.168.20.0网段内的主机都可以共享/var/install目录,但是是只读的方式。
-e 显示某台主机的/etc/exports所共享的目录数据
[iyunv@nfs ~]# showmount -e localhost
Export list for localhost:
没有显示,修改配置文件后需要重读配置文件才能生效,重启nfs。
[iyunv@nfs ~]# service nfs restart
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down RPC idmapd: [ OK ]
Starting NFS services: exportfs: Failed to stat /var/install: No such file or directory [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
查看共享的目录数据
[iyunv@nfs ~]# showmount -e localhost
Export list for localhost:
/var/install 192.168.20.0/24
新建/var/install目录