简单三层架构配置实验

实验要求

  1. 内网IP地址172.16.0.0/16,合理分配
  2. SW1/2之间互为备份
  3. VRRP/STP/VLAN/TRUNK均使用

实验拓扑

在这里插入图片描述

实验配置

vlan2 172.16.2.0/24
vlan3 172.16.3.0/24

  1. 华为eth-trunk配置
[Huawei]sysname sw3-1
[sw3-1]int Eth-Trunk 0
[sw3-1-Eth-Trunk0]trunkport g0/0/2
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3-1-Eth-Trunk0]trunkport g0/0/3

[Huawei]sysname sw3-2
[sw3-2]int Eth-Trunk 0
[sw3-2-Eth-Trunk0]trunkport g0/0/2
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3-2-Eth-Trunk0]trunkport g0/0/3
  1. 三层交换机vlan配置
[sw3-1]vlan batch 2 3
[sw3-1]int Eth-Trunk 0
[sw3-1-Eth-Trunk0]port link-type trunk
[sw3-1-Eth-Trunk0]port trunk allow-pass vlan 2 3
[sw3-1-Eth-Trunk0]int g0/0/4
[sw3-1-GigabitEthernet0/0/4]port hybrid tagged vlan 2 3
[sw3-1-GigabitEthernet0/0/4]int g0/0/5

[sw3-2]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3-2]int Eth-Trunk 0
[sw3-2-Eth-Trunk0]port link-type trunk
[sw3-2-Eth-Trunk0]port trunk allow-pass vlan 2 3
[sw3-2-Eth-Trunk0]int g0/0/4
[sw3-2-GigabitEthernet0/0/4]port hybrid tagged vlan 2 3
[sw3-2-GigabitEthernet0/0/4]int g0/0/5
[sw3-2-GigabitEthernet0/0/5]port hybrid tagged vlan 2 3
  1. 二层交换机vlan配置
[sw2-1]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2-1]int e0/0/4
[sw2-1-Ethernet0/0/4]port link-type access
[sw2-1-Ethernet0/0/4]port default vlan 2
[sw2-1-Ethernet0/0/4]int e0/0/3
[sw2-1-Ethernet0/0/3]port link-type access
[sw2-1-Ethernet0/0/3]port default vlan 3
[sw2-1-Ethernet0/0/3]int e0/0/1
[sw2-1-Ethernet0/0/1]port hybrid tagged vlan 2 3
[sw2-1-Ethernet0/0/1]int e0/0/2
[sw2-1-Ethernet0/0/2]port hybrid tagged vlan 2 3

[sw2-2]vlan batch 2 3
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2-2]int e0/0/3
[sw2-2-Ethernet0/0/3]port link-type access
[sw2-2-Ethernet0/0/3]port default vlan 2
[sw2-2-Ethernet0/0/3]int e0/0/4
[sw2-2-Ethernet0/0/4]port link-type access
[sw2-2-Ethernet0/0/4]port default vlan 3
[sw2-2-Ethernet0/0/4]int e0/0/1
[sw2-2-Ethernet0/0/1]port hybrid tagged vlan 2 3
[sw2-2-Ethernet0/0/1]int e0/0/2
[sw2-2-Ethernet0/0/2]port hybrid tagged vlan 2 3

  1. 生成树协议
[sw3-1]stp enable
[sw3-1]stp region-configuration 
[sw3-1-mst-region]region-name a
[sw3-1-mst-region]instance 1 vlan 2
[sw3-1-mst-region]instance 2 vlan 3
[sw3-1-mst-region]active region-configuration 
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3-1-mst-region]qu
[sw3-1]stp instance 1 root primary
[sw3-1]stp instance 2 root secondary 

[sw3-2]stp region-configuration 
[sw3-2-mst-region]reg	
[sw3-2-mst-region]region-name  a
[sw3-2-mst-region]instance 1 vlan 2
[sw3-2-mst-region]instance 2 vlan 3
[sw3-2-mst-region]active region-configuration 
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3-2-mst-region]qu
[sw3-2]stp instance 2 root primary
[sw3-2]stp instance 1 root secondary

[sw2-1]stp enable
[sw2-1]stp region-configuration 
[sw2-1-mst-region]region-name a
[sw2-1-mst-region]instance 1 vlan 2
[sw2-1-mst-region]instance 2 vlan 3
[sw2-1-mst-region]active region-configuration 

[sw2-2]stp enable
[sw2-2]stp region-configuration 	
[sw2-2-mst-region]region-name a
[sw2-2-mst-region]instance 1 vlan 2
[sw2-2-mst-region]instance 2 vlan 3
[sw2-2-mst-region]active region-configuration 

  1. 配置SVI
[sw3-1]int vlan 2
[sw3-1-Vlanif2]ip address 172.16.2.1 24
[sw3-1-Vlanif2]int vlan 3
[sw3-1-Vlanif3]ip address 172.16.3.1 24

[sw3-2]int vlan 2
[sw3-2-Vlanif2]ip address 172.16.2.2 24
[sw3-2-Vlanif2]int vlan 3
[sw3-2-Vlanif3]ip address 172.16.3.2 24
  1. VRRP配置
[sw3-1]int vlanif 2
[sw3-1-Vlanif2]vrrp vrid 2 virtual-ip 172.16.2.254
[sw3-1-Vlanif2]vrrp vrid 2 priority 101
[sw3-1-Vlanif2]vrrp vrid 2 track int g0/0/1
[sw3-1-Vlanif2]int vlanif 3
[sw3-1-Vlanif3]vrrp vrid 3 virtual-ip 172.16.3.254
[sw3-1-Vlanif3]vrrp vrid 3 track int g0/0/1

[sw3-2]int vlanif 2
[sw3-2-Vlanif2]vrrp vrid 2 virtual-ip 172.16.2.254
[sw3-2-Vlanif2]vrrp vrid 2 track int g0/0/1
[sw3-2-Vlanif2]int vlanif 3
[sw3-2-Vlanif3]vrrp vrid 3 virtual-ip 172.16.3.254
[sw3-2-Vlanif3]vrrp vrid 3 priority 101
[sw3-2-Vlanif3]vrrp vrid 3 track int g0/0/1
  1. DHCP配置

[sw3-1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[sw3-1]ip pool v1
Info:It's successful to create an IP address pool.
[sw3-1-ip-pool-v1]network 172.16.1.0 mask 24
[sw3-1-ip-pool-v1]gateway-list 172.16.1.254
[sw3-1-ip-pool-v1]dns-list 114.114.114.114
[sw3-1-ip-pool-v1]qu
[sw3-1]ip pool v2
Info:It's successful to create an IP address pool.
[sw3-1-ip-pool-v2]network 172.16.2.0 mask 24
[sw3-1-ip-pool-v2]gateway-list 172.16.2.254
[sw3-1-ip-pool-v2]dns-list 114.114.114.114
[sw3-1-ip-pool-v2]qu
[sw3-1]int vlanif 2
[sw3-1-Vlanif2]dhcp select global
[sw3-1-Vlanif2]int vlanif 3
[sw3-1-Vlanif3]dhcp select global

[sw3-2]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[sw3-2]ip pool v1
Info:It's successful to create an IP address pool.
[sw3-2-ip-pool-v1]network 172.16.2.0 mask 24
[sw3-2-ip-pool-v1]gateway-list 172.16.2.254
[sw3-2-ip-pool-v1]dns-list 114.114.114.114
[sw3-2-ip-pool-v1]ip pool v2
Info:It's successful to create an IP address pool.
[sw3-2-ip-pool-v2]network 172.16.3.0 mask 24
[sw3-2-ip-pool-v2]gateway-list 172.16.3.254
[sw3-2-ip-pool-v2]dns-list 114.114.114.114
[sw3-2-ip-pool-v2]qu
[sw3-2]int vlan 2
[sw3-2-Vlanif2]dhcp select global
[sw3-2-Vlanif2]int vlan 3
[sw3-2-Vlanif3]dhcp select global
  1. 核心层配置
[sw3-1]vlan 10
[sw3-1-vlan10]int vlan 10
[sw3-1-Vlanif10]ip address 172.16.10.1 24
[sw3-1-Vlanif10]int g0/0/1
[sw3-1-GigabitEthernet0/0/1]port link-type access
[sw3-1-GigabitEthernet0/0/1]port default vlan 10
[sw3-1-GigabitEthernet0/0/1]qu
[sw3-1]ip route-static 0.0.0.0 0 172.16.10.2

[sw3-2]vlan 20
[sw3-2-vlan20]int vlan 20
[sw3-2-Vlanif20]ip address 172.16.20.1 24
[sw3-2-Vlanif20]int g0/0/1
[sw3-2-GigabitEthernet0/0/1]port link-type access
[sw3-2-GigabitEthernet0/0/1]port default vlan 20
[sw3-2-GigabitEthernet0/0/1]ip route-static 0.0.0.0 0 172.16.20.2

[Huawei]sysname R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip address 172.16.10.2 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip address 172.16.20.2 24
[R1-GigabitEthernet0/0/1]qu
[R1]ip route-static 172.16.2.0 24 172.16.20.1
[R1]ip route-static 172.16.2.0 24 172.16.10.1
[R1]ip route-static 172.16.3.0 24 172.16.10.1
[R1]ip route-static 172.16.3.0 24 172.16.20.1

[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip address 12.1.1.1 24

[Huawei]sysname R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[R2-GigabitEthernet0/0/0]int loopback 0
[R2-LoopBack0]ip address 1.1.1.1 24
 
设置访问控制列表,将流量放出去
[R1]acl number 2000
[R1-acl-basic-2000]rule 1 permit source 172.16.0.0 0.0.255.255
[R1-acl-basic-2000]int g0/0/2
[R1-GigabitEthernet0/0/2]nat outbound 2000
[R1-GigabitEthernet0/0/2]qu
[R1]ip route-static 0.0.0.0 0 12.1.1.2

实验结果

PC1可以ping通外网以及内网vlan的终端
在这里插入图片描述

[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]shutdown

在关闭路由器g0/0/1端口后,PC1也可以ping通外网的PC。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值