文档库 最新最全的文档下载
当前位置:文档库 › 思科模拟器基本命令(交换机)

思科模拟器基本命令(交换机)

思科模拟器基本命令(交换机)
思科模拟器基本命令(交换机)

知识归纳

思科模拟器命令:

设置交换机名字为yzh

Switch> 进入超级终端控制台

Switch>enable 进入交换机特权模式

Switch#

Switch#configure terminal 进入交换机全局配置模式

Switch(configure)#hostname yzh 改变名字为XXX

yzh(configure)# 显示改名成功

yzh(configure)#exit 退回上级操作模式,即返回特权模式

yzh#

yzh#exit 返回到用户模式

yzh>

参看交换机有关信息

yzh#

yzh#configure terminal 进入交换机全局配置模式

yzh#show version 查看交换机的版本信息

yzh#show vlan 查看交换机的VLAN信息,默认情况下所有借口均属于VLAN yzh#show running-config 查看交换机当前生效的配置信息

配置交换机接口f0/2

yzh>

yzh>enable

yzh#

yzh#configure terminal 进入交换机配置模式

yzh(config)#interface fastEthernet 0/2 进入交换机接口fa0/2

yzh(config-if)# 进入接口配置模式

yzh(config-if)#speed 100 设置接口F0/2速率为100M

yzh(config-if)#duplex half 配置接口的双工模式是半双工

yzh(config-if)#no shutdown 开启接口,使得处于工作状态,等待转发数据。yzh(config-if)#exit 输入exit返回全局模式

yzh(config)#exit 返回特权模式

yzh# 位于特权模式

yzh#show interfaces fastEthernet 0/2 查看刚才对接口f0/2配置情况

设置交换机Enable特权密码为admin

yzh> 进入超级终端控制台

yzh>enable 进入交换机特权模式

yzh#configure terminal 进入交换机配置模式

yzh(config)#enable secret admin 设置Enable密码为admin

注:验证密码自己思考。

查看设备配置信息

yzh#show running-config

保存配置信息

yzh#write 保存设置配置,把配置指令写入对到系统文件夹中yzh#dir 查看系统文件

删除配置,恢复初始配置

yzh#

yzh#dir 查看系统文件

yzh#delete? 输入“?”号,获得帮助

yzh#delete flash:config.txt 删除配置文件

系统就恢复了出厂配置

三层交换机与二层交换机的大多数都相同。

配置三层交换机的名称为SW3,enable密码为admin,并且配置与远程登陆相关的选项。Switch>enable 进入交换机特权模式

Switch#configure terminal 进入交换机全局模式

Swirch(config)#hostname yzh 修改交换机名称

Yzh(config)#enable password admin 设置交换机enable密码为admin

Yzh(config)#interface vlan1 进入vlan1

Yzh(config-if-VLAN1)#ip address 192.168.1.1 255.255.255.0 配置IP地址

yzh(config-if-VLAN1)#exit 退出配置vlan1

yzh(config)#username admin password admin 配置登陆交换机的用户名与密码

yzh(config)#line vty 0 4 进入vty端口配置

yzh(config-line)#login local 配置vty端口使用本地数据库验证

yzh(config-line)#exit 退出vty端口配置

yzh(config)# 配置OK

保存三层交换机配置。

SW3#write

配置三层交换机名称与VLAN

yzh>enable 进入交换机特权模式

yzh#configure terminal 进入交换机全局模式

yzh(config)#hostname YZH 修改交换机名称为YZH

YZH(config)#vlan10 创建vlan10

YZH(config-vlan)#vlan20 创建vlan20

YZH(config-vlan)#exit

YZH(config)#interface range fastEthernet 0/1-10 进入fa/1-10端口

YZH(config-if-range)#switchport access vlan10 划分fa/1-10端口为vlan10 YZH(config-if-range)exit

YZH(config)#interface range fastEthernet 0/11-20 进入fa/11-20端口

YZH(config-if-range)#switchport access vlan20 划分fa/11-20端口为vlan20 YZH(config-if-range)#exit

查看vlan配置信息

YZH(config)#exit

YZH#show vlan 查看交换机vlan信息

配置vlan10与vlan20的IP地址,使vlan10与vlan20之间能相互通讯。

YZH(config)#interface vlan10 进入vlan10

YZH(config-vlan10)#ip address 192.168.1.1 255.255.255.0 配置vlan10的IP地址YZH(config-vlan10)#exit

YZH(config)#interface vlan20 进入vlan20

YZH(config-vlan20)#ip address 192.168.2.1 255.255.255.0 配置vlan20的IP地址

YZH(config)#exit

YZH#show running-config 查看交换机配置信息

在三层交换机上配置vlan10与20的IP地址后,PC1与PC2可以相互通讯

YZH>enable 进入特权模式

YZH#configure terminal 进入全局模式

YZH(config)#hostname yzh 修改名称

yzh(config)#interface range fasrEthernet 0/1-2 进入fa0/1、fa0/2端口

yzh(config-if-range)#port-group 1 把fa0/1、fa0/2端口聚合为端口组1 yzh(config-if-range)#exit

yzh(config)#exit 注:验证测试:查看交换机配置

yzh#show running-config

配置三层交换机SW1的生成树协议

yzh>enable

yzh#configure

yzh(config)#hostname YZH

YZH(config)#spanning-tree 配置生成树

YZH(config)#exit

验证配置:

YZH#show vlan 查看VLAN划分信息

配置二层交换机SWB的VLAN划分

YZH>enable

YZH #configure terminal

YZH(config)#hostname SWB 配置交换机名称

YZH (config)#vlan20 创建VLAN20

YZH (config-vlan)#exit

YZH (config)#int fa0/1

YZH (config-if)#swit

YZH (config-if)#switchport access vlan20 将端口Fa0/1划分为VLAN20

YZH (config-if)#exit

YZH (config)#int fa0/24

YZH (config-if)#switchport access vlan20 将端口Fa0/24划分为VLAN20

YZH (config-if)#exit

配置三层交换机SW1不同VLAN之间的通信

YZH>enable

YZH #configure terminal

YZH (config)#hostname yzh !配置交换机名称

yzh (config)#vlan10 !创建VLAN10

yzh (config-vlan)#vlan20 !创建VLAN20

yzh (config-vlan)#vlan 30 !创建VLAN30

yzh (config-vlan)#exit

yzh (config)#interface vlan10 !配置VLAN10的IP地址

yzh (config-VLAN10)#ip address 192.168.1.1 255.255.255.0

yzh (config-VLAN10)#exit

yzh config)#interface vlan20 !配置VLAN20的IP地址

yzh (config-VLAN20)#ip address 192.168.2.1 255.255.255.0

yzh config-VLAN20)#exit

yzh (config)#interface vlan 30 !配置VLAN30的IP地址

yzh (config-VLAN 30)#ip address 192.168.3.1 255.255.255.0

yzh (config-VLAN 30)#exit

yzh (config)#interface range fastEthernet 0/1-7

yzh (config-if-range)#switchport access vlan10 !划分VLAN10

yzh (config-if-range)#exit

yzh (config)#interface range fastEthernet 0/8-14

yzh (config-if-range)#switchport access vlan20 !划分VLAN20

yzh (config-if-range)#exit

yzh (config)#interface range fastEthernet 0/15-21

yzh (config-if-range)#switchport access vlan 30 !划分VLAN30

yzh (config-if-range)#exit

配置风暴控制。

在交换机配置F0/1端口(连接PC1 的端口)对广播报文进行风暴控制,限制其端口收到

的报文速率(pps)

yzh#configure

yzh(config)#interface fastEthernet 0/1

yzh(config-if)#storm-control broadcast pps 100 配置报文速率阈每秒100个报文

yzh(config-if)#exit

配置交换机端口安全的最大连接数和端口违背模式,绑定PC机IP地址和MAC地址到端口

yzh>enable

yzh#configure

yzh(config)#interface fastEthernet 0/1

yzh(config-FastEthernet 0/1)#switchport port-security 打开端口安全功能

yzh(config-FastEthernet 0/1)#switchport port-security mac address 0023.7d51.72ad

ip-addreess 192.168.1.1

yzh(config-if-range)#switchport port-security violation shutdown 配置安全违背关闭模式

验证交换机端口的最大连接数和端口违背模式

yzh(config)#show port-secruity

验证端口绑定的MAC地址和IP地址

yzh(config)#show port-security

验证端口绑定的MAC地址和IP地址

yzh(config)#show port-security address

配置镜像源端口0/1-2的进出流量映射到目的端口F0/20

yzh>enable

yzh#configure

yzh(config)#monitor session 1 source interface fasrEthernet 0/1-2 both

yzh(config)#monitor session 1 destination interface fastEthernet 0/20

yzh(config)#exit

查看配置信息

yzh(config)#show monitor session 1

交换机地址绑定(address-bind)功能

yzh>

yzh>enable

yzh#configure terminal

yzh(config)#address-bind install 使用address-bind功能

yzh(config)#address-bind 192.168.1.1 0016.d390.6cc5

绑定IP地址为192.168.1.1 MAC地址为0016.d390.6cc5的主机让其使用网络

yzh(config)#address-bind 192.168.1.2 0016.d390.6cc4

绑定IP地址为192.168.1.2 MAC地址为0016.d390.6cc4的主机让其使用网络

yzh(config)#address-bind iplink GigabitEthernet 0/24

设置F0/24为例外端口,对于绑定地址策略不生效!

查看配置信息

yzh#show address-bind

创建ACL,定义需要限速的主机范围

yzh>enable

yzh#configure

yzh(config)#ip access-list standard gc 创建标准访问控制列表gc

yzh(config-std-ipacl)#permit host 192.168.1.0 定义限速的数据流

yzh(config)#ip access-list standard yg 创建标准访问控制列表yg

yzh(config-std-ipacl)#permit host 192.168.2.0 定义限速的数据流

定义分类表

Yzh(config)#class-map yg 创建名为yg的分类表

yzh(config-cmap)#match access-group yg 关联匹配的列表地址

yzh(config-cmap)#exit

yzh(config)#class-map gc 创建名为yg的分类表

yzh(config-cmap)#match access-group gc 关联匹配的列表地址

yzh(config-cmap)#exit

创建策略列表,关联对应的分类表,配置限速大小

yzh(config)#policy-map qos1 创建名为qos1的策略列表

yzh(config-pmap)#class yg 关联分类表yg

yzh(config-pmap-c)#police 20000 2000 exceed-action drop

将满足yg分类规则的报文的带宽设置为20M比特/秒,突发值为2M字节,超出此带宽的报文一律丢弃

yzh(config-pmap)#class gc 关联分类表gc

yzh(config-pmap-c)#bandwidth 20 percent 设置cg占取20%带宽

yzh(config-pmap-c)#exit

将带宽限制策略应用到相应的端口

yzh#configure

yzh(config)#interface range fastEthernet 0/1-2 进入端口1-2

yzh(config-if)#service-policy input qos1 应用策略列表

小贴士

验证分类表和策略列表的配置命令

Switch#show class-map

Switch#show policy-map

yzh#config

yzh(config)#time-range schooltime 创建时间表schooltime

yzh(config-time-range)#periodic Daily 23:00 to 23:59

定义时间范围为23:00到23:59

yzh(config-time-range)#periodic Daily 0:00 to 7:00

定义时间范围为0:00 到 7:00

yzh(config)#exit

:创建扩展ACL并命名为schoolACl,配置禁止172.20.83.0该网段在每天晚上23:00至凌晨7:00禁止访问外网IP地址172.20.82.100。

yzh(config)#ip access-list extended schoolACL 创建ACL,命名为schoolACL

yzh(config-ext-nacl)#deny ip 172.20.83.0 0.0.0.255 172.20.82.100 time-range schooltime

禁止 172.20.83.0该网段在Schooltime 的时间段内访问外网IP地址172.20.82.100 yzh(config-ext-nacl)#permit ip any any 允许其他所有IP通过

yzh(config-ext-nacl)#exit

进入端口F0/1,配置PC的网关地址,将名为schoolACL的ACL绑定到该端口的入口处。yzh(config)#interface range fastEthernet 0/1

yzh(config-if-range)#ip address 172.20.83.1 255.255.255.0 设置PC网关地址

yzh(config-if-range)#ip access-group schoolACL in 将名为schoolACL的ACL绑定到该端口的入口处

yzh(config-if-range)#exit

把交换机的系统时间设置到ACL所允许通信的时间范围内

yzh(config)#clock set 9:00:00 10 19 2010 设置交换机系统时间为9点

把交换机的系统时间设置到ACL所禁止通信的时间范围内

yzh(config)#clock set 2:00:00 10 19 2010 设置交换机系统时间为2点

配置三层交换机S1,按照以下命令配置网关地址,并配置VRRP

yzh>enable

yzh#configure

yzh(config)#interface fastEthernet 0/23

yzh(config-FastEthernet 0/23)#no switchport

yzh(config-FastEthernet 0/23)#ip address 192.168.1.1 255.255.255.0

yzh(config-FastEthernet 0/23)vrrp 1 192.168.1.254

创建VRRP组为1,并设置虚拟网关

yzh(config-FastEthernet 0/23)#vrrp 1 priority 180 设置组号为1的优先级为180 yzh(config-FastEthernet 0/23)#exit

yzh(config)#interface fastEthernet 0/24

yzh(config-FastEthernet 0/24)#no switchport

yzh(config-FastEthernet 0/24)#ip address 10.0.0.1 255.255.255.240

yzh(config-FastEthernet 0/24)exit

配置三层交换机S2,按照以下命令配置网关地址,并配置VRRP。

S2>enable

S2(config)#interface fastEthernet 0/23

S2(config-FastEthernet 0/23)#no switchport

S2(config-FastEthernet 0/23)ip address 192.168.1.2 255.255.255.0

S2(config-FastEthernet 0/23)#vrrp 1 ip 192.168.1.254

创建VRRP组为1,并设置虚拟网关

S2(config-FastEthernet 0/23)#vrry 1 priority 150 设置组号为1的优先级为150

S2(config-FastEthernet 0/23)#exit

S2(config)#interface fastEthernet 0/24

S2(config-FastEthernet 0/24)#no switchport

S2(config-FastEthernet 0/24)#ip address 20.0.0.1 255.255.255.240

S2(config-FastEthernet 0/24)#exit

配置路由器R1,按照以下命令设置各端口IP地址

R1>

R1>enable

R1#configure

R1(config)#interface fastEthernet 0/0

R1(config-if)#ip address 10.0.0.5 255.255.255.240

R1(config-if)#exit

R1(config)#interface fastEthernet 0/1

R1(config-if)#ip address 20.0.0.4 255.255.255.240

R1(config-if)#exit

R1(config)#interface loopback 1

R1(config-if)#ip address 10.0.0.100 255.255.255.240

R1(config-if)#exit

配置三层交换机S1

S1(config)#route ospf 1

S1(config-router)#network 192.168.1.0 255.255.255.0 area 0

S1(config-router)#network 10.0.0.0 255.255.255.240 area 0

S1(config-router)#exit

配置路由器R1。

R1(config)#route ospf 1

R1(config-router)#network 10.0.0.96 255.255.255.240 area 0

R1(config-router)#network 10.0.0.0 255.255.255.240 area 0

R1(config-router)#network 20.0.0.0 255.255.255.240 area 0

R1(config-router)#exit

在三层交换机S1配置VRRP协议

S1(config)#interface vlan 10 !进入Vlan10

S1(config-VLAN 10)#vrrp 1 ip 192.168.1.10 !创建VRRP组为1,并设置虚拟网关S1(config-VLAN 10)#vrrp 1 priority 180 !设置组号为1的优先级为180

S1(config-VLAN 10)#exit

在三层交换机S1配置VRRP协议

S2(config)#interface vlan 10 !进入Vlan10

S1(config-VLAN 10)#vrrp 1 ip 192.168.1.10 !创建VRRP组为1,并设置虚拟网关S1(config-VLAN 10)#vrrp 1 priority 150 !设置组号为1的优先级为150

S1(config-VLAN 10)#exit

(注:可编辑下载,若有不当之处,请指正,谢谢!)

相关文档