HCL模拟三层交换机做DHCP服务器的实验

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

HCL模拟三层交换机做DHCP服务器的实验
HCL模拟器搭建实验拓扑图结构:
如上图,三层交换机S5820V2-54QS-GE_1的端口GE1/0/1连接一台PC2,PC2属于vlan 10,让其获取到192.168.10.0/24的ip地址;端口GE1/0/2连接一台host主机,host_1主机的网卡和电脑上的虚拟网卡NIC VitualBox Host-Only Ethernet Adapter #2关联。

Host_1主机让其获取到192.168.20.0/24的ip地址。

下面说一下配置思路和过程:
步骤1:三层交换机划分vlan并设置vlan的管理地址,作为主机的网关:
[H3C]vlan 10
[H3C-vlan10]vlan 20
[H3C-vlan20]quit
[H3C]int vlan 10
[H3C-Vlan-interface10]ip address 192.168.10.254 24
[H3C-Vlan-interface10]quit
[H3C]int vlan 20
[H3C-Vlan-interface20]ip address 192.168.20.254 24
[H3C-Vlan-interface20]quit
步骤2:把相应的端口添加到vlan:
[H3C]int g1/0/1
[H3C-GigabitEthernet1/0/1]port link-type access
[H3C-GigabitEthernet1/0/1]port access vlan 10
[H3C-GigabitEthernet1/0/1]quit
[H3C]int g1/0/2
[H3C-GigabitEthernet1/0/2]port link-type access
[H3C-GigabitEthernet1/0/2]port access vlan 20
步骤3:设置DHCP地址池:
我们可以查看下和dhcp相关的命令:
[H3C]dhcp ?
class Create a DHCP class
client Configure a DHCP client
dscp Set the Differentiated Services Codepoint (DSCP) value enable Enable DHCP
log Specify DHCP log configuration
option-group Create a DHCP option group
policy Configure a DHCP policy
relay Configure a DHCP relay agent
server Configure a DHCP server
smart-relay DHCP smart relay
snooping Configure DHCP snooping
其中,dhcp后接server是我们要使用的命令:
[H3C]dhcp server ip-pool vlan10pool 设置一个DHCP地址池名为vlan10pool [H3C-dhcp-pool-vlan10pool]network 192.168.10.0 24 设置vlan10pool分配地址段[H3C-dhcp-pool-vlan10pool]gate 按下tab键,自动补全命令
[H3C-dhcp-pool-vlan10pool]gateway-list 192.168.10.254 设置地址池网关地址为三层交换机划分的vlan 10的管理ip
[H3C-dhcp-pool-vlan10pool]dns
[H3C-dhcp-pool-vlan10pool]dns-list 114.114.114.114 设置dns参数
[H3C-dhcp-pool-vlan10pool]quit
步骤4:设置vlan的DHCP工作模式
首先进入到vlan 10,然后设置dhcp工作模式
[H3C-Vlan-interface10]dhcp select server
[H3C-Vlan-interface10]dhcp server ?
apply Apply a DHCP pool
check Check DHCP packets
policy-first Policy-first address pool selection
[H3C-Vlan-interface10]dhcp server apply ?
ip-pool Specify a DHCP pool
[H3C-Vlan-interface10]dhcp server apply ip-pool vlan10pool 在这里设置的为vlan10指定的地址池名(ip-pool)不能写错。

要和已经设置的地址池名对应上。

[H3C-Vlan-interface10]quit
[H3C]dhcp enable 启动DHCP服务
[H3C]%Aug 10 16:09:32:670 2019 H3C IFNET/3/PHY_UPDOWN: Physical state on the interface GigabitEthernet1/0/1 changed to up.
%Aug 10 16:09:32:671 2019 H3C IFNET/5/LINK_UPDOWN: Line protocol state on the interface GigabitEthernet1/0/1 changed to up.
%Aug 10 16:09:32:671 2019 H3C IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface10 changed to up.
%Aug 10 16:09:32:671 2019 H3C IFNET/5/LINK_UPDOWN: Line protocol state on the interface Vlan-interface10 changed to up.
[H3C]%Aug 10 16:10:03:476 2019 H3C STP/6/STP_DETECTED_TC: Instance 0's port GigabitEthernet1/0/1 detected a topology change. 出现这个提示就表示和GigabitEthernet1/0/1相连的端口机器成功获取IP
在这里,因为我们没有设置排除ip,故PC_2获取到的ip地址从192.168.10.1开始。

如果我们设置了排除ip:192.168.10.1-192.168.10.10不分配出去,那么它就获取到ip:192.168.10.11/24了。

设置排除ip须在全局模式下进行:
[H3C]dhcp server forbidden-ip 192.168.10.1 192.168.10.10
然后查看PC_2获取到的ip地址:
同理,我们设置vlan 20的ip地址池,并设置vlan 20的dhcp工作模式和排除ip:[H3C]dhcp server ip-pool vlan20pool
[H3C-dhcp-pool-vlan20pool]network 192.168.20.0 24
[H3C-dhcp-pool-vlan20pool]gate
[H3C-dhcp-pool-vlan20pool]gateway-list 192.168.20.254
[H3C-dhcp-pool-vlan20pool]dns
[H3C-dhcp-pool-vlan20pool]dns-list 114.114.114.114
[H3C-dhcp-pool-vlan20pool]quit
[H3C]int vlan 20
[H3C-Vlan-interface20]dhcp select server
[H3C-Vlan-interface20]dhcp server apply ip-pool vlan20pool
[H3C-Vlan-interface20]quit
[H3C]dhcp server forbidden-ip 192.168.20.1 192.168.20.20
由于模拟器上的host主机的网卡和本机的虚拟网卡关联,我们直接在本机网络和共享中心找到虚拟网卡,双击查看IP:
可以看见host_1主机也成功地获取到了三层交换机上DHCP服务器分配给vlan 20的机器的ip地址了。

相关文档
最新文档