需求描述:
在网关主机中构建DHCP、DHCP中继服务器
1.为以下三个物理网段提供动态地址分配服务:
192.168.1.0/24
192.168.2.0/24
192.168.3.0/24
2.默认租约时间21600秒
3.最大租约时间43200秒
4.客户机使用的DNS服务器地址如下:
202.106.0.20
8.8.8.8
5.用于动态分配的IP地址范围分别为:
192.168.1.100~192.168.1.200
192.168.2.200~192.168.2.200
192.168.3.300~192.168.3.200
网关主机各接口的IP地址作为对应网段的默认网关
实现思路:
1.确认服务器主机的网络地址配置正确
2.先配置好DHCP服务器
3.再配置DHCP中继服务器
验证实验结果
注意事项:
将虚拟机的内存设为256MB,进入字符模式,关闭不常用的系统服务程序
将DHCP服务器的默认网关指向DHCP中继服务器
GO
DHCP服务器的配置(网卡为vmnet2)
[root@dhcpserver~]#serviceiptablesstop
[root@dhcpserver~]#setenforce0
[root@dhcpserver~]#cat/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:0c:29:b3:f2:f5
IPADDR=192.168.1.2
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
[root@dhcpserver~]#servicenetworkrestart
[root@dhcpserver~]#ifconfigeth0
[root@dhcpserver~]#yum-yinstalldhcp
[root@dhcpserver~]#cp/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample/etc/dhcpd.conf
[root@dhcpserver~]#vim/etc/dhcpd.conf
ddns-update-styleinterim;
ignoreclient-updates;
default-lease-time21600;
max-lease-time43200;
optiondomain-name-servers202.106.0.20,8.8.8.8;
optiondomain-name"Crushlinux.com";
subnet192.168.1.0netmask255.255.255.0{
optionrouters192.168.1.1;
optionsubnet-mask255.255.255.0;
rangedynamic-bootp192.168.1.100192.168.1.200;
}
subnet192.168.2.0netmask255.255.255.0{
optionrouters192.168.2.1;
optionsubnet-mask255.255.255.0;
rangedynamic-bootp192.168.2.100192.168.2.200;
}
subnet192.168.3.0netmask255.255.255.0{
optionrouters192.168.3.1;
optionsubnet-mask255.255.255.0;
rangedynamic-bootp192.168.3.100192.168.3.200;
}
[root@dhcpserver~]#servicedhcpdrestart
[root@dhcpserver~]#chkconfigdhcpdon
[root@dhcpserver~]#ping192.168.1.1
DHCP中继服务器的配置(共3个网卡,第一个:vmnet2,第二个:vmnet3,第四个:vmnet4)
[root@DHCRELAY~]#serviceiptablesstop
[root@DHCRELAY~]#setenforce0
[root@DHCRELAY~]#vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:0c:29:e0:f7:26
ONBOOT=yes
IPADDR=192.168.1.1
NETMASK=255.255.255.0
GATEWAY=192.168.1.2
[root@DHCRELAY~]#vim/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
HWADDR=00:0c:28:e0:f7:33
ONBOOT=yes
IPADDR=192.168.2.1
NETMASK=255.255.255.0
[root@DHCRELAY~]#vim/etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
BOOTPROTO=static
HWADDR=00:0b:17:e0:f7:33
ONBOOT=yes
IPADDR=192.168.3.1
NETMASK=255.255.255.0
[root@DHCRELAY~]#servicenetworkrestart
[root@DHCRELAY~]#ifconfig
[root@DHCRELAY~]#ping192.168.1.2
[root@DHCRELAY~]#yum-yinstalldhcp
[root@DHCRELAY~]#vim/etc/sysconfig/dhcrelay
INTERFACES="eth0eth1eth2"
DHCPSERVERS="192.168.1.2"
[root@DHCRELAY~]#servicedhcrelaystart
[root@DHCRELAY~]#servicedhcrelayrestart
[root@DHCRELAY~]#chkconfigdhcrelayon
[root@DHCRELAY~]#netstat�Ctulnp|grepdhcrelay
客户机测试
客户机网卡分别设置成vmnet2、vmnet3、vmnet4获取IP地址进行测试
测试命令:
开始-->运行-->cmd
C:\Users\Crushlinux>cd\
C:\>ipconfig/release
C:\>ipconfig/renew
本文出自 “梦想的出发点” 博客,谢绝转载!