一、场景:

某公司需要使用开源技术构建企业的信息基础结构。第一期主要完成基础服务器的搭建。

主机名

IP地址

角色功能

ZZSRV1.BIGCLOUD.LOCAL

192.168.188.11

DNS、网站、DHCP服务器、时钟服务器

ZZSRV2.BIGCLOUD.LOCAL

192.168.188.12

辅助DNS、文件服务器

现在要求在VMwareWorkstation 10下构建POC(Proofof Concept)环境,以便来进行测试。

二、DHCP服务器搭建


1.要求:

网络

IP地址范围

网关

备注

VLAN1

192.168.188.100-192.168.188.253/24

排除 192.168.188.160192.168.188.169

192.168.188.2


VLAN2

192.168.189.100-192.168.189.253/24

192.168.189.2


DHCP服务器为ZZSRV1.BIGCLOUD.LOCAL,其IP地址为192.168.188.11

此单位的DNS服务器的地址为192.168.188.11192.168.188.12

需要将192.168.188.111保留给无法配置静态IP地址的打印机,其MAC地址为00:12:34:56:78:90

VLAN1的地址租约是3天,VLAN2的地址租约是8


2.实验环境:

# uname -a

Linux zzsrv1.bigcloud.local3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64GNU/Linux

# cat /etc/redhat-release

CentOS Linux release 7.0.1406 (Core)


3.实验步骤:

3.1修改主机名

# vi /etc/hostname

zzsrv1.bigcloud.local


3.2修改IP地址

# vi/etc/sysconfig/network-scripts/ifcfg-eno16777728

TYPE=Ethernet

BOOTPROTO=static

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

#IPV4_FAILURE_FATAL=yes

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

NAME=eno16777728

ONBOOT=yes

IPADDR=192.168.188.11

NETMASK=255.255.255.0

GETEWAY=192.168.188.2


3.3重启网卡

# service network restart

Restarting network (via systemctl):                        [  OK  ]

 

# vi /etc/resolv.conf

# Generated by NetworkManager

search bigcloud.local

nameserver 192.168.188.11

nameserver 192.168.188.12


3.4安装dhcp服务的包

# mkdir /mnt/cdrom

先挂载

# mount /dev/cdrom /mnt/cdrom

mount: /dev/sr0 is write-protected,mounting read-only

 

# cd /mnt/cdrom/Packages/

# ls dhcp*

dhcp-4.2.5-27.el7.centos.x86_64.rpm

dhcp-common-4.2.5-27.el7.centos.x86_64.rpm

dhcp-libs-4.2.5-27.el7.centos.x86_64.rpm

 

# rpm -Uchdhcp-4.2.5-27.el7.centos.x86_64.rpm

 

warning:dhcp-4.2.5-27.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key IDf4a80eb5: NOKEY

################################# [100%]

Updating / installing...

################################# [100%]

 

3.5.修改配置文件

# rpm -qc dhcp

/etc/dhcp/dhcpd.conf

/etc/dhcp/dhcpd6.conf

/etc/openldap/schema/dhcp.schema

/etc/sysconfig/dhcpd

/var/lib/dhcpd/dhcpd.leases

/var/lib/dhcpd/dhcpd6.leases

 

# vi dhcpd.conf

在该配置文件中添加如下内容:(188子网的租约为3天,189子网的租约为8天)

换算为秒:3*24*60*60s =2592008*24*60*60s=691200

option domain-name  "bigcloud.local";

option domain-name-servers  192.168.188.11, 192.168.188.12;

default-lease-time 691200;

max-lease-time 691200;

 

subnet 192.168.188.0 netmask  255.255.255.0 {

   range 192.168.188.100 192.168.188.159;

   range 192.168.188.170 192.168.188.253;

   default-lease-time 259200;

   max-lease-time 259200;

   option routers 192.168.188.2;

}

 

subnet 192.168.189.0 netmask  255.255.255.0 {

    range 192.168.189.100 192.168.189.253;

    option routers 192.168.189.2;

}

host printer1 {

    hardware ethernet 00:12:34:56:78:90;

    fixed-address 192.168.188.111;

}

 

3.6.启动dhcp服务

# systemctl start dhcpd.service

设置dhcp为自动启动

# systemctl enable dhcpd.service

检查dhcp是否为自动启动

# systemctl is-enabled dhcpd.service

enabled

 

3.7客户端验证:成功申请到IP

wKioL1PzTU6iM0JiAAICdw0Ggbs463.jpg

  ~还会再补充上DNS、NTP、samba、ftp等服务器的配置哦。~