华为路由器交换机DHCP配置实例(二层、三层交换机)

一、条件和拓朴:

R1为DHCP配置网关,S1为二层交换机

华为路由器交换机DHCP配置实例(二层、三层交换机)_第1张图片

二、要求:

PC1获取到vlan10地址,PC2获取vlan10地址,PC3获取vlan20地址

三、实现方式:
         1,单臂路由方式:

S1正常配置vlan10,20,配置与R1相连的1口为trunk口

R1的1口,配置单臂路由,终结vlan10、20

AR1的配置:

dhcp enable
#
ip pool 1
 gateway-list 10.10.10.1 
 network 10.10.10.0 mask 255.255.255.0 
 excluded-ip-address 10.10.10.2
#
ip pool 2
 gateway-list 10.20.20.1 
 network 10.20.20.0 mask 255.255.255.0 
#
interface GigabitEthernet0/0/1.1
 dot1q termination vid 10
 ip address 10.10.10.1 255.255.255.0 
 arp broadcast enable
 dhcp select global
#
interface GigabitEthernet0/0/1.2
 dot1q termination vid 20
 ip address 10.20.20.1 255.255.255.0 
 arp broadcast enable
 dhcp select global
#
         2,透传方式(路由器接口改二层trunk):

将R1的1口配置为二层的trunk口,配置vlan10、20的vlanif网关为dhcp网关,S1正常配置vlan

interface GigabitEthernet0/0/1
 portswitch
 port link-type trunk
port trunk allow-pass vlan 10 20
#
int vlanif 10
 ip addr 10.10.10.1 24
 dhcp select interface
#int vlanif 20
 ip addr 10.20.20.1 24
 dhcp select interface
         3,网关下沉方式(接入交换机改三层):

DHCP服务配置在三层交换机,网关也下沉到三层交换机上,通过管理网段和路由器接口连接,则S1配置如下:

vlan batch 10 20 100
#
dhcp enable
#
interface Vlanif2
 ip address 10.10.10.1 255.255.255.0
 dhcp select interface
 dhcp server dns-list 114.114.114.114 8.8.8.8
#
interface Vlanif3
 ip address 10.20.20.1 255.255.255.0
 dhcp select interface
 dhcp server dns-list 114.114.114.114 8.8.8.8
#
interface Vlanif100
 ip address 10.100.100.2 255.255.255.0
#
interface GE 1/0/1
 port default vlan 100
#
interface GE 1/0/2
 port default vlan 10
#
interface GE 1/0/3
 port default vlan 20
#
ip route-static 0.0.0.0 0.0.0.0 10.100.100.1
#

R1配置如下(含nat配置):

acl number 2001
 rule 5 permit source 10.0.0.0 0.255.255.255
#
interface GigabitEthernet0/0/1
 ip address 10.100.100.1 255.255.255.0
#
interface GigabitEthernet0/0/2
 ip address 203.0.113.46 255.255.255.30
 nat outbound 2001
#
ip route-static 0.0.0.0 0.0.0.0 203.0.113.45
ip route-static 10.0.0.0 255.255.255.0 10.100.100.2
         4,dhcp中继方式(接入交换机配置dhcp relay):

R1改为交换机S0,定义IP池,定义管理网段100,配置管理地址,trunk方式连接S1;

S1配置vlanif网关,启用dhcp中继,使用本机的管理IP为中继地址,配置默认路由为S0的管理IP。S1配置如下:

interface Vlanif10
 ip address 10.10.10.1 255.255.255.0
 dhcp select relay
 dhcp relay server-ip 10.1.200.29
#
interface Vlanif20
 ip address 10.20.20.1 255.255.255.0
 dhcp select relay
 dhcp relay server-ip 10.1.200.29
#
interface Vlanif100
 ip address 10.100.100.2 255.255.255.252
#
ip route-static 0.0.0.0 0.0.0.0 10.100.100.1

你可能感兴趣的:(数通,运维,华为,网络,智能路由器)