1. switch配置命令
(1)模式转换命令
用户模式----特权模式,使用命令"enable"
特权模式----全局配置模式,使用命令"config t"
全局配置模式----接口模式,使用命令"interface+接口类型+接口号"
全局配置模式----线控模式,使用命令"line+接口类型+接口号"
注:
用户模式:查看初始化的信息.
特权模式:查看所有信息、调试、保存配置信息
全局模式:配置所有信息、针对整个路由器或交换机的所有接口
接口模式:针对某一个接口的配置
线控模式:对路由器进行控制的接口配置
(2)配置命令
show running config 显示所有的配置
show versin 显示版本号和寄存器值
shut down 关闭接口
no shutdown 打开接口
ip add +ip地址 配置IP地址
secondary+IP地址 为接口配置第二个IP地址
show interface+接口类型+接口号 查看接口管理性
show controllers interface 查看接口是否有DCE电缆
show history 查看历史记录
show terminal 查看终端记录大小
hostname+主机名 配置路由器或交换机的标识
config memory 修改保存在NVRAM中的启动配置
exec timeout 0 0 设置控制台会话超时为0
service password-encryptin 手工加密所有密码
enable password +密码 配置明文密码
ena sec +密码 配置密文密码
line vty 0 4/15 进入telnet接口
password +密码 配置telnet密码
line aux 0 进入AUX接口
password +密码 配置密码
line con 0 进入CON接口
password +密码 配置密码
bandwidth+数字 配置带宽
no ip address 删除已配置的IP地址
show startup config 查看NVRAM中的配置信息
copy run-config atartup config 保存信息到NVRAM
write 保存信息到NVRAM
erase startup-config 清除NVRAM中的配置信息
show ip interface brief 查看接口的谪要信息
banner motd # +信息 + # 配置路由器或交换机的描素信息
description+信息 配置接口听描素信息
vlan database 进入VLAN数据库模式
vlan +vlan号+ 名称 创建VLAN
switchport access vlan +vlan号 为VLAN为配接口
interface vlan +vlan号 进入VLAN接口模式
ip add +ip地址 为VLAN配置管理IP地址
vtp+service/tracsparent/client 配置SW的VTP工作模式
vtp +domain+域名 配置SW的VTP域名
vtp +password +密码 配置SW的密码
switchport mode trunk 启用中继
no vlan +vlan号 删除VLAN
show spamming-tree vlan +vlan号 查看VLA怕生成树议
2. 路由器配置命令
ip route+非直连网段+子网掩码+下一跳地址 配置静态/默认路由
show ip route 查看路由表
show protocols 显示出所有的被动路由协议和接口上哪些协议被设置
show ip protocols 显示了被配置在路由器上的路由选择协议,同时给出了在路由选择协议中使用的定时器等
信息
router rip 激活RIP协议
network +直连网段 发布直连网段
interface lookback 0 激活逻辑接口
passive-interface +接口类型+接口号 配置接口为被动模式
debug ip +协议 动态查看路由更新信息
undebug all 关闭所有DEBUG信息
router eigrp +as号 激活EIGRP路由协议
network +网段+子网掩码 发布直连网段
show ip eigrp neighbors 查看邻居表
show ip eigrp topology 查看拓扑表
show ip eigrp traffic 查看发送包数量
router ospf +process-ID 激活OSPF协议
network+直连网段+area+区域号 发布直连网段
show ip ospf 显示OSPF的进程号和ROUTER-ID
encapsulation+封装格式 更改封装格式
no ip admain-lookup 关闭路由器的域名查找
ip routing 在三层交换机上启用路由功能
show user 查看SW的在线用户
clear line +线路号 清除线路
在网上找的感觉挺全的 讲的也很细 希望对要的朋友有用!
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
过手工输入的方式完成。
进入设置对话过程后,路由器首先会显示一些提示信息:
--- System Configuration Dialog ---
At any point you may enter a question mark '?' for help.
Use ctrl-c to abort configuration dialog at any prompt.
Default settings are in square brackets '[]'.
这是告诉你在设置对话过程中的任何地方都可以键入“?”得到系统的帮助,按ctrl-c可以退出设置过程,缺省
设置将显示在'[]’中。然后路由器会问是否进入设置对话:
Would you like to enter the initial configuration dialog? [yes]:
如果按y或回车,路由器就会进入设置对话过程。首先你可以看到各端口当前的状况:
First, would you like to see the current interface summary? [yes]:
Any interface listed with OK? value "NO" does not have a valid configuration
Interface IP-Address OK? Method Status Protocol
Ethernet0 unassigned NO unset up up
Serial0 unassigned NO unset up up
……… ……… … …… … …
然后,路由器就开始全局参数的设置:
Configuring global parameters:
1.设置路由器名:
Enter host name [Router]:
2.设置进入特权状态的密文(secret),此密文在设置以后不会以明文方式显示:
The enable secret is a one-way cryptographic secret used
instead of the enable password when it exists.
Enter enable secret: cisco
3.设置进入特权状态的密码(password),此密码只在没有密文时起作用,并且在设置以后会以明文方式显
示:
The enable password is used when there is no enable secret
and when using older software and some boot images.
Enter enable password: pass
4.设置虚拟终端访问时的密码:
Enter virtual terminal password: cisco
5.询问是否要设置路由器支持的各种网络协议:
Configure SNMP Network Management? [yes]:
Configure DECnet? [no]:
Configure AppleTalk? [no]:
Configure IPX? [no]:
Configure IP? [yes]:
Configure IGRP routing? [yes]:
Configure RIP routing? [no]:
………
6.如果配置的是拨号访问服务器,系统还会设置异步口的参数:
Configure Async lines? [yes]:
1) 设置线路的最高速度:
Async line speed [9600]:
2) 是否使用硬件流控:
Configure for HW flow control? [yes]:
3) 是否设置modem:
Configure for modems? [yes/no]: yes
4) 是否使用默认的modem命令:
Configure for default chat script? [yes]:
5) 是否设置异步口的PPP参数:
Configure for Dial-in IP SLIP/PPP access? [no]: yes
6) 是否使用动态IP地址:
Configure for Dynamic IP addresses? [yes]:
7) 是否使用缺省IP地址:
Configure Default IP addresses? [no]: yes
是否使用TCP头压缩:
Configure for TCP Header Compression? [yes]:
9) 是否在异步口上使用路由表更新:
Configure for routing updates on async links? [no]: y
10) 是否设置异步口上的其它协议。
接下来,系统会对每个接口进行参数的设置。
1.Configuring interface Ethernet0:
1) 是否使用此接口:
Is this interface in use? [yes]:
2) 是否设置此接口的IP参数:
Configure IP on this interface? [yes]:
3) 设置接口的IP地址:
IP address for this interface: 192.168.162.2
4) 设置接口的IP子网掩码:
Number of bits in subnet field [0]:
Class C network is 192.168.162.0, 0 subnet bits; mask is /24
在设置完所有接口的参数后,系统会把整个设置对话过程的结果显示出来:
The following configuration command script was created:
hostname Router
enable secret 5 $1$W5Oh$p6J7tIgRMBOIKVXVG53Uh1
enable password pass
…………
请注意在enable secret后面显示的是乱码,而enable password后面显示的是设置的内容。
显示结束后,系统会问是否使用这个设置:
Use this configuration? [yes/no]: yes
如果回答yes,系统就会把设置的结果存入路由器的NVRAM中,然后结束设置对话过程,使路由器开始正常
四、常用命令
1. 帮助
在IOS操作中,无论任何状态和位置,都可以键入“?”得到系统的帮助。
2. 改变命令状态
任务 命令
进入特权命令状态 enable
退出特权命令状态 disable
进入设置对话状态 setup
进入全局设置状态 config terminal
退出全局设置状态 end
进入端口设置状态 interface type slot/number
进入子端口设置状态 interface type number.subinterface [point-to-point | multipoint]
进入线路设置状态 line type slot/number
进入路由设置状态 router protocol
退出局部设置状态 exit
3. 显示命令
任务 命令
查看版本及引导信息 show version
查看运行设置 show running-config
查看开机设置 show startup-config
显示端口信息 show interface type slot/number
显示路由信息 show ip router
4. 拷贝命令
用于IOS及CONFIG的备份和升级
:
种类 网络地址范围
A 1.0.0.0 到126.0.0.0有效 0.0.0.0 和127.0.0.0保留
B 128.1.0.0到191.254.0.0有效 128.0.0.0和191.255.0.0保留
C 192.0.1.0 到223.255.254.0有效 192.0.0.0和223.255.255.0保留
D 224.0.0.0到239.255.255.255用于多点广播
E 240.0.0.0到255.255.255.254保留 255.255.255.255用于广播
2. 分配接口IP地址
任务 命令
接口设置 interface type slot/number
为接口设置IP地址 ip address ip-address mask
掩玛(mask)用于识别IP地址中的网络地址位数,IP地址(ip-address)和掩码(mask)相与即得到网络地
有合法IP地址的用户可以通过NAT访问到外部Internet.
当建立内部网的时候,建议使用以下地址组用于主机,这些地址是由Network Working Group(RFC 1918)保留
用于私有网络地址分配的.
l Class A:10.1.1.1 to 10.254.254.254
l Class B:172.16.1.1 to 172.31.254.254
l Class C:192.168.1.1 to 192.168.254.254
命令描述如下:
任务 命令
定义一个标准访问列表 access-list access-list-number permit source [source-wildcard]
定义一个全局地址池 ip nat pool name start-ip end-ip {netmask netmask | prefix-length prefix-length}
[type rotary]
建立动态地址翻译 ip nat inside source {list {access-list-number | name} pool name [overload] | static
local-ip global-ip}
指定内部和外部端口 ip nat {inside | outside}
如下图所示,
。命令ip nat inside source list 2 pool c2501 overload中的参数overload,将允许多个内部地址使用相同的
全局地址(一个合法IP地址,它是由NIC或服务提供商所分配的地址)。命令ip nat pool c2501
202.96.38.1 202.96.38.62 netmask 255.255.255.192定义了全局地址的范围。
设置如下:
ip nat pool c2501 202.96.38.1 202.96.38.62 netmask 255.255.255.192
interface Ethernet 0
ip address 10.1.1.1 255.255.255.0
ip nat inside
!
interface Serial 0
ip address 202.200.10.5 255.255.255.252
ip nat outside
!
ip route 0.0.0.0 0.0.0.0 Serial 0
access-list 2 permit 10.0.0.0 0.0.0.255
! Dynamic NAT
!
ip nat inside source list 2 pool c2501 overload
line console 0
exec-timeout 0 0
!
line vty 0 4
end
以下例子为E1连接3条64K专线, 帧类型为NO-CRC4,非平衡链路,路由器具体设置如下:
shanxi#wri t
Building configuration...
Current configuration:
!
version 11.2
no service udp-small-servers
no service tcp-small-servers
!
hostname shanxi
!
enable secret 5 $1$XN08$Ttr8nfLoP9.2RgZhcBzkk/
enable password shanxi
!
!
ip subnet-zero
!
controller E1 0
framing NO-CRC4
channel-group 0 timeslots 1
channel-group 1 timeslots 2
channel-group 2 timeslots 3
!
interface Ethernet0
ip address 133.118.40.1 255.255.0.0
media-type 10BaseT
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0:0
ip address 202.119.96.1 255.255.255.252
no ip mroute-cache
!
interface Serial0:1
ip address 202.119.96.5 255.255.255.252
no ip mroute-cache
!
interface Serial0:2
ip address 202.119.96.9 255.255.255.252
no ip mroute-cache
!
no ip classless
ip route 133.210.40.0 255.255.255.0 Serial0:0
ip route 133.210.41.0 255.255.255.0 Serial0:1
ip route 133.210.42.0 255.255.255.0 Serial0:2
!
line con 0
line aux 0
line vty 0 4
password shanxi
login
!
end
广域网设置:
一、HDLC
HDLC是CISCO路由器使用的缺省协议,一台新路由器在未指定封装协议时默认使用HDLC封装。
1. 有关命令
端口设置
任务 命令
设置HDLC封装 encapsulation hdlc
设置DCE端线路速度 clockrate speed
复位一个硬件接口 clear interface serial unit
显示接口状态 show interfaces serial [unit] 1
注:1.以下给出一个显示Cisco同步串口状态的例子.
Router#show interface serial 0
Serial 0 is up, line protocol is up
Hardware is MCI Serial
Internet address is 150.136.190.203, subnet mask is 255.255.255.0
MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, rely 255/255, load 1/255
Encapsulation HDLC, loopback not set, keepalive set (10 sec)
Last input 0:00:07, output 0:00:00, output hang never
Output queue 0/40, 0 drops; input queue 0/75, 0 drops
Five minute input rate 0 bits/sec, 0 packets/sec
Five minute output rate 0 bits/sec, 0 packets/sec
16263 packets input, 1347238 bytes, 0 no buffer
Received 13983 broadcasts, 0 runts, 0 giants
2 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 2 abort
22146 packets output, 2383680 bytes, 0 underruns
0 output errors, 0 collisions, 2 interface resets, 0 restarts
1 carrier transitions
2. 举例
设置如下:
Router1:
interface Serial0
ip address 192.200.10.1 255.255.255.0
clockrate 1000000
以下例子为E1连接3条64K专线, 帧类型为NO-CRC4,非平衡链路,路由器具体设置如下:
shanxi#wri t
Building configuration...
Current configuration:
!
version 11.2
no service udp-small-servers
no service tcp-small-servers
!
hostname shanxi
!
enable secret 5 $1$XN08$Ttr8nfLoP9.2RgZhcBzkk/
enable password shanxi
!
!
ip subnet-zero
!
controller E1 0
framing NO-CRC4
channel-group 0 timeslots 1
channel-group 1 timeslots 2
channel-group 2 timeslots 3
!
interface Ethernet0
ip address 133.118.40.1 255.255.0.0
media-type 10BaseT
!
interface Ethernet1
no ip address
shutdown
!
interface Serial0:0
ip address 202.119.96.1 255.255.255.252
no ip mroute-cache
!
interface Serial0:1
ip address 202.119.96.5 255.255.255.252
no ip mroute-cache
!
interface Serial0:2
ip address 202.119.96.9 255.255.255.252
no ip mroute-cache
!
no ip classless
ip route 133.210.40.0 255.255.255.0 Serial0:0
ip route 133.210.41.0 255.255.255.0 Serial0:1
ip route 133.210.42.0 255.255.255.0 Serial0:2
!
line con 0
line aux 0
line vty 0 4
password shanxi
login
!
end
返回目录
二、PPP
PPP(Point-to-Point Protocol)是SLIP(Serial Line IP protocol)的继承者,它提供了跨过同步和异步电路实现
address} [vc-number] 3
清x25虚电路 clear x25-vc
显示接口及x25相关信息 show interfaces serial show x25 interface show x25 map show x25 vc
注:1、虚电路号从1到4095,Cisco路由器默认为1024,国内一般分配为16。
2、虚电路计数从1到8,缺省为1。
3、在改变了x.25各层的相关参数后,应重新启动x25(使用clear x25 {serial number | cmns-interface mac
相关调试命令:
clear x25-vc
show interfaces serial
show x25 map
show x25 route
show x25 vc
3.2. 在以下实例中路由器router1和router2均通过svc与router连接,但router1和router2不通过svc直接连
支持的LMI类型,用户可以不明确配置LMI接口类型。
3.broadcast选项允许在帧中继网络上传输路由广播信息。
3. 帧中继point to point配置实例:
Router1:
interface serial 0
encapsulation frame-relay
!
interface serial 0.1 point-to-point
ip address 172.16.1.1 255.255.255.0
frame-reply interface-dlci 105
!
interface serial 0.2 point-to-point
ip address 172.16.2.1 255.255.255.0
frame-reply interface-dlci 102
!
interface serial 0.3 point-to-point
ip address 172.16.4.1 255.255.255.0
frame-reply interface-dlci 104
!
Router2:
interface serial 0
encapsulation frame-relay
!
interface serial 0.1 point-to-point
ip address 172.16.2.2 255.255.255.0
frame-reply interface-dlci 201
!
interface serial 0.2 point-to-point
ip address 172.16.3.1 255.255.255.0
frame-reply interface-dlci 203
!
相关调试命令:
show frame-relay lmi
show frame-relay map
show frame-relay pvc
show frame-relay route
show interfaces serial
go top
4. 帧中继 Multipoint 配置实例:
Router1:
interface serial 0
encapsulation frame-reply
!
interface serial 0.1 multipoint
ip address 172.16.1.2 255.255.255.0
frame-reply map ip 172.16.1.1 201 broadcast
frame-reply map ip 172.16.1.3 301 broadcast
frame-reply map ip 172.16.1.4 401 broadcast
!
Router2:
interface serial 0
encapsulation frame-reply
!
interface serial 0.1 multipoint
ip address 172.16.1.1 255.255.255.0
frame-reply map ip 172.16.1.2 102 broadcast
frame-reply map ip 172.16.1.3 102 broadcast
frame-reply map ip 172.16.1.4 102 broadcast
!