思科三层交换机配置命令

时间:2021-03-13 09:04:37 思科认证 我要投稿
  • 相关推荐

思科三层交换机配置命令大全

  Cisco的名字取自San Francisco(旧金山),那里有座闻名于世界的金门大桥。可以说,依靠自身的技术和对网络经济模式的深刻理解,思科成为了网络应用的成功实践者之一。为帮助同学们更好去学习思科交换机配置,yjbys小编为大家带来最新配置命令如下:

  配置一组二层端口

  configure terminal 进入配置状态

  nterface range {port-range} 进入组配置状态

  配置三层端口

  configure terminal 进入配置状态

  interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-channel port-channel-number} 进入端口配置状态

  no switchport 把物理端口变成三层口

  ip address ip_address subnet_mask 配置IP地址和掩码

  no shutdown 激活端口

  例:

  Switch(config)# interface gigabitethernet0/2

  Switch(config-if)# no switchport

  Switch(config-if)# ip address 192.20.135.21 255.255.255.0

  Switch(config-if)# no shutdown

  配置VLAN

  configure terminal 进入配置状态

  vlan vlan-id 输入一个VLAN号, 然后进入vlan配态,可以输入一个新的VLAN号或旧的来进行修改。

  name vlan-name 可选)输入一个VLAN名,如果没有配置VLAN名,缺省的名字是VLAN号前面用0填满的4位数,如VLAN0004是VLAN4的缺省名字

  mtu mtu-size (可选) 改变MTU大小

  例

  Switch# configure terminal

  Switch(config)# vlan 20

  Switch(config-vlan)# name test20

  Switch(config-vlan)# end

  或

  Switch# vlan database

  Switch(vlan)# vlan 20 name test20

  Switch(vlan)# exit

  将端口分配给一个VLAN

  configure terminal 进入配置状态

  interface interface-id 进入要分配的端口

  switchport mode access 定义二层口

  switchport access vlan vlan-id 把端口分配给某一VLAN

  例

  Switch# configure terminal

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

  Switch(config)# interface fastethernet0/1

  Switch(config-if)# switchport mode access

  Switch(config-if)# switchport access vlan 2

  Switch(config-if)# end

  Switch#

  配置VLAN trunk

  configure terminal 进入配置状态

  interface interface-Id 进入端口配置状态

  switchport trunk encapsulation {isl | dot1q | negotiate}配置trunk封装ISL 或 802.1Q 或自动协商

  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配置

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

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