其他的一些关于历史的命令:
1 I' v. v# F' ^ 1.show history:显示最后输入的10条命令,默认是10条,可以修改该值( `" u* F! }9 q" j: n e
2.terminal history size:修改显示最后输入过的的命令的数量,默认是10条,最大是256条
4 a, a1 g' c+ E! v5 A 3.show terminal:显示命令历史缓存大小,如下:
, I* r$ X1 }" I% @# ~ Router#sh terminal+ T* V9 i6 A: Y8 @
(略)- n" z. ?8 p* C3 \
History is enabled,history size is 10" j% c: b) x9 A( I D
(略)* U" m- S9 Y2 S' B
Router#terminal history size ?5 e9 [5 g* p& ]
Size of history buffer' P1 q, } n* j- H
Router#terminal history size 252 o3 Q% v( Y3 U/ @2 Q7 K) E: ]' h, V
Router#sh terminal, s$ f; m0 f- @
(略)- g+ P' S( e6 `+ n
History is enabled,history size is 25+ }' ]$ `/ D: j4 w% i8 ? W5 m" {
(略)! J& W5 t" W9 R6 ]+ _( O' n$ d
Gather Basic Routing Information
1 Q S) q- l% n" m show version:显示系统硬件的基本配置和软件版本,以及配置文件的名字和来源,还有启动镜象,最后是configuration register的值
; x2 l2 \) x& R: |& Y: S Set Passwords:
5 g, x4 i g: w" X 有5种密码用于加密你的Cisco router:) c1 N" T( a+ v, y
1.控制口(console)+ D, d8 p e7 ~( q* T$ m
2.辅助口(AUX)0 V/ K! v5 s8 ~: o1 L
3.VTY2 X1 M0 u. {1 N4 Z: s4 b+ I
4.enable password
4 q7 S! i0 ^9 w7 D% [ 5.enable secret8 u5 q( ?' B' i; A4 R' U8 X1 B
Enable Passwords
9 \8 v1 o$ T: g# m2 Z* e; |% ~9 S enable password:给console和AUX口加密,防止未授权用户进入特权模式,但是密码是非加密形式
' m; j4 @& X# ~/ a enable secret:给console和AUX口加密,防止未授权用户进入特权模式,密码是加密形式,并且一旦起用了这个密码,将凌驾于enable password之上,如果同时设置了enable password和enable secret的情况下,必须输入不同的密码,如下:
' y- c7 m; V* v( A: R Router(config)#enable secret 1239 a* u' E7 j6 i5 K$ Z0 ~
Router(config)#enable secret 123
4 f9 M) a" ]2 h6 p. y The enable password you have chosen is the same as your enable secret.This is not recommended.Re-enter the enable password3 B4 J3 g/ k+ x4 G
Router(config)#enable secret 321
5 q! W4 O7 @0 b$ u, o 如果VTY线路的密码没有设置,你将无法使用telnet来连上它2 x9 V! G4 U! l0 O2 g. y7 r5 U
Auxiliary Password
/ } a) ^( x$ B% V 配置AUX密码:. }4 }, ]7 A1 _
Router#conf t
# V8 a$ B8 [+ e, \1 t Router(config)#line aux ?
/ r% ~" o8 {, }# G9 z2 F$ Z First line number
- C$ S/ l6 L" G) z) n Router(config)#line aux 0
3 I7 L! W1 [# o$ ]$ h Router(config-line)#login9 J1 a: F. J& i, w# g W& {# [
Router(config-line)#password 123* ~( q G+ M% O/ |& ?
Console Password
7 P& y8 ?' D4 B5 s6 N2 k3 |! e 配置console密码以及一些辅助命令:+ U3 `6 Q2 p. ?: t' A6 G( p& {7 k
Router#conf t
; l) l$ L& A6 _. \% D+ d Router(config)#line console ?
7 D) G, m* @1 y l( S- J( K First line number
# z# J" G- J6 Z' X Router(config)#line console 0% g( e& W: S0 e5 h6 w
Router(config-line)#login6 i' a$ f: R! b4 |1 z$ L/ Z
Router(config-line)#password 1233 y7 x9 s5 {7 r4 n
Router(config-line)#exec-timeout ?6 n: o3 v, P# x' R6 M# i* R& i1 s2 x
Timeout in minutes5 s/ h) ] R. ~. K, P
Router(config-line)#exec-timeout 0 ?
8 j' R0 X8 F, A0 S3 ]6 U# B, ^9 u Timeout in seconds9 C$ X8 m" J) v, D8 K
Router(config-line)#exec-timeout 0 0& ]7 Q! k) [0 Q5 a2 W
Router(config-line)#logging synchonous! A5 w6 [# F2 y: X
exec-timeout命令:如果X分钟X秒不活动的话将自动退出,默认是10分钟,0 0代表永远不自动退出* D+ H0 a/ E+ Q/ G2 j( F
logging synchronous:光标跟随
9 m1 d- {. X% h- D8 e Telnet Password2 ~% m/ t4 T5 U7 r9 G- l ~
配置VTY密码:如果你的IOS不是企业版(Enterprise edition),默认你只能有5条VTY线路,线路0到4.配置如下:
2 V' R* L* _" D5 N7 }0 K# Y( L Router(config-line)#line vty 0 ?
& U) n: v! _3 u2 H Last Line Number
' _$ y4 _" h$ x$ q, V' K( c s Router(config-line)#line vty 0 49 G) L0 n) m- O) n0 W
Router(config-line)#login1 }, L4 I1 E7 e
Router(config-line)#password 123
6 K% t2 r! j% L& j" i 刚才说过了,如果你的VTY线路没有配置密码的话,你将无法telnet连上它,它会报错:VTY线路没有配置密码。但是你可以取消VTY密码,这样就可以在没有密码的情况下进行telnet,处于安全考虑,此方法不推荐,配置如下:
N7 F7 s l3 k# b* q Router(config-line)#line vty 0 4
! {1 i6 ^$ S6 H) z! G Router(config-line)#no login
; C% ?6 k% x7 G Encryption Your Passwords
3 f' `; ~; `( m/ r2 Y 只有enable secret是加密的,当你在特权模式下输入sh running-config显示DRAM的配置文件时,其他密码将被罗列出来:) ]3 e; u I$ `4 b4 @( ^1 ~
Router#sh run
& ?; r. y5 ^/ R2 P5 [ (略)/ l: k$ y3 C+ a! W
!
# K' q$ I$ _: ?1 j o: W4 ? enable secret jhdflkdfg$#sdf$ V, ~& n# b, ]. ]: A
enable password 123+ j+ r _5 [& P2 c, m: A" J
!6 K& ?" T: s3 K/ a0 m& ?
(略)( o. B7 {' u9 J r
对密码进行加密:在全局配置模式下使用service password-encryption命令
% A% ~% ?9 [! G/ u6 ~ Banners. j* d F+ p; _
banner类似标语,问候语。最常用的是MOTD(message of the day),分界符用于分隔信息,但是分隔符不能出现在MOTD信息中,如下:7 A& O1 b6 B+ p1 K
Router(config)#banner motd #
: O! @# Q$ j/ t# H& ]8 a, w The Router is mine
' U* _; V" n* f0 i5 w% ?! o #7 Y! _+ D! I8 f6 Q
Router(config)#^Z(Ctrl+Z)
7 ^6 ^0 m1 I e; I8 H# K Router#exit1 ?: K; D1 {( i$ z) Q; |
Router con0 is now available6 a# K& N" t1 S* {$ R5 J, A4 _$ \
Press RETURN to get started. v2 e( s( F2 r0 R# m
The Router is mine
; d$ @/ `% o, R Router>
) k, x4 S* h8 G' ]4 A7 K9 Z, ] 其他的3种banner:
) Q9 P+ z8 N' {5 G1 w 1.exec banner
( Y7 u9 d& o/ w# T. z, ?+ c. d 2.incoming banner
$ i; r# r, q! r) ~, N 3.login banner
0 b8 a- g. [! [5 ? Router Interfaces4 U5 c2 Z! w2 c# f
配置router的接口,一般命令模式采用:interface type number的格式,比如:2 L7 C: i2 Y$ E0 E) D7 w
Router(config)#int ethernet 0
+ N; E N& F% h 但是Cisco的2600,3600,4000和7000等系列采用了物理卡槽和模块化的端口机制。因此,命令变化为:interface type slot/port,比如:" u# K& Y8 E F4 n! f6 I
Router(config)#int fastethernet 0, v# w/ B6 i T2 l4 c2 ?! A: f
% Imcomplete command5 f/ T6 V( B" S$ n8 X
Router(config)#int fastethernet 0?
1 ~5 A7 j5 x6 w) a1 J /; J V* S/ v$ j; i$ M2 m
Router(config)#int fastethernet 0/?1 D$ S; P% e0 o8 y! I+ R
Fastethernet interface number
$ K, n3 M- _! ?. p Router(config)#int fastethernet 0/1
4 C4 I$ _: o5 A! S. k. q. S% C 配置连接器的介质类型,使用media-type命令,不过这个一般是自动检测,如下:6 C: q/ `9 x; R' ~
Router(config)#int fa 0/0) ^5 A: ^, h) ]5 }1 L9 T
Router(config-if)#media-type ?
6 M! x9 l* x( A5 x1 |- h1 i# \% d 100BaseX Use RJ45 for -TX; SC F0 for -FX
9 h8 ?. d7 [6 H9 j. L6 G9 D MII Use MII connector2 E4 D: _0 v. T* _0 f' L& ~
Bring Up an Interface1 i" N2 {6 _+ S
打开和关闭1个接口,分别使用shutdown和no shutdown命令,当你关闭某个接口的时候,使用sh interfaces命令可以查看接口状态,并且你将看到以下输出:0 U2 V/ Q& v) v: r0 x: d s! [
Router#sh int e0
% h" N3 I2 _7 ~/ O" I/ Z, E8 @; G4 b Ethernet0 is administratively down,line protocol is down- p/ X. |2 O% N
(略)
: j. l$ _ _* G# f; e9 I 接口是关闭的,所以你要手动打开它,如下:1 s4 G8 V8 k8 m v4 P! ^
Router#conf t
; {2 W7 d+ _! B4 j Router(config)#int e0
0 L- J) N7 F1 N% j' X Router(config-if)#no shut7 _3 R, N& `" T9 ]
Router(config-if)#^Z
5 G; I% K% `1 @4 {& V, d3 W Router#sh int e0
K8 X# t& o k; \6 T/ c Ethernet is up,line protocol is up+ t( f9 H N7 O8 B, U
(略)/ W _: H A" x b/ A
Configuring an IP Address on an Interface0 m+ B" z, k D2 O8 K
给某个接口配置IP地址,使用ip address [address] [mask]命令,如下:
, c! D! d8 \) \# l3 U Router(config)#int e0( v; d$ c% m/ l1 u
Router(config-if)#ip address 172.16.10.2 255.255.255.0" H+ P1 W8 [3 l6 M0 X, |8 r
记得把接口打开:2 g1 y5 T2 ~! z# O* ^& ?9 k
Router(config-if)#no shut( q h+ o' g9 q" y+ ^
Router(config-if)#^Z
# C3 t" W" |, a: c3 ] 如果你需要在1个接口添加第二个子网地址,在末尾使用secondary参数,这将替换现有IP地址,如下:" U: l: X8 ~2 A( n) C
Router(config)#int e0
1 t$ l6 N* h% g: \/ m; I: N Router(config-if)#ip address 172.16.20.2 255.255.255.0 secondary: Z" F$ A/ a6 s( j# l4 n
Router(config-if)#^Z
$ `, G0 h# {* t) ?+ O" ^ 来验证下:2 _# J( ~$ r4 u2 y* a
Router#sh run
: ?5 M. n. M6 ^" ^; m (略)& H) ~3 v( Y0 ]# V9 u
!5 o7 J0 b' w% m: R+ t
interface Ethernet0; _, U) P: l$ l
ip address 172.16.20.2 255.255.255.0 secondary
6 a1 r2 M* I5 _) V( p: X ip address 172.16.10.2 255.255.255.0
' J! S+ Q' I U- p9 T3 t" y1 u !. q" r5 E* e7 H& K1 o5 C
Serial Interface Commands
) s, v: o8 U$ e% M E m: ?6 i# i! j Serial口一般是连接在CSU/DSU等类型的提供时钟频率的设备上。但是,假如你在个实验环境里采用了背对背配置,那么1端将作为DCE设备提供时钟频率。默认Cisco的router都是DTE,所以你必须让1个serial接口来提供时钟频率,采用的命令是:clock rate,如下:$ f) R. s3 ^1 q% p( R8 N+ N
Router(config)#int s0
/ S$ C4 L m0 F7 R L Router(config-if)#clock rate ?
2 o$ z5 X' P+ T9 X4 N Speed (bits per second)
+ R: @1 B$ p4 |0 Y( w9 E 1200
" K, {5 v( s6 c (略)1 g' c) _0 z. N/ }- D
56000
; f- {1 d# I/ Q* f% C$ F7 E 64000' K& L8 Z0 r* q3 Z% O9 G* k# u2 {
(略)
9 Y# F s0 H0 x7 ?" W: T8 V Router(config-if)#clock rate 64000# r: s* h6 d; P* w; K% f% s7 c
% Error: This commands applies only to DCE interfaces, b% V" _3 b1 u8 p% z+ ?7 v
Router(config-if)#int s1
* R" p$ S3 v/ O5 n1 k) }% G% e Router(config-if)#clock rate 64000
* W$ m7 i' T# n+ F! K 确定serial接口是否是DCE线缆使用sh controllers命令,如下:2 t8 [8 I* k+ d2 ^
Router>sh controllers s 0
" u1 \4 D9 D5 B" b6 A! G HD unit 0, idb=0x297DE8, driver structure at 0x29F3A0
% ~& ]- M3 D+ s Buffer size 1524 HD unit 0, V.35 DCE cable* B; @- f8 [: U4 {: c$ m# @% l
Cisco的router的默认serial连接带宽是T-1(1.544Mbps)。有的路由协议要以带宽做为度来进行衡量,所以,我们给它配置带宽,使用bandwidth命令,注意参数单位是kb,如下:. g7 ]0 ` G/ U/ I( J' j" H3 u
Router(config-if)#bandwidth ?( D" W v! _* q6 o' j
Bandwidth in kilobits, }: {. D4 P$ P+ s
Router(config-if)#bandwidth 64
8 x+ P a! q! |, N. e Hostnames
' K: B& p4 G r* {' y 给router配置主机名,使用hostname命令,这个是本地标志,不影响router在Internet上的工作,注意回车立即生效,如下:
( s8 u3 f2 ]& y5 W2 p) J Router(config)#hostname Noko" ^2 j+ c0 M8 u$ N# ?& c
Noko(config)#hostname Noco
% `$ F+ C: U' c. _8 p, f Noco(config)#
2 e h7 S6 p& f. w, o+ u7 x4 K# r( V Descriptions) t( h: f) v$ s* b; Y
description命令:本地标志,可以给接口加描述,以便用于区分,如下:
! h5 R, C/ M# g$ b& Q) N3 s Noco(config)#int e0
4 F7 Z! G/ R: ~ ] Noco(config-if)#description Sales LAN
/ \( ~1 b0 T; M6 K# A Noco(config-if)#^Z3 p+ `+ ^# T6 X5 R
来验证下:$ ~! D( g: p, n" I
Noco#sh int e0+ c1 Y# Z2 ?2 u |
(略)
; H% \+ r3 n9 ^7 T* ] Description: Sales LAN/ L0 A9 G. z& m% S' ~% d8 o+ f! N
(略)
0 j6 a; O$ u4 J- X1 j# B4 C Viewing and Saving Configurations: V& w8 E3 q% ~
将running-config(DRAM)的文件复制到startup-config(NVRAM)里,使用copy running-config startup-config命令:
% ]& I) d, A+ V0 K Noco#copy run start
1 Y, f4 {* q1 F3 o, o 可以使用erase startup-config命令删除startup-config文件,如下:
4 d: O) t( L* W# Q8 @$ g Noco#erase startup-config4 a6 _" j' L3 x6 r$ b
(略)% g% b" p% h/ f
Noco#sh start
- `9 }$ z5 ]1 Y( F* ?; g %% Non-volatile configuration memory is not present
5 q4 S% o) z; s( V+ [$ _3 y) [ 假如在这个情况下在特权模式使用reload命令重新启动router,将进入setup模式
6 F$ h3 v4 F* q/ q; ] Verifying Your Configuration
5 m# c' h" \+ T* k* m3 e ping:采用了ICMP echo requests和replies: r! y$ U4 p6 c, @
traceroute:使用ICMP和IP TTL来跟踪包所经过的路径- x- B u! e& ?. W Q
Verifying with the show ip interface Command/ E5 r5 ?9 }3 b9 y% ?6 W
show ip interface:提供router接口的层3信息,包括:) k0 `1 C% t% H6 |
1.接口状态
* ^1 d3 w% @' A8 P1 y 2.IP地址和掩码0 d7 u. a+ N6 W3 [; B2 s* u
3.访问列表(access-list)信息/ q6 g/ f4 s7 h: }
4.一些其他的基本的IP信息
9 U# j% Y% y4 u1 ^ Using the show ip interface brief Command
. g! B; S: j: x- d3 S5 h show ip interface brief:和show ip interface类似,只是提供简洁点的总结信息
7 @1 \7 Q/ u' q5 ~( l/ r4 }5 r Using the show controllers Command
5 E( @3 ~) F1 x& v( [ sh controllers:显示物理接口的信息,还提供serial口线缆信息,如下:
7 }: D% m! h# D9 H Router#sh controllers serial 0/08 a9 S% d/ { Q( n- `
(略)
/ h2 M! `1 ?: N" Q9 K* A1 j7 d buffer size 1524 HD unit 0, V.35 DTE cable
& e( m& d$ I6 i; ^ O (略)
9 P, w! P( Q |# r0 e Router#sh controllers serial 0/1
. V9 l/ Z6 t! g (略)6 C. A7 C. `0 @0 q
buffer size 1524 HD unit 1, V.35 DCE cable
6 m/ ?! ?0 p" f8 N# B" V/ l (略)。(Written by 红头发,ChinaITLab BBS) |