一、DHCP可自动分配的入网参数:
--IP地址、子网掩码、广播地址
--默认网关
--DNS服务器地址
二、DHCP相关概念:
---作用域:分配给客户机的ip地址所在网段
---地址池:用来动态分配的ip地址的范围
---排除范围:不用来动态分配的ip地址
---保留地址:用来动态分配,但保留给某个固定的客户机
---租期(租约时间):允许客户机租用ip地址时间期限、单位为秒。
Dhcp主配置文件:/etc/dhcpd.conf
监听端口:服务端UDP67,客户端UDP68
三、配置DHCP服务器:
前提条件:
1.实验环境准备(机器设置,网络设置)
2.DHCP服务器需要固定IP
[root@localhost ~]# cat/etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:0c:29:5d:ed:a4
IPADDR=192.168.50.253
NETMASK=255.255.255.0
[root@localhost ~]# service network restart
[root@localhost ~]# chkconfig network on/设置network服务开机自启
[root@localhost ~]# ifconfig eth0
1、安装dhcp软件包
[root@localhost ~]# rpm -q dhcp/查看是否安装
package dhcp is not installed
放入5.9iso
[root@localhost ~]# cd /misc/cd/Server/
[root@localhost Server]# ls dhcp*
dhcp-3.0.5-31.el5_8.1.x86_64.rpm
dhcp-devel-3.0.5-31.el5_8.1.i386.rpm
dhcp-devel-3.0.5-31.el5_8.1.x86_64.rpm
dhcpv6-1.0.10-20.el5.x86_64.rpm
dhcpv6-client-1.0.10-20.el5.x86_64.rpm
[root@localhost Server]# rpm -ivhdhcp-3.0.5-31.el5_8.1.x86_64.rpm /安装
warning: dhcp-3.0.5-31.el5_8.1.x86_64.rpm: Header V3 DSA signature:NOKEY, key ID 37017186
Preparing...############################### [100%]
1:dhcp############################### [100%]
2、DHCP服务器的配置
[root@localhost ~]# cat /etc/dhcpd.conf/修改配置文件
ddns-update-style interim;
subnet 192.168.50.0 netmask 255.255.255.0 {
option routers192.168.50.254; /网关
optionsubnet-mask255.255.255.0;
optiondomain-name"tarena.com";
optiondomain-name-servers202.106.0.20;/DNS
range dynamic-bootp192.168.50.10 192.168.50.20;/地址池
default-lease-time21600;/默认租期
max-lease-time 43200;/最大租期
host ns {
hardwareethernet 12:34:56:78:AB:CD;
fixed-address207.175.42.254;/给固定客户机分地址
}
}
3、启动服务
[root@localhost ~]# rpm -ql dhcp | grepinit.d
/etc/rc.d/init.d/dhcpd
/etc/rc.d/init.d/dhcrelay
[root@localhost ~]# /etc/init.d/dhcpd status
dhcpd 已停
[root@localhost ~]# /etc/init.d/dhcpd start或:service dhcpd start
启动 dhcpd:[确定]
[root@localhost ~]# chkconfig --list dhcpd/查看自启状态
dhcpd0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭
[root@localhost ~]# chkconfig dhcpd on /设置开机自启
本文出自 “路过我青春” 博客,转载请与作者联系!