mstp的配置有哪些
‘壹’ 锐捷MSTP配置
交换机
密码
1234(config)#enable secret level 1 0 100
1234(config)#enable secret level 15 0 100
远程登入密码
1234(config)#line vty 0 4
1234(config-line)#password 100
1234(config-line)#end
交换机管理IP
1234(config)#interface vlan 1
1234(config-if)#ip address 192.168.1.10 255.255.255.0
1234(config-if)#no shutdown
修改交换机老化时间
1234(config)#mac-address-table aging-time 20
1234(config)#end
添删vlan
1234(config)#vlan 888
1234(config-vlan)#name a888
1234(config)#no vlan 888
添加access口
1234(config)#interface gigabitEthernet 0/10
1234(config-if)#switchport mode access
1234(config-if)#switchport access vlan 10
切换assess trunk
1234(config-if)#switchport mode access
1234(config-if)#switchport mode trunk
指定特定一个native vlan
1234(config-if)#switchport trunk native vlan 10
配置trunk口的许可vlan列表
1234(config-if)#switchport trunk allowed vlan ?
add Add VLANs to the current list
all All VLANs
except All VLANs except the following
remove Remove VLANs from the current list
速成树协议
1234(config)#spanning-tree
1234(config)#spanning-tree mode rstp/stp
配置网关:
switch(config)#ip default-gateway 192.168.1.254
交换机基本配置-常见查看命令
查看CPU利用率
show cpu
查看交换机时钟
show clock
查看交换机日志
show logging
查看交换机动态学习到的MAC地址表
show mac-address-table dynamic
查看当前交换机运行的配置文件
show running-config
查看交换机硬件、软件信息
show version
查看交换机的arp表
show arp
显示接口详细信息的命令
show interfaces gigabitEthernet 4/1 counters
接口配置
Switch(config)#interface gigabitethernet 0/1
把接口工作模式改为光口。
Switch(config-if)#medium-type fiber
把接口工作模式改为电口。
Switch(config-if)#medium-type copper
速度/双工配置
进入接口配置模式。
Switch(config)#interface interface-id
设置接口的速率参数,或者设置为auto。
Switch(config-if)#speed {10 | 100 | 1000 | auto }
设置接口的双工模式。
Switch(config-if)#plex {auto | full | half}
例子
Switch(config)#interface gigabitethernet 0/1
Switch(config-if)#speed 1000
Switch(config-if)#plex full
光口不能修改速度和双工配置,只能auto。
在故障处理的时候,如果遇到规律性的时断时续或掉包,在排除其他原因后,可以考虑是否和对端设备的速率和双工模式不匹配,尤其是两端设备为不同厂商的时候。
VLAN
建立VLAN 100
Switch (config)#vlan 100
该VLAN名称为ruijie
Switch (config)#name ruijie
将交换机接口划入VLAN 中:
range表示选取了系列端口1-48,这个对多个端口进行相同配置时非常有用。
Switch (config)#interface range f 0/1-48
将接口划到VLAN 100中。
Switch (config-if-range)#switchport access vlan 100
将接口划回到默认VLAN 1中,即端口初始配置。
Switch (config-if-range)#no switchport access vlan
Switch(config)#interface fastEthernet 0/1
该端口工作在access模式下
Switch(config-if)#switchport mode access
该端口工作在trunk模式下
Switch(config-if)#switchport mode trunk
Switch(config)#interface fastEthernet 0/2
设定VLAN要修剪的VLAN。
Switch(config-if)#switchport trunk allowed vlan remove 2-9,11-19,21-4094
取消端口下的VLAN修剪。
Switch(config-if)#no switchport trunk allowed vlan
生成树
开启生成树协议。
Switch(config)#spanning-tree
禁止生成树协议。
Switch(config)#no spanning-tree
配置生成树优先级:
配置设备优先级为4096。
Switch(config)#spanning-tree priority 4096
数值越低,优先级别越高。
端口镜像
配置G0/2为镜像端口。
Switch (config)# monitor session 1 destination interface G 0/2
配置G0/1为被镜像端口,且出入双向数据均被镜像。
Switch (config)# monitor session 1 source interface G 0/1 both
去掉镜像1。
Switch (config)# no monitor session 1
端口聚合
Switch(config)#interface fastEthernet 0/1
把端口f0/1加入到聚合组1中。
Switch (config-if)#port-group 1
把端口f0/1从聚合组1中去掉
Switch (config-if)#no port-group 1
建立ACL:
建立ACL访问控制列表名为ruijie,extend表示建立的是扩展访
Switch(config)# Ip access-list exten ruijie
问控制列表。
添加ACL的规则:
禁止PING IP地址为192.168.1.1的设备。
Switch (config-ext-nacl)#deny icmp any 192.168.1.1 255.255.255.0
禁止端口号为135的应用。
Switch (config-ext-nacl)# deny tcp any any eq 135
禁止协议为www的应用。
Switch (config-ext-nacl)#deny udp any any eq www
允许所有行为。
Switch(config-ext-nacl)# permit ip any any
将ACL应用到具体的接口上:
Switch (config)#interface range f 0/1
把名为ruijie的ACL应用到端口f 0/1上。
Switch (config-if)#ip access-group ruijie in
从接口去除ACL。
Switch (config-if)#no ip access-group ruijie in
删除ACL:
删除名为ruijie的ACL。
Switch(config)#no Ip access-list exten ruijie
增加ACE项后,是增加到ACL最后,不可以中间插入,如果要调整ACE的顺序,必须整个删除ACL后再重新配置。
端口安全
Switch (config)#interface range f 0/1
开启端口安全。
Switch(config-if)# switchport port-security
关闭端口安全。
Switch(config-if)# no switchport port-security
设置端口能包含的最大安全地址数为8。
Switch(config-if)# switchport port-security maximum 8
在接口fastethernet0/1配置一个安全地址00d0.f800.073c,并为其绑定一个IP地址192.168.1.1
Switch(config-if)# switchport port-security mac-address 00d0.f800.073c ip-address 192.168.1.1
删除接口上配置的安全地址。
Switch(config-if)#no switchport port-security mac-address 00d0.f800.073c ip-address 192.168.1.1
防ARP攻击
IP和MAC地址的绑定
Switch(config)#arp ip-address hardware-address [type] interface-id
Switch(config)#arp 192.168.12.111 00d0.f800.073c arpa g 0/1
绑定网关
进入指定端口进行配置。
Switch(config)#Interface interface-id
配置防止ip-address的ARP欺骗。
Switch(config-if)#Anti-ARP-Spoofing ip ip-address
防STP攻击
进入端口Fa0/1。
Switch(config)# inter fastEthernet 0/1
打开该端口的的BPDU guard功能。
Switch(config-if)# spanning-tree bpguard enable
关闭该端口的的BPDU guard功能。
Switch(config-if)# spanning-tree bpguard diaable
端口关闭后只能shutdown然后再no shutdown
或者重新启动交换机才能恢复!
防DOS/DDOS攻击
进入端口Fa0/1。
Switch(config)# inter fastEthernet 0/1
预防伪造源IP的DOS攻击的入口过滤功能。
Switch(config-if)#ip deny spoofing-source
关闭入口过滤功能只能在三层接口上配置。
Switch(config-if)#no ip deny spoofing-source
和ACL不能同时存在。
端口关闭后只能shutdown然后再no shutdown
或者重新启动交换机才能恢复!
防IP扫描攻击配置:
打开系统保护。
Switch(config)#system-guard enable
关闭系统保护功能。
Switch(config)#no system-guard
DHCP配置
打开DHCP Relay Agent:
Switch(config)#service dhcp
配置DHCP Server的IP地址:
Switch(config)#ip helper-address address
VRRP配置
Switch(config)#Interface interface-id
Switch(config-if)#Standby [group-number] ip ip-address
设置虚拟机的优先级。
standby [group-number] priority priority
三层交换机配置
SVI:
把VLAN 10配置成SVI。
switch (config)#interface vlan 10
给该SVI接口配置一个IP地址
switch (config-if)#ip address 192.168.1.1 255.255.255.0
Routed Port:
switch (config)#interface fa 0/1
把f 0/1变成路由口。
switch (config-if)#no switch
路由配置:
添加一条路由。
switch (config)#ip route 目的地址 掩码 下一跳
switch (config)#ip route 210.10.10.0 255.255.255.0 218.8.8.8
‘贰’ 华为交换机配置vrrp、mstp综合实验
;
1.PC1的网关ip位于汇聚交换机凳缺A,PC2的网关IP位于汇聚交换机B,默认均为vlan 1;
2.核心交换机A 与核心交换机B 采用VRRP实现高可用,双机互联端口采用二层聚合;
3.核心交换机A 指定为Vlan 194 和 vlan 192 的根桥(bridge root),核心交换机B指定为vlan195 和vlan193的根桥(bridge root);
汇聚层交换机A:
#生成树的模式选为mstp
stp mode mstp
#进入生成树的配置模式
stp region-configuration
region-name yongfu
#创建实例1,将vlan192、194划到实例1中
instance 1 vlan 192 194
#创建实例1,将vlan193、195划到实例2中
instance 2 vlan 193 195
#激活配置
active region-configuration
interface Vlanif1
#接入层交换机的网关ip
ip address 10.12.192.254 255.255.255.128
interface Vlanif192
ip address 10.13.192.156 255.255.255.248
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#配置环枣茄辩回接口的IP地址
interface LoopBack0
ip address 1.1.1.1 255.255.255.0
#配置route-id 1.1.1.1
ospf 1 router-id 1.1.1.1
area 0
#宣告直连网络
network 10.13.192.0 0.0.0.255
network 10.12.192.128 0.0.0.127
汇聚层交换机B:纳空
vlan batch 193
stp mode mstp
stp region-configuration
region-name yongfu
instance 1 vlan 192 194
instance 2 vlan 193 195
active region-configuration
interface Vlanif1
#pc2的网关ip
ip address 10.14.192.126 255.255.255.128
interface Vlanif193
ip address 10.13.193.156 255.255.255.248
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 193
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan 193
#配置ospf,手动设置route-id
ospf 1 router-id 2.2.2.2
area 0
#宣告直连网段
network 10.14.192.0 0.0.0.127
network 10.13.193.152 0.0.0.7
核心交换机lsw1:
#创建vlan192-195
vlan batch 192 to 195
#指定该交换机为实例1的根网桥(即为vlan 192、194的根桥)
stp instance 1 root primary
#指定该交换机为实例2的根网桥(即为vlan 193、195的备根桥)
stp instance 2 root secondary
#配置mstp生成树协议
stp mode mstp
stp region-configuration
region-name yongfu
instance 1 vlan 192 194
instance 2 vlan 193 195
active region-configuration
interface Vlanif192
ip address 10.13.192.153 255.255.255.248
#配置vrrp协议,vrid为192,虚拟网关地址为10.13.192.155
vrrp vrid 192 virtual-ip 10.13.192.155
#默认优先级是100,现将优先级设置为120,为主网关设备
vrrp vrid 192 priority 120
interface Vlanif193
ip address 10.13.193.153 255.255.255.248
#不配置优先级,默认为100,作为备用网关
vrrp vrid 193 virtual-ip 10.13.193.155
interface Vlanif194
ip address 10.13.194.1 255.255.255.248
vrrp vrid 194 virtual-ip 10.13.194.3
vrrp vrid 194 priority 120
interface Vlanif195
ip address 10.13.195.1 255.255.255.248
vrrp vrid 195 virtual-ip 10.13.195.3
#配置聚合口
interface Eth-Trunk1
port link-type trunk
#放通所有vlan
port trunk allow-pass vlan 2 to 4094
#将接口划分为对应的vlan
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 192
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 193
#将GigabitEthernet0/0/3、GigabitEthernet0/0/4捆绑成一个聚合口
interface GigabitEthernet0/0/3
eth-trunk 1
interface GigabitEthernet0/0/4
eth-trunk 1
interface GigabitEthernet0/0/5
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/6
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#配置ospf,进程号为1,route-id为3.3.3.3
ospf 1 router-id 3.3.3.3
area 0.0.0.0
#宣告直连网段
network 10.13.192.152 0.0.0.7
network 10.13.193.152 0.0.0.7
network 10.13.194.0 0.0.0.7
network 10.13.195.0 0.0.0.7
ip route-static 19.130.107.0 255.255.255.192 10.13.194.5
核心交换机lsw2:(配置与lsw1相似)
#创建vlan192-195
vlan batch 192 to 195
stp mode mstp
stp instance 2 root primary
stp instance 1 root secondary
stp region-configuration
region-name yongfu
instance 1 vlan 192 194
instance 2 vlan 193 195
active region-configuration
#配置个接口的ip地址,配置vrrp,设置主、备网关
interface Vlanif192
ip address 10.13.192.154 255.255.255.248
vrrp vrid 192 virtual-ip 10.13.192.155
interface Vlanif193
ip address 10.13.193.154 255.255.255.248
vrrp vrid 193 virtual-ip 10.13.193.155
vrrp vrid 193 priority 120
interface Vlanif194
ip address 10.13.194.2 255.255.255.248
vrrp vrid 194 virtual-ip 10.13.194.3
interface Vlanif195
ip address 10.13.195.2 255.255.255.248
vrrp vrid 195 virtual-ip 10.13.195.3
vrrp vrid 195 priority 120
interface Eth-Trunk1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 192
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 193
interface GigabitEthernet0/0/3
eth-trunk 1
interface GigabitEthernet0/0/4
eth-trunk 1
interface GigabitEthernet0/0/5
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/6
port link-type trunk
port trunk allow-pass vlan 2 to 4094
交换机lsw14:
vlan batch 194
stp mode mstp
stp region-configuration
region-name yongfu
instance 1 vlan 192 194
instance 2 vlan 193 195
active region-configuration
interface Vlanif1
ip address 10.13.192.133 255.255.255.252
interface Vlanif194
ip address 10.13.194.5 255.255.255.248
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 194
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan 194
#配置ospf,进程号为1,route-id 5.5.5.5
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 10.13.194.0 0.0.0.7
network 10.13.192.132 0.0.0.3
ip route-static 19.130.107.0 255.255.255.0 10.13.192.134
交换机lsw15:
vlan batch 195
stp mode mstp
stp region-configuration
region-name yongu
instance 1 vlan 192 194
instance 2 vlan 193 195
active region-configuration
interface Vlanif1
ip address 10.13.192.149 255.255.255.252
interface Vlanif195
ip address 10.13.195.5 255.255.255.248
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 195
interface Ethernet0/0/2
port link-type trunk
port trunk allow-pass vlan 195
ospf 1 router-id 6.6.6.6
area 0.0.0.0
network 10.13.192.148 0.0.0.3
network 10.13.195.0 0.0.0.7
ip route-static 61.142.211.0 255.255.255.0 10.13.192.150
出口路由器R1:
interface Ethernet0/0/0
ip address 10.13.192.134 255.255.255.252
interface Ethernet0/0/1
ip address 19.130.107.1 255.255.255.0
ospf 1 router-id 7.7.7.7
area 0.0.0.0
network 10.13.192.132 0.0.0.3
network 19.130.107.0 0.0.0.255
ip route-static 0.0.0.0 0.0.0.0 10.13.192.133
出口路由器R2:
interface Ethernet0/0/0
ip address 10.13.192.150 255.255.255.252
interface Ethernet0/0/1
interface GigabitEthernet0/0/0
ip address 61.142.211.122 255.255.255.0
nat static global 61.142.211.123 inside 10.12.194.1 netmask 255.255.255.255
nat static enable
ospf 1 router-id 8.8.8.8
area 0.0.0.0
network 10.13.192.148 0.0.0.3
network 61.142.211.0 0.0.0.255
ip route-static 0.0.0.0 0.0.0.0 10.13.192.149