侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

交换

2023-12-11 星期一 / 0 评论 / 0 点赞 / 121 阅读 / 8968 字

enable conf t hostname int vlan 1 ip addr 192.168.1.100 255.255.255.0 no sh //设置交换机管理IP ip default

enable
conf t
hostname

int vlan 1
ip addr 192.168.1.100 255.255.255.0
no sh            //设置交换机管理IP

ip default-gateway 192.168.1.1    //设置交换机默认网关

copy running-config startup-config //保存配置文件
write

show version
show running-config
show interface
show mac-address-table

==================================================================
创建VLAN


旧版IOS常用配置vlan方法:

enable
vlan database
vlan 2 name VLAN2
exit

新版IOS常用配置vlan方法:

enable
conf t
vlan 3
name VLAN3
exit

查看vlan:交换机默认存在5个vlan(无法删除):1,1002,1003,1004,1005
show vlan

将交换机端口划分给某个vlan,例如vlan2

int fa0/1
switchport            //将交换机端口设置为交换端口
switchport mode access        //将交换端口模式设为接入模式
switchport access vlan 2    //将本端口划分给vlan2

将13-24口划分给vlan10

int range fa0/13-24        //进入fa0/13~fa0/24端口
switchport
sw m a
sw a v 10

======================================================================================================================================
中继

默认情况下中继接口允许所有vlan的数据帧通过,通常在交换机连接交换机的线路两端设置中继端口

将fa0/23和fa0/24端口设为中继端口

int range fa0/23-24
switchport
switchport trunk encapsulation dot1q    //配置中继封装方式dot1q(在三层交换机上设置中继端口必须先设置封装方式)
switchport mode trunk            //将交换端口模式设为中继模式
switchport trunk allowed vlan 2,3    //设置trunk链路仅允许vlan2和vlan3的数据帧通过
switchport trunk native vlan 2        //设置本trunk端口的native(本征)vlan为vlan2

本征vlan:native vlan的数据帧在进出trunk端口时不在帧添加vlan标记

=====================================================================================================================================
EtherChannel    以太网通道/链路聚合

手动配置以太网通道
interface port-channel 1        //创建以太网通道,编号为1
interface range fa0/23-24
channel-group 1 mode on            //将本接口加入1号以太网通道,并开启
switchport trunk encapsulation dot1q    //配置中继封装方式
switchport mode trunk             //配置端口为中继端口
port-channel load-balance dst-ip    //配置以太网通道负载均衡方式(根据目的ip进行负载均衡)

查看命令
show etherchannel summary
show etherchannel load-balance
show etherchannel port-channel
show interfaces etherchannel

使用pagp自动配置以太网通道
interface port-channel 2
interface range fa0/23-24
channel-protocol pagp            //配置以太网通道使用pagp协议自动协商
channel-group 2 mode desirable/auto    //将本接口加入2号以太网通道,同时将pagp模式设为需求/自动


使用lacp自动配置以太网通道
interface port-channel 3
interface range fa0/23-24
channel-protocol lacp            //配置以太网通道使用pagp协议自动协商
channel-group 3 mode active/passive    //将本接口加入3号以太网通道,同时将lacp模式设为主动/被动
lacp port-priority 100            //设置lacp端口优先级,数字越小优先级越高

=====================================================================================================================================
VTP    Vlan Trunking Protocol    Vlan中继协议
通过中继线路,传递vlan的配置信息。在拥有大量相同vlan配置的内网交换机的情况下,使用vtp大大简化vlan配置工作。

交换机启用VTP协议后,共有三种工作模式:
server        服务器模式    可以创建、删除、修改VLAN,也可通过中继线路获取其他服务器传递来的vlan配置信息
client        客户端模式    不可创建、删除、修改VLAN,但可通过中继线路获取服务器传递来的vlan配置信息
transparent    透明模式    可以创建、删除、修改VLAN,但对通过中继线路传递过来的vlan配置信息不接受但会传递

show vtp status        查看vtp状态信息

vtp domain TEST-DOMAIN            设置vtp域名
vtp mode server/client/transparent    设置交换机的vtp工作模式为服务器/客户机/透明
vtp password cisco            设置vtp密码为cisco
vtp version 2                设置vtp协议版本为2(只能在server上配置)

======================================================================================================================================
STP    Spanning Tree Protocol    生成树协议
通过阻断一些交换机的某些端口,构建一棵没有环路的转发树,解决交换环路带来的问题。

PVST    per vlan spanning tree        每vlan生成树协议
RSTP    rapid spanning tree protocol    快速生成树协议

stp的工作过程
1、选举根桥        优先级最低的交换机成为根桥,优先级相同时mac地址最小的交换机成为根桥
2、选举根端口        根交换机上的端口默认为根端口,链路另一端为制定端口
3、选取指定端口        优先级较低的交换机端口为指定端口,优先级相同情况下mac地址较小的交换机端口为指定端口

spanning-tree vlan 1 priority 4096    //将交换的vlan1桥优先级设为4096(默认是32768)
spanning-tree vlan 1 root secondary

int fa0/24
spanning-tree vlan 1 cost 18        //将fa0/24端口cost值设为18
spanning-tree vlan 1 port-priority 112    //将fa0/24端口优先级设为112(默认128)

portfast    端口快速启动

int fa0/1
spanning-tree portfast

uplinkfast    上联链路快速启动
全局配置
spanning-tree uplinkfast


backbonefast    主干链路快速启动
全局配置
spanning-tree backbonefast


======================================================================================================================================
清除交换机配置

enable            
delete flash:vlan.dat    删除flash下的vlan数据库文件
erase startup-config    擦除启动配置文件
reload            重新启动交换机

清除路由器配置

enable            
erase startup-config    擦除启动配置文件
reload            重新启动交换机

 

配置全双工与半双工及交换机接口速率


进入接口

duplex full/half/auto  //全双工/半双工、自动检测双工模式

speed(auto)   //配置接口速率,自动检测接口速率

midx auto // 可以启用介质检测功能


配置默认网关

ip default-gateway 192.168.1.1 //

int range f0/1 -12  //批量配置 f0/1-f0/12

配置交换机端口安全之静态安全mac地址

switch mode access
switch port-security

 

广告 广告

评论区