思科交换机基本配置命令大全(2)

时间:2018-04-04 编辑:少芬 手机版

  switchport mode {dynamic {auto | desirable} | trunk} 配置二层trunk模式。

  dynamic auto—自动协商是否成为trunk

  dynamic desirable—把端口设置为trunk如果对方端口是trunk, desirable, 配置Native VLAN

  (802.1q)

  或自动模式,trunk—设置端口为强制的trunk方式,而不理会对方端口是否为trunk

  switchport access vlan vlan-id 可选) 指定一个缺省VLAN, 如果此端口不再是trunk

  switchport trunk native vlan vlan-id 指定802.1Q native VLAN号

  例:

  Switch# configure terminal

  Enter configuration commands, one per line. End with CNTL/Z.

  Switch(config)# interface fastethernet0/4

  Switch(config-if)# switchport mode trunk

  Switch(config-if)# switchport trunk encapsulation dot1q

  Switch(config-if)# end

  定义TRUNK允许的VLAN

  configure terminal子 进入配置状态

  interface interface-id 进入端口配置

  switchport mode trunk 配置二层口为trunk

  switchport trunk allowed vlan {add | all | except | remove} vlan-list可选) 配置trunk允

  许的VLAN.使用add, all, except, remove关健字

  no switchport trunk allowed vlan 允许所有VLAN通过

  例

  Switch(config)# interface fastethernet0/1

  Switch(config-if)# switchport trunk allowed vlan remove 2

  Switch(config-if)# end

  配置Native VLAN(802.1q)

  configure terminal 进入配置状态

  interface interface-id 进入配置成802.1qtrunk的端口

  switchport trunk native vlan vlan-Id 配置native VLAN号

  no switchport trunk native vlan 端口配置命令回到缺省的状态

  配置基于端口权值的负载均衡

  configure terminal 进入Switch 1配置状态

  vtp domain domain-name 配置VTP域

  vtp mode server 将Switch 1配置成VTP server.

  show vtp status 验证VTP的配置

  show vlan 验证VLAN

  configure terminal 进入配置状态

  interface fastethernet 0/1 进入F0/1端口

  switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封装

  switchport mode trunk 配置成trunk

  show interfaces fastethernet0/1 switchport 验证VLAN配置

  按以上步骤对想要负载均衡的接口进行配置

  在另一个交换机上进行此配置

  show vlan 当trunk已经起来,在switch2上验证已经学到相的vlan配置

  configure terminal 在Switch 1上进入配置状态

  interface fastethernet0/1 进入要配置的端口

  spanning-tree vlan 8 port-priority 10 将端口权值10赋与VLAN 8.

  spanning-tree vlan 9 port-priority 10 将端口权值10赋与VLAN 9.

  spanning-tree vlan 10 port-priority 10 将端口权值10赋与VLAN 10.

  interface fastethernet0/2 进入F0/2

  spanning-tree vlan 3 port-priority 10 将端口权值10赋与VLAN 3.

  spanning-tree vlan 4 port-priority 10 将端口权值10赋与VLAN 4

  spanning-tree vlan 5 port-priority 10 将端口权值10赋与VLAN 5

  spanning-tree vlan 6 port-priority 10 将端口权值10赋与VLAN 10

  end 退出

  show running-config 验证配置

  copy running-config startup-config 保存配置

  配置STP路径值的负载均衡

  Trunk1走VLAN8-10,Trunk2走VLAN2-4

  configure terminal 进入 Switch 1配置状态

  interface fastethernet 0/1 进入F0/1

  switchport trunk encapsulation {isl | dot1q | negotiate}配置封装

  switchport mode trunk 配置Trunk,缺省是ISL封装

  exit 退回

  在F0/2口上重复2-4步骤

  exit 退回

  show running-config 验证配置

  show vlan验证switch1 已经学到Vlan

  configure terminal 进入配置状态

  interface fastethernet 0/1 进入F0/1

  spanning-tree vlan 2 cost 30 设置Vlan2生成树路径值为30

  spanning-tree vlan 3 cost 30 设置Vlan3生成树路径值为30

  spanning-tree vlan 4 cost 30 设置Vlan4生成树路径值为30

  end 退出

  在switch1的F0/2上重复9-11步骤设置VLAN8,9,10生成树路径值为30

  end 退出

  show running-config 验证配置

  copy running-config startup-config 保存配置

  补充:CISCO命令集——路由选择协议及排障

  *ip route命令

  Router(config)# ip route <目录网络或子网号> [子网掩码] <下一路由器IP地址 | 从本地出口

  的地址> [管理距离0~255,默认为1]

  (注:静态地址配置)

  *ip default-network命令

  Router(config)# ip default-network <目标网络号>

  (注:配合路由协使用,用其中的一个动态路由号作默认路由配置)

  Router(config)# ip route 0.0.0.0 0.0.0.0 <下一路由器IP地址 | 从本地出口的地址>

  (注:只有一个公网地址时,在出口路由器上的配置)

  *内部路由选择协议

  *使用router和network命令

  Router(config)# router <路由协议rip | igrp | eigrp | ospf | is-is等> [自主系统号]

  Router(config-router)# network <直接相连的要用此路由协议的网络号>

  Router(config-router)# network <直接相连的要用此路由协议的网络号>

  *路由信息协议RIP

  Router(config)# router rip

  Router(config-router)# network <直接相连的要用rip协议的有类别网络号>

  Router# show ip protocols

  Router# show ip route

  Router# debug ip rip

  *内部网关路由协议IGRP

  Router(config)# router igrp <自主系统号>

  Router(config-router)# network <直接相连的要用igrp协议的有类别网络号>

  Router# show ip interface

  Router# show ip protocols

  Router# show ip route

  Router# debug ip rip

  *排除网络故障

  排除网络故障的一个总体模型

  Router# ping <有故障的主机 | 有故障的IP地址>

  Router# show ip route

  Router# show interface <有故障的接口>

  Router# show run

  *IP的故故障排除

  检查可用的路由

  Router# show ip route <有故障的IP地址>

  27.4.4 跟踪路由(Tracing the Route)

  SUN-A> traceroute <有故障的主机 | 有故障的IP地址>

  C:/windows/> winipcfg

  C:/windows/> ipconfig

  C:/windows/> ipconfig / all

  C:/windows/> tracert <有故障的主机 | 有故障的IP地址>

  使用扩展的ping来跟踪连接性

  Router# ping

  *其它可能的故障

  一个地址解析(ARP)的故障

  Router# show arp

  Router# show interface <有故障的接口>

  C:/windows/> arp -a

  SUN-A> arp –a

  验证终端系统的路由表

  C:/windows/> netstat –rn

  C:/windows/> route –f add 0.0.0.0 mask 0.0.0.0 <需要添加入的网关地址>

  C:/windows/> route [–f ] [[print | add | delete | change] [destination] [mask

  netmask] [gateway]]

  C:/windows/> route add mask <网络掩码> <网关ip地址>

  C:/windows/> route delete mask <网络掩码> <网关ip地址>

  C:/windows/> nbtstat <相应的参数>

  SUN-A> netstat -rn路由器

  CISCO交换机配置命令大全2009-08-13 21:131.在基于IOS的交换机上设置主机名/系统名:

  switch(config)# hostname hostname

  在基于CLI的交换机上设置主机名/系统名:

  switch(enable) set system name name-string

  2.在基于IOS的交换机上设置登录口令:

  switch(config)# enable password level 1 password

  在基于CLI的交换机上设置登录口令:

  switch(enable) set password

  switch(enable) set enalbepass

  3.在基于IOS的交换机上设置远程访问:

  switch(config)# interface vlan 1

  switch(config-if)# ip address ip-address netmask

  switch(config-if)# ip default-gateway ip-address

  在基于CLI的交换机上设置远程访问:

  switch(enable) set interface sc0 ip-address netmask broadcast-address

  switch(enable) set interface sc0 vlan

  switch(enable) set ip route default gateway

  4.在基于IOS的交换机上启用和浏览CDP信息:

  switch(config-if)# cdp enable

  switch(config-if)# no cdp enable

  为了查看Cisco邻接设备的CDP通告信息:

  switch# show cdp interface [type modle/port]

  switch# show cdp neighbors [type module/port] [detail]

  在基于CLI的交换机上启用和浏览CDP信息:

  switch(enable) set cdp {enable|disable} module/port

  为了查看Cisco邻接设备的CDP通告信息:

  switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilities|detail]

  5.基于IOS的交换机的端口描述:

  switch(config-if)# description description-string

  基于CLI的交换机的端口描述:

  switch(enable)set port name module/number description-string

  6.在基于IOS的交换机上设置端口速度:

  switch(config-if)# speed{10|100|auto}

  在基于CLI的交换机上设置端口速度:

  switch(enable) set port speed moudle/number {10|100|auto}

  switch(enable) set port speed moudle/number {4|16|auto}

  7.在基于IOS的交换机上设置以太网的链路模式:

  switch(config-if)# duplex {auto|full|half}

  在基于CLI的交换机上设置以太网的链路模式:

  switch(enable) set port duplex module/number {full|half}

  8.在基于IOS的交换机上配置静态VLAN:

  switch# vlan database

  switch(vlan)# vlan vlan-num name vla

  switch(vlan)# exit

  switch# configure teriminal

  switch(config)# interface interface module/number


更多思科交换机相关文章:

思科交换机基本配置命令大全(2)相关推荐