• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

04-三层技术-IP业务配置举例

目录

07-H3C_12500_跨网段动态分配IP地址典型配置举例

本章节下载 07-H3C_12500_跨网段动态分配IP地址典型配置举例  (189.98 KB)

docurl=/cn/Service/Document_Software/Document_Center/Switches/Catalog/S12500/S12500-S/Configure/Typical_Configuration_Example/H3C_S12500-S_CE-R7536P05-6W100/04/201709/1032173_30005_0.htm

07-H3C_12500_跨网段动态分配IP地址典型配置举例

H3C 跨网段动态分配IP地址典型配置举例

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Copyright © 2017 新华三技术有限公司 版权所有,保留一切权利。

非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,

并不得以任何形式传播。本文档中的信息可能变动,恕不另行通知。

H3C_彩色.emf

 



1 简介

本文档介绍了通过DHCP服务器和DHCP中继为用户动态分配IP地址的配置举例。

2 配置前提

本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。

本文假设您已了解DHCP相关特性。

3 跨网段动态分配IP地址典型配置举例

3.1  组网需求

图3-1所示,公司总部和分支机构处于不同的网段,网关DeviceA充当DHCP服务器,要求:

·     为总部分配10.1.1.2~10.1.1.100之间的IP地址;

·     为分支机构分配10.1.3.2~10.1.3.100之间的IP地址,其中10.1.3.2~10.1.3.48之间的IP地址分配给分支机构1,10.1.3.49~10.1.3.100之间的IP地址分配给分支机构2;

·     指定DNS服务器的固定IP地址为10.1.1.3/24,TFTP服务器的固定IP地址为10.1.1.4/24;

·     分配DNS服务器、TFTP服务器和网关等配置信息。

网关DeviceB充当DHCP中继,要求:

·     通过配置DHCP中继功能,使得DHCP服务器能够为分支机构分配IP地址、DNS服务器、TFTP服务器和网关等配置信息;

·     防止分支机构中存在非法主机配置静态IP地址访问网络;

·     为每个区域分配特定范围内的IP地址。

图3-1 跨网段动态分配IP地址配置组网图

设备

接口

IP地址

设备

接口

IP地址

Device A

Vlan-int3

10.1.1.1/24

Device B

Vlan-int3

10.1.3.1/24

 

Vlan-int2

10.1.2.1/24

 

Vlan-int2

10.1.2.2/24

 

3.2  配置思路

·     DHCP Server分配IP地址时,不能将DNS Server和TFTP Server的IP地址分配出去,所以需要将这两台服务器的IP地址配置为不参与自动分配的IP地址。

·     启用DHCP中继的用户地址表项记录功能,通过与IP Source Guard配合,实现只允许匹配用户地址表项中绑定关系的报文通过DHCP中继。

·     配置DHCP中继支持Option82功能,并在DHCP服务器上配置根据Option82的分配策略,从而实现为每个区域分配特定范围内的IP地址。

3.3  使用版本

本举例是在S12500S-CMW710-R7536P05版本上进行配置和验证的。

3.4  配置步骤

1. Device A的配置

# 配置VLAN接口2的IP地址。

<DeviceA> system-view

[DeviceA] vlan 2

[DeviceA-vlan2] port GigabitEthernet 1/0/2

[DeviceA-vlan2] quit

[DeviceA] interface Vlan-interface 2

[DeviceA-Vlan-interface2] ip address 10.1.2.1 24

[DeviceA-Vlan-interface2] quit

# 配置VLAN接口3的IP地址。

[DeviceA] vlan 3

[DeviceA-vlan3] port GigabitEthernet 1/0/1

[DeviceA-vlan3] quit

[DeviceA] interface Vlan-interface 3

[DeviceA-Vlan-interface3] ip address 10.1.1.1 24

[DeviceA-Vlan-interface3] quit

# 使能DHCP服务。

[DeviceA] dhcp enable

# 配置VLAN接口2工作在DHCP服务器模式。

[DeviceA] interface vlan-interface 2

[DeviceA-Vlan-interface2] dhcp select server

[DeviceA-Vlan-interface2] quit

# 配置VLAN接口3工作在DHCP服务器模式。

[DeviceA] interface vlan-interface 3

[DeviceA-Vlan-interface3] dhcp select server

[DeviceA-Vlan-interface3] quit

# 配置DHCP地址池1。

[DeviceA] dhcp server ip-pool 1

# 配置地址池动态分配的主网段和IP地址范围。

[DeviceA-dhcp-pool-1] network 10.1.1.0 mask 255.255.255.0

[DeviceA-dhcp-pool-1] address range 10.1.1.2 10.1.1.100

# 配置DHCP客户端使用的DNS服务器地址、TFTP服务器地址、域名后缀和网关地址。

[DeviceA-dhcp-pool-1] dns-list 10.1.1.3

[DeviceA-dhcp-pool-1] tftp-server ip-address 10.1.1.4

[DeviceA-dhcp-pool-1] domain-name com

[DeviceA-dhcp-pool-1] gateway-list 10.1.1.1

# 配置DHCP地址池中不参与自动分配的IP地址。

[DeviceA-dhcp-pool-1] forbidden-ip 10.1.1.3 10.1.1.4

[DeviceA-dhcp-pool-1] quit

# 配置VLAN接口3引用地址池1。

[DeviceA] interface Vlan-interface 3

[DeviceA-Vlan-interface3] dhcp server apply ip-pool 1

[DeviceA-Vlan-interface3] quit

# 为使Option 82功能正常使用,需要在DHCP服务器和DHCP中继上都进行相应配置。如下为DHCP服务器上的相关配置:

# 创建DHCP用户类aa的匹配规则为匹配规则编号1,匹配请求报文中包含Option 82选项,并且该选项的第5字节到第6字节为0x0001(表示连接端口为GE1/0/1)的客户端。

[DeviceA] dhcp class aa

[DeviceA-dhcp-class-aa] if-match rule 1 option 82 hex 0001 offset 4 length 2

[DeviceA-dhcp-class-aa] quit

# 创建DHCP用户类bb的匹配规则为匹配规则编号1,匹配请求报文中包含Option 82选项,并且该选项的第5字节到第6字节为0x0003(表示连接端口为GE1/0/3)的客户端。

[DeviceA] dhcp class bb

[DeviceA-dhcp-class-bb] if-match rule 1 option 82 hex 0003 offset 4 length 2

[DeviceA-dhcp-class-bb] quit

# 配置DHCP地址池2。

[DeviceA] dhcp server ip-pool 2

# 配置地址池动态分配的主网段。

[DeviceA-dhcp-pool-2] network 10.1.3.0 mask 255.255.255.0

# 配置DHCP地址池为DHCP用户类aa动态分配的IP地址范围。

[DeviceA-dhcp-pool-2] class aa range 10.1.3.2 10.1.3.48

# 配置DHCP地址池为DHCP用户类bb动态分配的IP地址范围。

[DeviceA-dhcp-pool-2] class bb range 10.1.3.49 10.1.3.100

# 配置DHCP客户端使用的DNS服务器地址、TFTP服务器地址、域名后缀和网关地址。

[DeviceA-dhcp-pool-2] tftp-server ip-address 10.1.1.4

[DeviceA-dhcp-pool-2] dns-list 10.1.1.3

[DeviceA-dhcp-pool-2] domain-name com

[DeviceA-dhcp-pool-2] gateway-list 10.1.3.1

[DeviceA-dhcp-pool-2] quit

# 配置VLAN接口2引用地址池2。

[DeviceA] interface Vlan-interface 2

[DeviceA-Vlan-interface2] dhcp server apply ip-pool 2

[DeviceA-Vlan-interface2] quit

# 配置到10.1.3.0网段的静态路由。

[DeviceA] ip route-static 10.1.3.0 24 10.1.2.2 

2. Device B的配置

# 配置VLAN接口2的IP地址。

<DeviceB> system-view

[DeviceB] vlan 2

[DeviceB-vlan2] port GigabitEthernet 1/0/2

[DeviceB-vlan2] quit

[DeviceB] interface Vlan-interface 2

[DeviceB-Vlan-interface2] ip address 10.1.2.2 24

[DeviceB-Vlan-interface2] quit

# 配置VLAN接口3的IP地址。

[DeviceB] vlan 3

[DeviceB-vlan3] port GigabitEthernet 1/0/1

[DeviceB-vlan3] port GigabitEthernet 1/0/3

[DeviceB-vlan3] quit

[DeviceB] interface Vlan-interface 3

[DeviceB-Vlan-interface3] ip address 10.1.3.1 24

[DeviceB-Vlan-interface3] quit

# 使能DHCP服务。

[DeviceB] dhcp enable

# 配置VLAN接口3工作在DHCP中继模式。

[DeviceB] interface vlan-interface 3

[DeviceB-Vlan-interface3] dhcp select relay

# 指定DHCP服务器的地址。

[DeviceB-Vlan-interface3] dhcp relay server-address 10.1.2.1

# 为使Option 82功能正常使用,需要在DHCP服务器和DHCP中继上都进行相应配置。如下为DHCP中继上的相关配置:

# 使能DHCP中继支持Option82功能。

[DeviceB-Vlan-interface3] dhcp relay information enable

[DeviceB-Vlan-interface3] quit

# 开启DHCP中继用户地址表项记录功能。

[DeviceB] dhcp relay client-information record

# 配置IPv4动态绑定功能。

[DeviceB] interface vlan-interface 3

[DeviceB-Vlan-interface3] ip verify source ip-address mac-address

[DeviceB-Vlan-interface3] quit

# 配置到10.1.1.0网段的静态路由。

[DeviceB] ip route-static 10.1.1.0 24 10.1.2.1 

3.5  验证配置

# 显示IP地址10.1.3.3DHCP地址绑定信息,可以查看到该地址已经被分配出去。

<DeviceA> display dhcp server ip-in-use ip 10.1.3.3

IP address       Client identifier/    Lease expiration      Type

                 Hardware address

10.1.3.3         0033-6365-352e-6136-  Jan  2 00:34:02 2017  Auto(C)

                 6466-2e65-3133-392d-

                 5465-6e2d-4769-6761-

                 6269-7445-7468-6572-

                 6e65-7431-2f30-2f35-

                 31 

# 在分支机构1中的某一用户PC上输入如下命令,可查看申请到的IP地址。按照同样的方式,可以确认分支机构2中的用户也得到指定范围内的地址。

C:\Documents and Settings\aa>ipconfig

 

Windows IP Configuration

 

Ethernet adapter aa:

 

        Connection-specific DNS Suffix  . : domain-name com

        IP Address. . . . . . . . . . . . : 10.1.3.3

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        IP Address. . . . . . . . . . . . : fe80::20f:3dff:fe80:2b38%4

        Default Gateway . . . . . . . . . : 10.1.3.1

# 假设分支机构2里的非法用户配置了一个10.1.3.87IP地址,会发现无法访问TFTP服务器。

3.6  配置文件

(1)     Device A

#

 dhcp enable

#

vlan 2 to 3

#

dhcp class aa

 if-match rule 1 option 82 hex 0001 offset 4 length 2

#

dhcp class bb

 if-match rule 1 option 82 hex 0003 offset 4 length 2

#

dhcp server ip-pool 1

 network 10.1.1.0 mask 255.255.255.0

 address range 10.1.1.2 10.1.1.100

 dns-list 10.1.1.3

 domain-name com

 forbidden-ip 10.1.1.3

 forbidden-ip 10.1.1.4

 gateway-list 10.1.1.1

 tftp-server ip-address 10.1.1.4

#

dhcp server ip-pool 2

 network 10.1.3.0 mask 255.255.255.0

 class aa range 10.1.3.2 10.1.3.48

 class bb range 10.1.3.49 10.1.3.100

 dns-list 10.1.1.3

 domain-name com

 gateway-list 10.1.3.1

 tftp-server ip-address 10.1.1.4

#

interface Vlan-interface2

 ip address 10.1.2.1 255.255.255.0

 dhcp server apply ip-pool 2

#

interface Vlan-interface3

 ip address 10.1.1.1 255.255.255.0

 dhcp server apply ip-pool 1

#

interface GigabitEthernet1/0/1

 port link-mode bridge

 port access vlan 3

#

interface GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

ip route-static 10.1.3.0 24 10.1.2.2

#

(2)     Device B

#

 dhcp enable

 dhcp relay client-information record

#

vlan 2 to 3

#

interface Vlan-interface2

 ip address 10.1.2.2 255.255.255.0

#

interface Vlan-interface3

 ip address 10.1.3.1 255.255.255.0

 dhcp select relay

 dhcp relay information enable

 dhcp relay server-address 10.1.2.1

 ip verify source ip-address mac-address

#

interface GigabitEthernet1/0/1

 port link-mode bridge

 port access vlan 3

#

interface GigabitEthernet1/0/2

 port link-mode bridge

 port access vlan 2

#

interface GigabitEthernet1/0/3

 port link-mode bridge

 port access vlan 3

#

ip route-static 10.1.1.0 24 10.1.2.1

#

4 相关资料

·     H3C S12500-S系列交换机 三层技术-IP业务配置指导-R7536P05

·     H3C S12500-S系列交换机 三层技术-IP业务命令参考-R7536P05

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们