DHCP服务
注:##后为自己敲写命令
DHCP服务(需要dhcp命令):负责ip,掩码,网关地址,DNS地址等自动分发的软件服务
/usr/sbin/dhcpd或/usr/sbin/dhcrelay(中继命令):执行程序
/etc/init.d/dhcpd或/etc/init.d/dhcrelay:服务脚本
/etc/sysconfig/dhcpd(一般不用):执行参数配置
/etc/syusconfig/dhcrelay:DHCP中继配置
DHCP服务搭建
配置文件: /etc/dhcp
## ls /etc/dhcp
dhclient.d
yum安装dhcp后,在/etc/dhcp配置文件中会默认出现2个模板
## yum -y install dhcp
## ls /etc/dhcp
dhclient.d dhcpd6.conf dhcpd.conf
vim 打开 /etc/dhcp/dhcpd.conf ,配置文件里面什么都没有,提示需要在 /usr/share/doc/dhcp*/dhcpd.conf.sample 里找模板文件
## DHCP Server Configuration file.
## see /usr/share/doc/dhcp*/dhcpd.conf.sample
## see 'man 5 dhcpd.conf'
直接将/usr/share/doc/dhcp*/dhcp.conf.sample文件复制到dhcp配置文件中
##cp /usr/share/doc/shcp*/dhcp.conf.sample /etc/dhcp
## ls
dhclient.d dhcpd6.conf dhcpd.conf dhcpd.conf.sample
因为模板里面有太多注释所以需要自己修饰一下。去掉所有注释并且备份文件
## egrep -v "#" /etc/dhcp/dhcpd.conf.sample > /etc/dhcp/dhcpd.conf.bak
## ls
dhclient.d dhcpd6.conf dhcpd.conf dhcpd.conf.bak dhcp.conf.sample
##vim dhcpd.conf.bak
把备份文件里的内容从定向到DHCP主配置文件里
## cat /etc/dhcp/dhcp.conf.bak > /etc/dhcp/dhcpd.conf
## cat /etc/dhcp/dhcpd.conf
##看到的是修饰好的配置文件
配置DHCP住配置文件
##vim dhcp.conf
##双引号中起名字
option domain-name "要起的名字"
##DNS服务器的IP地址
option domain-name-servers 192.168.200.2;
##最小租约时间
default-lease-time 600;
##最大租约时间
max-lease-time 800;
##日志路径
log-facility local17;
subnet 192.120.200.0 在哪个网段呢
range 192.120.200.100 192.120.200.200; ip范围
option routers 192.120.200.2; 网关
##host主机名(随便起)
##hardware ethernet代表物理(MAX)地址
##fixed-address代表强制给主机分配IP
host www.yunjisuan.com { hardware ethernet 08:00:07:26:c0:a5; fixed-address 192.168.200.211;}
???host fantasia {
hardware ethernet 08:00:07:26:c0:a5;
fixed-address fantasia.fugue.com;
}