DHCP relay service (the whole experiment, you can now do)

DHCP relay service test

Before the experiment we first look at the DHCP service
What is DHCP: DHCP is a protocol designed to automatically assign TCP / IP parameters for TCP / IP computers on the network. DHCP service to avoid errors caused by manually setting the IP address generated, but also to avoid address conflicts assign the same IP address to multiple users caused. DHCP provides safe, reliable and simple TCP / IP network settings, reducing the burden configure the IP address.
DHCP network structure
DHCP relay service (the whole experiment, you can now do)
benefit of DHCP:
reduce the workload of administrators.
Avoid possible input errors.
Avoid IP address conflicts.
When the network to change IP addresses, you do not need to reconfigure IP addresses for each user.
Improve the utilization of IP addresses.
Easy to configure the client.
DHCP distribution methods: Work in the DHCP, DHCP provides three IP allocation.
1) Automatic allocation: DHCP server specifies a permanent IP address for the host, once the DHCP client for the first time successfully leased from the DHCP server to the IP address, you can use that address permanently.
2) Dynamic allocation: DHCP server specifies the IP address to a host having a time limit, the time expires, or when the host discard the clear address, which can be used by other hosts.
3) manual distribution: client IP address is assigned by the network administrator, DHCP server assigned IP address will only tell the client host.

Experimental hardware requirements: CentOS VMware Workstation 7 and two win10 and GNS3 installed.
The first step in the experiment: GNS3 topology planning
first into GNS3 two routers and three out of the PC (select the host), After two routers configuration.
A renamed sw1, change the icon for the three switches, and add a two-story service board, as the three switches.
A renamed sw2, the icon for the switch, and add a two-story service board, as the switcher.
DHCP relay service (the whole experiment, you can now do)
A PC icon will be changed to sever, as the DHCP server. The other two configuration unchanged.

After the device is connected, and a display interface.
F1 DHCP sw2 is connected to VMnet1 / 1 interface.
f1 win10-1 sw2 is connected VMnet2 / 2 interfaces.
f1 win10-2 sw2 of the connection VMnet8 / 3 interfaces.
sw2 of f1 / f1 0 interface connected to sw1 / 0 interface.

划分vlan并对网关进行规划
win10-1对应vlan10:192.168.10.1;win10-2对应vlan20:192.168.20.1;DHCP对应vlan30:192.168.30.1。
规划结果如下图所示
DHCP relay service (the whole experiment, you can now do)
.
实验第二步:对交换机接口进行配置
对sw2二层交换机接口的配置
依次输入以下命令
conf t(进入全局模式)
vlan 10,20,30(进入vlan模式并创建三个vlan)
ex(退出vlan模式)
do show vlan-sw b(查看vlan配置结果)
int f1/1(进入sw2f1/1接口)
sw mo acc
sw acc vlan10(将f1/1接口划分给vlan10)
ex(退出接口)
int f1/2(进入sw2f1/2接口)
sw mo acc
sw acc vlan20(将接口f1/2划分给vlan20)
ex(退出接口)
int f1/3(进入sw2接口f1/3)
sw mo acc
sw acc vlan30(将接口f1/3划分给vlan30)
ex(退出接口)
do show vlan-sw b(查看vlan配置结果)
int f1/0(进入接口f1/0)
sw mo trunk(划分trunk链路)
sw trunk encapsulation dot1q(封装dot1q协议)
no ip routing(关闭路由功能)
DHCP relay service (the whole experiment, you can now do)
DHCP relay service (the whole experiment, you can now do)

对sw1三层交换机接口的配置
依次输入以下命令
conf t(进入全局模式)
vlan 10,20,30(进入vlan模式并创建是三个vlan)
ex(退出vlan模式)
do show vlan-sw b(查看vlan创建结果)
int f1/0(进入接口f1/0)
sw mo t(配置trunk链路)
sw t en dot(封装dot1q协议)
do show int f1/0 switchport(查看f1/0接口状态)
int vlan 10(进入虚拟接口vlan10)
ip add 192.168.10.1 255.255.255.0(配置vlan10的网关及子网掩码)
no shut(启动)
int vlan 20(进入虚拟接口vlan20)
ip add 192.168.20.1 255.255.255.0(配置vlan20的网关及子网掩码)
no shut(启动)
int vlan 30(进入虚拟接口vlan30)
ip add 192.168.30.1 255.255.255.0(配置vlan30的网关及子网掩码)
no shut(启动)
show ip int b(查看配置结果)
DHCP relay service (the whole experiment, you can now do)
DHCP relay service (the whole experiment, you can now do)

实验第三步:对三台PC机的网络配置进行设置
首先对CentOS 7在联网状态下使用yum源安装dhcp服务。
命令:yum install dhcp -y
DHCP relay service (the whole experiment, you can now do)

安装完的DHCP后,调整网络适配器连接模式为机主机模式,然后对其ens33网卡进行配置。
命令:vim /etc/sysconfig/network-scripts/ifcfg-ens33
DHCP relay service (the whole experiment, you can now do)

进入网络配置文件之后进行ens33网卡配置
dhcp改为static(自动分配ip改为手动配置)
IPADDR=192.168.30.30(IP地址)
NETMASK=255.255.255.0(子网掩码)
GATEWAY=192.168.30.1(网关)
:wq(保存并退出)
systemctl restart network(重启网络配置)
ifconfig(查看配置结果)
DHCP relay service (the whole experiment, you can now do)
DHCP relay service (the whole experiment, you can now do)

下面就是对dhcp的配置了
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf(复制/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example到/etc/dhcp/dhcpd.conf)
yes(确认进行覆盖)
vim /etc/dhcp/dhcpd.conf(进入配置文件)
进入后找到第一个subnet进行修改
subnet 192.168.10.0 network 255.255.255.0 {
(转下行空两格)range 192.168.10.128 192.168.10.200;(DHCP自动分配地址的范围)
(转下行空两格)option routers 192.168.10.1;
}
因为我们一共三个vlan,所以要配三个
4yy p 复制第一个对第二个进行配置
subnet 192.168.20.0 network 255.255.255.0 {
(转下行空两格)range 192.168.20.128 192.168.20.200;(DHCP自动分配地址的范围)
(转下行空两格)option routers 192.168.20.1;
}
4yy p对第三个进行配置
subnet 192.168.30.0 network 255.255.255.0 {
(转下行空两格)range 192.168.30.128 192.168.30.200;(DHCP自动分配地址的范围)
(转下行空两格)option routers 192.168.30.1;
}
:wq(保存并退出)
systemctl start dhcpd(启动DHCP服务)
systemctl status dhcpd(查看DHCP服务状态)
DHCP relay service (the whole experiment, you can now do)
DHCP relay service (the whole experiment, you can now do)
DHCP relay service (the whole experiment, you can now do)

CentOS 7配置完成,下面就是两台win10的网络适配器的配置了
win10-1网络适配器模式调成VMnet2仅主机模式
win10-2网络适配器模式调成VMnet8仅主机模式
DHCP relay service (the whole experiment, you can now do)

实验第四步:配置DHCP中继
我们知道正常vlan是阻断广播的,但是此处就需要只让DHCP的广播包可以跨越,走到不同的vlan中,给他们分配不同的vlanIP,所以我们要在sw1中配置dhcp中继服务。
依次输入以下命令
conf t
int vlan 10
ip helper-address 192.168.30.30
no shut
ex
int vlan 20
ip helper-address 192.168.30.30
no shut
ex
int vlan 30
ip helper-address 192.168.30.30
no shut
ex
DHCP relay service (the whole experiment, you can now do)

Experimental Step five: Verify the test results
using two win10 see if you can obtain an IP address automatically.
DHCP relay service (the whole experiment, you can now do)
DHCP relay service (the whole experiment, you can now do)

Results: Two win10 able to obtain an IP address via dhcp relay service capable of interoperability.
DHCP relay service (the whole experiment, you can now do)

Guess you like

Origin blog.51cto.com/14449528/2434881