思科路由器和交换机的配置命令全集

(1)模式转换命令

用户模式一-特权模式,使用命令"enable"

特权模式一-全局配置模式,使用命令”ontfg"

全局配置模式--接口模式,使用命令"interface接口类型#接口号”

全局配置模--线控模式,使用命令“line+接口类型+接口号”

注:

用户模式:查看初始化的信息.

特权模式:查看所有信息、调试、保存配置信息

全局模式:配置所有信息、针对整个路由器或交换机的所有接口

接口模式:针对某一个接口的配置

线控模式:对路由器进行控制的接口配置

(2)配置命令

show funning config显示所有的配置

show versin显示版本号和寄存器值

shut down关闲接口

mo shutdown打开接口

中addtip地址配置P地址

secondary+IP地址为接口配置第二个IP地址

show interfacet接口类型+接口号查看接口管理性

show controlers intertace查看接口是否有DCE电缆

show history查看历史记录

show teminal查看終端记录大小

hostname主机名配置路由器或交换机的标识

conlg memory修改保存在NVRAM中的启动配置

exec timeout00设置控制台会话超时为0

service password-encryptin手工加密所有密码

enable password +密码配置明文密码

ena sec +密码配置密文密码

line vny04/15进入telnet接口

password密码配置telnet密吗

line aux0进入AUX接口

passwerd +密码配置密码

line con0进入CON接口

password+密码 配置密码

banowidth+数字 配置带宽

mo ip adress 删除已配置的IP地址

show startup contig 查看NVRAM中的配置信息

copy nun-conig atartup config 保存值息到NVRAM

wite 保存信息到NVRAM

erase startup-coning 清除NVRAM中的配置信息

show ip interface briet 查看接口的滴要信息

banner motd#信息# 配置路由器或交换机的描素信息

description+信息 配置接口听描素信息

vlan database 进入VLAN数据库模式

wlan +vlan号+名称 创建VLAN

sithport access wlan +vlan号 为VLAN为配接

interface vlan +vlan号进入VLAN接口模式

ip add+ip地址 为VLAN配置管理IP地址

vp+ seice/tracsparent/elient 配置SW的VTP工作模式

vip +domain+城名 配置Sw的VTP城名

vip +passwerd +密码 配置SW的密码

switchport mode trunk 启用中继

no van +vlan号 删除VLAN

show spamning-tree vlan +vlan号 查看VLA怕生成树议

image

路由器配置命令

ip route+非直连网段+子网掩码*下一跳地址 配置静态/默认路由

show ip route 查看路由表

show prooles 显示出所有的被动路由协议和接口上哪些协议被设置

show ip prolocols 显示了被配置在路由器上的路由选择协议,同时给出了在路由选择协议中使用的定时器等信息

routerrip 激活RIP协议

network +直连网段 发布直连网段

interface kokback D 激活逻辑接口

passive-interface +接口类型+接口号 配置接口为被动模式

debug ip +协议动态 查看路由更新信息

undebug all 关闭所有DEBUG信息

router eigp +as号 激活EIGRP路由协议

netwark +网段+子网掩码 发布直连网段

show ip eigrp neighbors 查香邻居表

show ip eigrp topologoy 查看拓扑表

show ip eigrp trtflic 查看发送包数量

router ospl +process-ID 激活OSPF协议

network+直连网段+area+区域号 发布直连网段

show ip ospt 显示OSPF的选程号和ROUTER-ID

encapsulatlion+封装格式 更改封装格式

no ip admain-lookup 关闭路由器的城名查找

ip rouing 在三层交换机上启用路由功能

show user 查看sw的在线用卢

clear line +线路号 清除线路

三层交换机配置命令

配置一组二层端口

configure teminal 进入配置状态

ntertace range (port-range} 进入组配置状态

配置三层端口

conigure terminal 进入配置状态

interface (fatethrmet I gigabitethemet} interface-it} I Man van-id} | {por-

channel por-channe-number进入端口配置状态

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

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

no shutdown 激活端口

例:

Switch(conig)# interlace gigabitethemet0/2

Switch(canfig-iy no switchport

Switch(config-iry ip address 192.20.135.21 255.255 255.0

Swith(conig-if)# no shutdown

配置 VLAN

configure terminal 进入配置状态

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

name vlan-name可选输入一个VLAN名。如果没有配置VLAN名。缺省的名字是VLAN号前面用0填满

的4位数,如VLAN004是VLAN4的缺省名字

mtu mtu-size 改变 MTU 大小

例:

Switch# configure terminal

Switch(conig)# vlan 20

Stitcheonig-vlan) name test20

Switch(config-vlan)# end

Switch vlan database

Switch(vlan)# vlan 20 name test20

Switch(vlan)# exit

将端口分配给一个 VLAN

comfigure terminal 进入配置状态

inerftoce intertae-id 进入要分配的端口

swilchport mode access 定义二层口

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

例:

Switch# comnfigure terminal

Enter ofiguration commands, one per line. End with CNTLZ.

Switch(canfig)# interface fastethemet0V1

Switch(config-i)# switchpor made access

Swilthlconig-iry# swilchpon access vlan 2

Swilth(config-if)# end

Switch#

配置 VLAN trunk

configure terminal 进入配置状态

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

swilchport trunk encapsulation (isl I dot1q I negotiate)配置trunk 封装ISL或 802.1Q 或

自动协商

switchport mode (dynamic (auto I desirable) trunk) 配置二层 trunk 模式。

dymamic 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 I all I except I 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-ld 配置 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 验证 VL AN

configure terminal 进入配置状态

interface fastethernet0/1 进入F0/1 端口

switchport trunk encapsulation (isl I dot1q I 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

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设置VIan3生成树路径值为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(onfig-router)# network <直接相连的要用此路由协议的网络号>

*路由信息协议RIP

Router(config)# router rip

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

Router# show ip protocols

Router#t show ip route

Router#t debug ip rip

*内部网关路由协议IGRP

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

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

Router#t show ip interface

Router# show ip protocols

Router#t show ip route

Router# debug ip rip

*排除网络故障

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

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

Router#t 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:lwindows> winipcfg

C:lwindows> ipconfig

C:windows> ipconfig 1 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 I add I delete I change] [destination] [mask

netmask] [gateway]]

C:windowsl> route add mask < WHEKT1> <@* ip th>

C:lwindowsl> route delete mask < NJk HiÊHig>

C:windows> nbtstat <相立的参数>

SUN-A> netstat -n路由器

本文转自:https://mp.weixin.qq.com/s/jg-WYZ9u3IH_QWUnJZhiLw

你可能感兴趣的:(思科路由器和交换机的配置命令全集)