目录
编辑
一,交换层面的配置
1.channel
2.vlan
3.trunk
二,配置路由
R1
R2
LW1
LW2
三,OSPF
四,能够访问外网操作
一,交换层面的配置
配置顺序 channel vlan trunk stp svi vrrp dhcp
1.channel
LW1
[lw1]interface Eth-Trunk 0
[lw1-Eth-Trunk0]int g0/0/5
[lw1-GigabitEthernet0/0/5]eth-trunk 0
[lw1-Eth-Trunk0]int g0/0/4
[lw1-GigabitEthernet0/0/4]eth-trunk 0
LW2
[lw2]interface Eth-Trunk 0
[lw2-Eth-Trunk0]int g0/0/5
[lw2-GigabitEthernet0/0/5]eth-trunk 0
[lw-Eth-Trunk0]int g0/0/4
[lw2-GigabitEthernet0/0/4]eth-trunk 0
2.vlan
LW1
[lw1]vlan 2
LW2
[lw2]vlan 2
LW3
[lw3]vlan 2
LW4
[lw4]vlan 2
3.trunk
LW1
没有连接PC所以不用划分vlan
[lw1]port-group group-member g0/0/2 to g0/0/3 Eth-Trunk 0
[lw1-port-group]port link-type trunk
[lw1-port-group]port trunk allow-pass vlan all
LW2
没有连接PC所以不用划分vlan
[lw2]port-group group-member g0/0/2 to g0/0/3 Eth-Trunk 0
[lw2-port-group]port link-type trunk
[lw2-port-group]port trunk allow-pass vlan all
LW3
划分接口
[lw3]int g0/0/2
[lw3-GigabitEthernet0/0/2]port link-type access
[lw3-GigabitEthernet0/0/2]port default vlan 2
[lw3-GigabitEthernet0/0/2]int g0/0/3
[lw3-GigabitEthernet0/0/3]port link-type access
[lw3-GigabitEthernet0/0/3]port default vlan 2创建trunk干道
[lw3-GigabitEthernet0/0/3]int g0/0/1
[lw3-GigabitEthernet0/0/1]port link-type trunk
[lw3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[lw3-GigabitEthernet0/0/1]int g0/0/4[lw3-GigabitEthernet0/0/4]port link-type trunk
[lw3-GigabitEthernet0/0/4]port trunk allow-pass vlan all
LW4
划分接口
[lw4]int g0/0/2
[lw4-GigabitEthernet0/0/2]port link-type access
[lw4-GigabitEthernet0/0/2]port default vlan 2
[lw4-GigabitEthernet0/0/2]int g0/0/3
[lw4-GigabitEthernet0/0/3]port link-type access
[lw4-GigabitEthernet0/0/3]port default vlan 2创建trunk干道
[lw4-GigabitEthernet0/0/3]int g0/0/1
[lw4-GigabitEthernet0/0/1]port link-type trunk
[lw4-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[lw4-GigabitEthernet0/0/1]int g0/0/4[lw4-GigabitEthernet0/0/4]port link-type trunk
[lw4-GigabitEthernet0/0/4]port trunk allow-pass vlan all
4.STP
LW1
启动stp服务
[lw1]stp enable
[lw1]stp region-configuration
[lw1-mst-region]region-name a划分vlan到组
[lw1-mst-region]instance 1 vlan 1[lw1-mst-region]instance 2 vlan 2
[lw1-mst-region]q一定要激活配置
[lw1-mst-region]active region-configuration
创建备份根 组1中当主根,在组2中当备份根
[lw1]stp instance 1 root primary
[lw1]stp instance 2 root secondary
多vlan划入到组 操作
[lw1-mst-region]instance 2 vlan 2 to vlan 50
LW2
启动stp服务
[lw2]stp enable
[lw2]stp region-configuration
[lw2-mst-region]region-name a划分vlan到组
[lw2-mst-region]instance 1 vlan 1
[lw2-mst-region]instance 2 vlan 2一定要激活配置
[lw2-mst-region]active region-configuration
[lw2-mst-region]q创建备份根 组2中当主根,在组1中当备份根
[lw2]stp instance 1 root secondary
[lw2]stp instance 2 root primary
LW3
划分vlan到组
[lw3]stp enable
[lw3]stp region-configuration
[lw3-mst-region] region-name a
[lw3-mst-region] instance 1 vlan 1
[lw3-mst-region] instance 2 vlan 2一定要激活配置
[lw3-mst-region] active region-configuration优化连接PC接口
[lw3]port-group group-member g0/0/2 to g0/0/3
[lw3-port-group]stp edged-port
注意:接口连接WiFi6时接口配置
[lw3-GigabitEthernet0/0/2]stp instance 1 port priority 128
LW4
划分vlan到组
[lw4]stp enable
[lw4]stp region-configuration
[lw4-mst-region]region-name a
[lw4-mst-region]instance 1 vlan 1
[lw4-mst-region]instance 2 vlan 2一定要激活配置
[lw4-mst-region] active region-configuration
优化连接PC接口
[lw4]port-group group-member g0/0/2 to GigabitEthernet 0/0/3
[lw4-port-group]stp edged-port enable
5.SVI
LW1
[lw1]interface Vlan 1
[lw1-Vlanif1]ip add 172.16.1.1 25
[lw1-Vlanif1]int vlan 2
[lw1-Vlanif2]ip add 172.16.1.129 25
LW2
[lw2]interface Vlan 1
[lw2-Vlanif1]ip add 172.16.1.2 25
[lw2-Vlanif1]int vlan 2
[lw2-Vlanif2]ip add 172.16.1.130 25
6.VRRP
LW1
虚拟网关
[lw1]interface Vlanif 1
[lw1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126修改优先级
[lw1-Vlanif1]vrrp vrid 1 priority 105上行链路追踪
[lw1-Vlanif1]vrrp vrid 1 track interface GigabitEthernet 0/0/1进入vlan2做备份
[lw1]interface Vlanif 2
[lw1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254
LW2
虚拟网关
[lw2]interface Vlanif 2
[lw2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254修改优先级
[lw2-Vlanif2]vrrp vrid 1 priority 105上行链路追踪
[lw2-Vlanif2]vrrp vrid 1 track interface GigabitEthernet 0/0/1进入vlan1做备份
[lw2]interface Vlanif 1
[lw2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
7.DHCP
LW1
[lw1]dhcp enable
[lw1]ip pool vlan1
[lw1-ip-pool-vlan1]network 172.16.1.0 mask 25
[lw1-ip-pool-vlan1]gateway-list 172.16.1.126 虚拟网关[lw1]ip pool vlan2
[lw1-ip-pool-vlan2]network 172.16.1.128 mask 25
[lw1-ip-pool-vlan2]gateway-list 172.16.1.254 虚拟网关
[lw1]interface Vlanif 1
[lw1-Vlanif1]dhcp select global
[lw1]interface Vlanif 2
[lw1-Vlanif2]dhcp select global
LW2
[lw2]dhcp enable
[lw2]ip pool vlan1
[lw2-ip-pool-vlan1]network 172.16.1.0 mask 25
[lw2-ip-pool-vlan1]gateway-list 172.16.1.126 虚拟网关[lw2]ip pool vlan2
[lw2-ip-pool-vlan2]network 172.16.1.128 mask 25
[lw2-ip-pool-vlan2]gateway-list 172.16.1.254 虚拟网关
[lw2]interface Vlanif 1
[lw2-Vlanif1]dhcp select global
[lw2]interface Vlanif 2
[lw2-Vlanif2]dhcp select global
注意:LW2的dhcp的配置可以直接复制LW1的配置
二,配置路由
R1
[r1]int l0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1-LoopBack0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
R2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 172.16.0.1 30
[r2-GigabitEthernet0/0/1]int g0/0/2
[r2-GigabitEthernet0/0/2]ip add 172.16.0.5 30
LW1
[lw1]vlan 99
[lw1-vlan99]q
[lw1-GigabitEthernet0/0/1]port link-type a
[lw1-GigabitEthernet0/0/1]port default vlan 99
[lw1-GigabitEthernet0/0/1]q
[lw1]interface Vlanif 99
[lw1-Vlanif99] ip add 172.16.0.2 30
LW2
[lw2]vlan 99
[lw2-GigabitEthernet0/0/1]port link-type access
[lw2-GigabitEthernet0/0/1]port default vlan 99
[lw2-GigabitEthernet0/0/1]int v99
[lw2-Vlanif99]ip add 172.16.0.6 30
三,OSPF
R2
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 172.16.0.1 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 172.16.0.5 0.0.0.0
LW1
[lw1]ospf 1 router-id 3.3.3.3
[lw1-ospf-1]ar
[lw1-ospf-1]area 1
[lw1-ospf-1-area-0.0.0.1]network 172.16.1.1 0.0.0.0
[lw1-ospf-1-area-0.0.0.1]network 172.16.1.129 0.0.0.0[lw1-ospf-1-area-0.0.0.1]area 0
[lw1-ospf-1-area-0.0.0.0]network 172.16.0.2 0.0.0.0[lw1-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0
LW2
[lw2]ospf 1 router-id 4.4.4.4
[lw2-ospf-1]area 1
[lw2-ospf-1-area-0.0.0.1]network 172.16.1.2 0.0.0.0
[lw2-ospf-1-area-0.0.0.1]network 172.16.1.130 0.0.0.0[lw2-ospf-1-area-0.0.0.1]area 0
[lw2-ospf-1-area-0.0.0.0]network 172.16.0.6 0.0.0.0[lw2-ospf-1-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0
也可以使用静态路由获取路由
四,能够访问外网操作
R2
缺省路由:
[r2]ip route-static 0.0.0.0 0 12.1.1.1
[r2-ospf-1]default-route-advertise写规则
[r2]acl 2000
[r2-acl-basic-2000]rule permit source any
[r2-acl-basic-2000]int g0/0/0
[r2-GigabitEthernet0/0/0]nat outbound 2000