linux dhcp
dhcp 服务一、要求服务器地址:192.168.2.2/24 网关:192.168.2.1分配192.168.1.2-192.168.1.60/24 网关为192.168.1.1 新建保留192.1
dhcp 服务
一、要求
服务器地址:192.168.2.2/24 网关:192.168.2.1
分配192.168.1.2-192.168.1.60/24 网关为192.168.1.1 新建保留192.168.1.3分配给AA:BB:CC:DD:EE:FF
二、操作步骤:
1. yum –y install dhcp*
2. cat /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample > /etc/dhcpd.conf
3. 修改/etc/dhcpd.conf 文件(注意:dhcp 首先要做与本机同网段的作用域)


, 红色字体是需要修改部分
#ddns-update-style interim; #ignore client-updates;
subnet 192.168.2.0 netmask 255.255.255.0 { ping-check true; ping-timeout 1; # #
//分配之前ICMP 检测,1S 后无响应则分配
# --- default gateway
option routers option subnet-mask option nis-domain option domain-name
192.168.2.1; 255.255.255.0; "domain.org"; "domain.org";
//dns域名 //dns地址
192.168.1.1;
option domain-name-servers option time-offset option ntp-servers
-18000; # Eastern Standard Time 192.168.1.1;
option netbios-name-servers 192.168.1.1;
,# --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well
#
}
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
#
# option time-offset option ntp-servers -18000; # Eastern Standard Time 192.168.1.1; option nis-domain option domain-name "domain.org"; "domain.org"; 192.168.1.1; option routers option subnet-mask 192.168.1.1; 255.255.255.0; range dynamic-bootp 192.168.2.128 192.168.2.254; default-lease-time 21600; max-lease-time 43200; //地址池 //默认租期时间 (秒) //最大租期时间 (秒) option netbios-node-type 2; option domain-name-servers option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well
#
} # we want the nameserver to appear at a fixed address host ns { } next-server marvin.redhat.com; hardware ethernet AA:BB:CC:DD:EE:FF; fixed-address 192.168.1.3; //新建保留 range dynamic-bootp 192.168.1.2 192.168.1.60; default-lease-time 21600; max-lease-time 43200; option netbios-node-type 2;
4. service dhcpd restart
5. ※开机自启动(如果需要)
chkconfig dhcpd on
,四、测试结果
mac 地址为AA:BB:CC:DD:EE:FF的客户机 打开cmd 输入 ipconfig /renew
Windows IP Configuration
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.1.3 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1
五、问题判断:
无法启动服务,请仔细检查配置文件,注意不要少;和}符号
客户端无法获取地址,请检查客户机与服务器中间有没有路由设备。
dhcp 超级作用域
一、要求
服务器地址:192.168.2.2/24 网关:192.168.2.1
分配192.168.1.2-192.168.1.60/24 网关为192.168.1.1 新建保留192.168.1.3分配给AA:BB:CC:DD:EE:FF 建立名为dhcp 超级作用域。
二、操作步骤:
1. yum –y install dhcp*
2. cat /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample > /etc/dhcpd.conf
3. 修改/etc/dhcpd.conf 文件(注意:dhcp 首先要做与本机同网段的作用域)

4. service dhcpd restart
5. ※开机自启动(如果需要)
chkconfig dhcpd on
三、配置文件

, 红色字体是需要修改部分
#ddns-update-style interim;
#ignore client-updates;
share-network <名字> {
subnet 192.168.2.0 netmask 255.255.255.0 {
# --- default gateway
#
# option time-offset option ntp-servers -18000; # Eastern Standard Time 192.168.1.1; option nis-domain option domain-name "domain.org"; "domain.org"; //dns域名 //dns地址 192.168.1.1; option routers option subnet-mask 192.168.2.1; 255.255.255.0; option domain-name-servers option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well
#
}
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
option nis-domain option domain-name "domain.org"; "domain.org"; option routers option subnet-mask 192.168.1.1; 255.255.255.0; range dynamic-bootp 192.168.2.128 192.168.2.254; default-lease-time 21600; max-lease-time 43200; //地址池 //默认租期时间 (秒) //最大租期时间 (秒) option netbios-node-type 2;
,#
# option domain-name-servers option time-offset option ntp-servers 192.168.1.1; -18000; # Eastern Standard Time 192.168.1.1; option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well
#
}
} # we want the nameserver to appear at a fixed address host ns { } next-server marvin.redhat.com; hardware ethernet AA:BB:CC:DD:EE:FF; fixed-address 192.168.1.3; //新建保留 range dynamic-bootp 192.168.1.2 192.168.1.60; default-lease-time 21600; max-lease-time 43200; option netbios-node-type 2;
四、测试结果
mac 地址为AA:BB:CC:DD:EE:FF的客户机
打开cmd 输入 ipconfig /renew
Windows IP Configuration
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.1.3
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
五、问题判断:
无法启动服务,请仔细检查配置文件,注意不要少;和}符号 客户端无法获取地址,请检查客户机与服务器中间有没有路由设备。
dhcp group 组
,一、要求
服务器地址:192.168.2.2/24 网关:192.168.2.1
分配192.168.1.2-192.168.1.60/24 网关为192.168.1.1 新建保留192.168.1.3分配给AA:BB:CC:DD:EE:FF 建立dhcp group 组。
二、操作步骤:
1. yum –y install dhcp*
2. cat /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample > /etc/dhcpd.conf
3. 修改/etc/dhcpd.conf 文件(注意:dhcp 首先要做与本机同网段的作用域)


4. service dhcpd restart
5. ※开机自启动(如果需要)
chkconfig dhcpd on
三、配置文件
, 红色字体是需要修改部分
#ddns-update-style interim; #ignore client-updates;
share-network <名字> {
subnet 192.168.2.0 netmask 255.255.255.0 {
# --- default gateway
option routers option subnet-mask option nis-domain option domain-name
192.168.2.1; 255.255.255.0; "domain.org"; "domain.org";
//dns域名 //dns地址
192.168.1.1;
option domain-name-servers
,#
# option time-offset option ntp-servers -18000; # Eastern Standard Time 192.168.1.1; option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well
#
}
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
#
# option time-offset option ntp-servers -18000; # Eastern Standard Time 192.168.1.1; option nis-domain option domain-name "domain.org"; "domain.org"; 192.168.1.1; option routers option subnet-mask 192.168.1.1; 255.255.255.0; range dynamic-bootp 192.168.2.128 192.168.2.254; default-lease-time 21600; max-lease-time 43200; //地址池 //默认租期时间 (秒) //最大租期时间 (秒) option netbios-node-type 2; option domain-name-servers option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well
#
}
} # we want the nameserver to appear at a fixed address host ns { } next-server marvin.redhat.com; hardware ethernet AA:BB:CC:DD:EE:FF; fixed-address 192.168.1.3; //新建保留 range dynamic-bootp 192.168.1.2 192.168.1.60; default-lease-time 21600; max-lease-time 43200; option netbios-node-type 2;
,四、测试结果
mac 地址为AA:BB:CC:DD:EE:FF的客户机
打开cmd 输入 ipconfig /renew
Windows IP Configuration
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 192.168.1.3
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
五、问题判断:
无法启动服务,请仔细检查配置文件,注意不要少;和}符号 客户端无法获取地址,请检查客户机与服务器中间有没有路由设备。
group 组中可以有多个作用域,其作用域选项在作用域前面设置,则都起作用不用分开设置。