目录
实验需求
1、内网IP地址172.16.0.0/16合理分配
2、SW1/2之间互为备份
3、VRRP/STR/VLAN/TRUNK均使用
4、所有通过DHCP获取ip地址
实验拓扑
实验配置
1.创建vlan
并将创建好的vlan加入到对应的接口
[sw1]vlan 2
interface GigabitEthernet0/0/4
port link-type trunk
port trunk allow-pass vlan 2
interface GigabitEthernet0/0/5
port link-type trunk
port trunk allow-pass vlan 2
[sw2]vlan 2
interface GigabitEthernet0/0/4
port link-type trunk
port trunk allow-pass vlan 2
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 5
[sw3]vlan 2
interface Ethernet0/0/2
port link-type access
port default vlan 2
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2
[sw4]vlan 2
interface Ethernet0/0/2
port link-type access
port default vlan 2
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2
2.用以太网中继技术配置通道
将sw1与sw2的g0/0/2和g0/0/3接口逻辑上整合为一个接口,实现带宽叠加的效果
配置要求:
- 通道的对端必须为同一台设备;
- 通道的所有物理接口应该具有相同的速率、双工模式;相同的类型,相同的vlan允许列表;
[sw1]interface Eth-Trunk 0
[sw1-Eth-Trunk0]dis th
#
interface Eth-Trunk0
port link-type trunk
port trunk allow-pass vlan 2
#
[sw1-Eth-Trunk0]int g0/0/2
[sw1-GigabitEthernet0/0/2] eth-trunk 0
[sw1-GigabitEthernet0/0/2]int g0/0/3
[sw1-GigabitEthernet0/0/3]eth-trunk 0
[sw2]interface Eth-Trunk 0
[sw2-Eth-Trunk0]dis th
#
interface Eth-Trunk0
port link-type trunk
port trunk allow-pass vlan 2
#
[sw2-Eth-Trunk0]int g0/0/2
[sw2-GigabitEthernet0/0/2] eth-trunk 0
[sw2-GigabitEthernet0/0/2]int g0/0/3
[sw2-GigabitEthernet0/0/3]eth-trunk 0
3. 使用mstp协议定义主备根
其中sw1为组1的主根组2的备份根,sw2为组2的主根组1的备份根
[sw1]stp enable
[sw1]stp region-configuration
[sw1-mst-region]region-name a 所有设备应在一个组内
[sw1-mst-region]instance 1 vlan 1
[sw1-mst-region]instance 2 vlan 2
[sw1-mst-region]active region-configuration 激活当前配置
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary
[sw2]stp enable
[sw2]stp region-configuration
[sw2-mst-region]region-name a 所有设备应在一个组内
[sw2-mst-region]instance 1 vlan 1
[sw2-mst-region]instance 2 vlan 2
[sw2-mst-region]active region-configuration 激活当前配置
[sw2]stp instance 2 root primary
[sw2]stp instance 1 root secondary
[sw3]stp enable
[sw3]stp region-configuration
[sw3-mst-region]region-name a
[sw3-mst-region]instance 1 vlan 1
[sw3-mst-region]instance 2 vlan 2
[sw3-mst-region]active region-configuration
[sw4]stp enable
[sw4]stp region-configuration
[sw4-mst-region]region-name a
[sw4-mst-region]instance 1 vlan 1
[sw4-mst-region]instance 2 vlan 2
[sw4-mst-region]active region-configuration
4.配置网关冗余
1.在sw1和sw2中创建vlan1和vlan2的svi
2.使用VRRP 协议配置虚拟网关和定义主备设备
vlan1的网关冗余
sw1
[sw1]int vlanif1
[sw1-Vlanif1] ip address 172.16.1.254 255.255.255.0
[sw1-Vlanif1] vrrp vrid 1 virtual-ip 172.16.1.250
[sw1-Vlanif1]vrrp vrid 1 priority 120
[sw1-Vlanif1] vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 21
sw2
[sw2]int vlanif1
[sw2-Vlanif1] ip address 172.16.1.253 255.255.255.0
[sw2-Vlanif1] vrrp vrid 1 virtual-ip 172.16.1.250
vlan2的网关冗余
sw2
[sw2]int vlanif2
[sw2-Vlanif2] ip address 172.16.2.253 255.255.255.0
[sw2-Vlanif2] vrrp vrid 2 virtual-ip 172.16.2.250
[sw2-Vlanif2]vrrp vrid 2 priority 120
[sw2-Vlanif2] vrrp vrid 2 track interface GigabitEthernet0/0/1 reduced 21
sw1
[sw1]int vlanif2
[sw1-Vlanif2] ip address 172.16.2.254 255.255.255.0
[sw1-Vlanif2] vrrp vrid 2 virtual-ip 172.16.2.250
5.配置dhcp
需要在sw1和sw2上都要为vlan1和vlan2配置dhcp
网关设为VRRP创建的虚拟网关
sw1上配置dhcp
[sw1]dhcp enable
[sw1]ip pool v1
#
ip pool v1
gateway-list 172.16.1.250
network 172.16.1.0 mask 255.255.255.0
dns-list 114.114.114.114
#
return
[sw1-Vlanif1]dhcp select global
[sw1]ip pool v2
#
ip pool v2
gateway-list 172.16.2.250
network 172.16.2.0 mask 255.255.255.0
dns-list 114.114.114.114
#
return
[sw1-Vlanif2]dhcp select global
sw2上配置dhcp
[sw2]dhcp enable
[sw2]ip pool v1
#
ip pool v1
gateway-list 172.16.1.250
network 172.16.2.0 mask 255.255.255.0
dns-list 114.114.114.114
#
return
[sw2-Vlanif1]dhcp select global
[sw2]ip pool v2
#
ip pool v2
gateway-list 172.16.2.250
network 172.16.2.0 mask 255.255.255.0
dns-list 114.114.114.114
#
return
[sw2-Vlanif2]dhcp select global
6.配置路由接口ip
1.使用svi给sw1和sw2的上行链路g0/0/1接口配置ip
sw1
[sw1]vlan 3
[sw1-vlan3]int vlanif 3
[sw1-Vlanif3]ip address 172.16.0.2 255.255.255.252
[sw1-Vlanif3]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 3
sw2
[sw2]vlan 3
[sw2-vlan3]int vlanif 3
[sw2-Vlanif3]ip address 172.16.0.6 255.255.255.252
[sw2-Vlanif3]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 3
2.配置r1的接口ip
7.sw1/2和r1启用ospf获取路由
[r1]ospf 1
[r1-ospf-1]dis th
[V200R003C00]
#
ospf 1 router-id 1.1.1.1
default-route-advertise #边界路由下发缺省
area 0.0.0.0
network 172.16.0.1 0.0.0.0
network 172.16.0.5 0.0.0.0
#
return
[sw1]ospf 1
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 172.16.0.2 0.0.0.0
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
#
return
[sw2]ospf 1
#
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 172.16.0.6 0.0.0.0
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
#
return
8.配置公网环境
8.1 配置公网ip
如拓扑所示
8.2 r1写到公网的静态缺省
[r1]ip route-static 0.0.0.0 0.0.0.0 12.1.1.2
验证
1. PC1访问PC3和PC4
2.PC1访问PC2,中途关闭sw1,测试网关冗余
3.pc1访问公网
4.pc2访问公网,中途关闭sw2,测试网关冗余
game over