a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 156|回复: 1

[CCNA] 菜鸟学习CCNA-静态路由和默认路由

[复制链接]
发表于 2012-8-3 20:28:11 | 显示全部楼层 |阅读模式
一、使用静态路由的优缺点  静态路由的缺点是不能动态反映网络拓扑,当网络拓扑发生变化时,管理员就必须手工改变路由表;然而静态路不会占用路由器太多的CPU 和RAM 资源,也不占用线路的带宽。如果出于安全的考虑想隐藏网络的某些部分或者管理员想控制数据转发路径,也会使用静态路由。在一个小而简单的网络中,也常使用静态路由,因为配置静态路由会更为简捷。
. H( D2 }. b6 m& S/ s& I2 |; n, X  [4 {  二、配置静态路由的命令
( j% I5 n$ `  r( ~6 a" \5 o. m  ip route 目的网络 掩码 { 网关地址 | 接口 }
$ F5 |/ d  y! X. _. k  例子:ip route 192.168.1.0 255.255.255.0 s0/0
+ c0 f4 ]# q# x6 ?. Q; x" ~  例子:ip route 192.168.1.0 255.255.255.0 12.12.12.2
2 C9 i' d4 I, ^. h& y  在写静态路由时,如果链路是点到点的链路(例如PPP 封装的链路),采用网关地址和9 c& N% _. k" h( s2 z& A' y6 w: o
  接口都是可以的;然而如果链路是多路访问的链路(例如以太网),则只能采用网关地址,
" f, j( I$ ?  v4 P  e9 m9 X  即不能:ip route 192.168.1.0 255.255.255.0 f0/0 。
/ `4 d. v# M" {8 b; }8 a4 M0 s  三、静态路由实验# R& N  ?! h; c, u0 T
  网络拓扑图:
" V$ Y. ?* ?  ~$ D" [9 o* G
! y, w) F" S' J- a1 r% N0 ?/ f) e+ K* p 4 ]3 s. j+ D; i5 P! X
  具体配置命令:' [, v' p" H( h5 S
  Route A配置:
+ o+ o; F5 |$ O! o0 t  Router>enable- C) z. Q7 |" x1 r7 P' f$ Z5 F
  Router#config terminal$ `9 v& M, l; I2 ?. r+ L5 A8 h
  Router(config)#hostname RouteA //修改路由器名称
; _5 x) C# |/ R4 Z* ]  RouteA(config)#int f0/1         //进入FO/1接口模式
% M) F3 Q/ ]4 E! c" n  RouteA(config-if)#ip address 1.1.1.2 255.255.255.0 //配置ip0 r( ?) y9 J! C
  RouteA(config-if)#no shutdown //开启端口5 Z% |" c" j# k' x
  RouteA(config-if)#int s0/0
1 p6 K: r- L4 O2 d2 ^4 j  RouteA(config-if)#ip address 192.168.12.1 255.255.255.0/ d; w; M0 A! f$ V* c, {0 z
  RouteA(config-if)#no shut
) ]8 {8 c$ a" v3 W! p  RouteA(config-if)#exit
* Q1 j5 F  m! K  [  I/ q' Z0 |  RouteA(config)#exit
, I* {% }/ D% ]; Y# Z4 E- }  RouteA#copy run start   //保存当前配置
; v% f- X6 a' Z; E' I' Z  Destination filename [startup-config]?
7 \* T8 s! n# J" t  Building configuration...
  }# i5 g, i, D  [OK]
/ C. z& ?% ^, d, B+ Y  Route B配置:" {: u- q( |7 o  R* K7 Q
  Router>enable! L7 x' N& J5 E7 k9 a: }9 ~
  Router#config terminal0 a- m3 b  \6 O- o
  RouterB(config)#hostname RouterB
9 d! [! [3 {* H  ^( }  RouterB(config)#int f0/1, X2 }7 ^4 m) Y1 s9 B
  RouterB(config-if)#ip address 2.2.2.1 255.255.255.0
% t" c9 |7 v" w, [$ S8 W8 ]  RouterB(config-if)#no shut3 L$ \6 W3 C5 o3 M* R
  RouterB(config-if)#int s0/01 j  K3 g8 G& F! n1 E2 w
  RouterB(config-if)#ip address 192.168.12.2 255.255.255.03 g" o% t4 w2 K' b* Q$ e1 g
  RouterB(config-if)#clock rate 128000   //配置时钟
' y! _. X. X: h  RouterB(config-if)#no shut, Y+ A* `( ?2 ^, y  C1 J
  RouterB(config)#in s0/1( ?" f+ @4 X6 L% ~
  RouterB(config-if)#ip address 192.168.23.1 255.255.255.0
" d2 `3 ]5 }6 X6 v5 A, d  RouterB(config-if)#clock rate 128000' y$ t" m. H, E7 A
  RouterB(config-if)#no shut
: m* b( D2 d! d) f) s( @  RouterB(config-if)#
) G- \7 C* g3 z# A9 L4 i  RouterB(config-if)#exit
" ^, H4 a5 A4 w' y[NextPage]# |/ I- x; h1 A
  Route C配置:
" x; `& e' G& m. x  Router>enable/ Q/ E3 P' {5 n% Y
  Router#config terminal
2 y* i& M$ u3 W; _9 S1 R; D  Router#hostname RouterC: l: f' w. |( ?( B
  RouterC(config)#int s0/0
7 h- @3 e& O: E/ D! Z1 w$ Y" l4 G  RouterC(config-if)#ip address 192.168.23.2 255.255.255.0
) N+ k* k, M& Y  RouterC(config-if)#no shut
& ~; ^7 B2 M$ P( K& D+ L, W6 y  RouterC(config-if)#int f0/1
  w# N0 e# ?6 U9 ?  RouterC(config-if)#ip address 3.3.3.1 255.255.255.0
! b8 }8 D/ H+ T4 X2 z3 V8 p' V  RouterC(config-if)#no shut! K( o- ~9 o& }* U5 [' h1 P
  RouterC(config-if)#exit0 I8 ~" ~1 n# `" `) |# a
  RouterC(config)#exit
1 `2 F8 w$ j6 N" O  RouterC#copy run start; k( ]4 t1 q+ c, `
  Destination filename [startup-config]?
" J& z! d4 u- L+ v4 i  Building configuration...
9 S% B0 f( ?1 |7 z( K; a6 y, F; b) s  [OK]
. [. G/ P* N1 K. G& e  Router>enable6 @2 O/ t* C3 p* L3 C4 |+ Q& X
  Router#config terminal
& N; G/ H/ K. a: M  u, v* _4 V  Router(config)#hostname RouteA //修改路由器名称
% l' B3 f& r' z1 c( [  RouteA(config)#int f0/1         //进入FO/1接口模式
( f! g( j7 {9 M1 N: C/ j# L  RouteA(config-if)#ip address 1.1.1.2 255.255.255.0 //配置ip, H2 T; ~2 @' F
  RouteA(config-if)#no shutdown //开启端口
3 J6 E8 w* R8 }6 @! B  RouteA(config-if)#int s0/0& d4 L, a4 w4 R$ H& z
  RouteA(config-if)#ip address 192.168.12.1 255.255.255.0
/ R( D. }- }/ q& q  RouteA(config-if)#no shut
$ r9 W- L% E* q6 U  RouteA(config-if)#exit1 C4 g( b' J5 a3 f- a+ z
  RouteA(config)#exit
- P! k# f. Q( u6 N, b( ]  RouteA#copy run start   //保存当前配置
6 L: A; ^8 U& z' g6 j1 \# _8 K/ ~  Destination filename [startup-config]?
( @; L, k4 F, N1 Z$ L6 i  Building configuration...9 ?0 ~0 V9 d2 U5 d% }( ]$ F$ T
  [OK]* z, B  Q  P0 z# W
  Router>enable
; i$ \7 A6 }. u  K9 q9 u, O$ M7 z+ n7 d& M$ u  Router#config terminal; D6 n# A- x% l; m& X
  RouterB(config)#hostname RouterB
4 j; x+ A- V0 l6 b  RouterB(config)#int f0/1* s$ a9 N. Z* y1 d" S
  RouterB(config-if)#ip address 2.2.2.1 255.255.255.05 o1 s  ^! D/ ]" s0 F! C3 }
  RouterB(config-if)#no shut
: ?- l. @1 l1 w1 Q9 k* P. m  RouterB(config-if)#int s0/08 e1 ]4 ~0 b& k  s% j8 q# J
  RouterB(config-if)#ip address 192.168.12.2 255.255.255.05 f/ ^) `! K2 x- Z- T
  RouterB(config-if)#clock rate 128000   //配置时钟
' i2 F8 \4 M( z1 \4 a% c- _0 r  RouterB(config-if)#no shut
* ~- [$ \( T! ^% I. M' n& M  RouterB(config)#in s0/1- x4 X  @  S! W; O
  RouterB(config-if)#ip address 192.168.23.1 255.255.255.0
% A7 ?5 f  ~4 V; [# u* I  RouterB(config-if)#clock rate 128000
( D% `4 \1 _& p7 a& g  RouterB(config-if)#no shut# e6 j8 ?8 A. V; E
  RouterB(config-if)#
) b& ^% R+ D/ }/ ^! y! E# i  RouterB(config-if)#exit: z0 |3 q/ G4 F% S5 H
  Router>enable. u& T' B1 o2 {+ @& |
  Router#config terminal
6 C% t* P# P' ^; t( }+ ~) t3 p  Router#hostname RouterC
# J  Q! R* S# c2 \- q6 j  RouterC(config)#int s0/0, f% l% d  u* m

2 z) P. c9 \, k2 Y1 J  j6 c( G  RouterC(config-if)#ip address 192.168.23.2 255.255.255.0
回复

使用道具 举报

 楼主| 发表于 2012-8-3 20:28:12 | 显示全部楼层

菜鸟学习CCNA-静态路由和默认路由

</p>  RouterC(config-if)#no shut
+ U$ h# M9 u) v# f8 q% o' {  RouterC(config-if)#int f0/1" G, b# a$ g" t$ Q0 E( h3 {
  RouterC(config-if)#ip address 3.3.3.1 255.255.255.09 ?: b/ W% W# u) D# i
  RouterC(config-if)#no shut
4 A/ T+ {9 V1 ~# @6 q  RouterC(config-if)#exit2 }& }+ X: Z  d& C0 o$ ~
  RouterC(config)#exit
; ?6 b: M! s" d9 p1 x. A  RouterC#copy run start
/ ~, F, E$ {! W, {  Destination filename [startup-config]?
" i1 e+ ]: z; h  Building configuration...
# Q5 K$ `2 E" Q+ F. [) W" l  [OK]; r( L" Y( z/ U9 C9 L  m
  配置完成可以使用PING 命令进行检测
  N) m4 v: H, a2 N! V, y% P6 B& ^- Z  删除静态路由配置:
' O$ C4 j$ {5 }* H& J  _& i7 a  RouteA(config)#ip route 2.2.2.0 255.255.255.0 s0/0
! |0 i$ C) r6 `  RouteA(config)#ip route 3.3.3.0 255.255.255.0 192.168.12.26 g3 U* }9 o+ Q& o( N$ w
  RouterB(config)#ip route 1.1.1.0 255.255.255.0 s0/0
* p1 [; Y3 Y7 u% P0 m: d2 @8 x, c& @  RouterB(config)#ip route 3.3.3.0 255.255.255.0 s0/1; D0 q5 {( D, S/ ^% t
  RouterC(config)#ip route 2.2.2.0 255.255.255.0 s0/0% u  w$ u. H8 T5 b7 u7 B
  RouterC(config)#ip route 1.1.1.0 255.255.255.0 192.168.23.1
1 G8 G1 `: X! H  查看静态路由的配置情况:Router#show  ip  route
1 ]2 H/ p% r" s! g  注意:3 b& B+ j: {) K8 g+ s& A% D
  如果是点对点的链路,注意使用本路由器上的接口,反之则为:下一跳ip, O: i; z0 a' W1 y: v
  区分DCE和DTE:RS-232接口是DTE(数据终端设备)和DCE(数据通信设备)之间的一个接口,DTE包括计算机、终端、串口打印机等设备;对于标准的串行端口,通常从外观就能判断是DTE还是DCE,DTE是针头(俗称公头),DCE是孔头(俗称母头),这样两种接口才能接在一起。DCE端需要设置时钟,Cisco的串口线 模块wic-1T, NM-4T, NM-4A/S,两头都是60针,两端分别标有DCE,DTE,可以分别插入 DB60 接口上。' b+ G' P( \8 l% k
  默认路由设置6 \5 [3 O/ @/ {2 g' {4 U
  默认路由是一种特殊的静态路由,指的是当路由表中与包的目的地址之间没有匹配的表项时路由器能够做出的选择。6 T9 n( V6 [* ?- F3 X
  命令格式:只是把目的地ip和子网掩码改成0.0.0.0和0.0.0.0。
9 V+ J% ~2 O8 S& A  删除静态路由:) ~% e( ?3 \( y) `  B
  删除静态路由的命令格式:no ip route ip地址 子网 接口/下一跳ip2 M2 b1 C9 [) I+ x* I8 y' f! f8 Q
  RouteA(config)#no ip route 2.2.2.0 255.255.255.0 s0/07 S0 Q& c1 B$ C4 T
  RouteA(config)#no ip route 3.3.3.0 255.255.255.0 192.168.12.2
3 g- Q1 q# @7 v3 F  RouterC(config)#no ip route 2.2.2.0 255.255.255.0 s0/0
7 y+ o( R6 f8 q( l1 z  RouterC(config)#no ip route 1.1.1.0 255.255.255.0 192.168.23.1
7 b) ]8 T- c3 ?; g* u  上图具体配置:
. r9 O1 A8 {& W/ l( y' g* [  RouteA(config)#ip route 0.0.0.0  0.0.0.0  s0/0* \4 @: b, l$ y6 b8 H; D8 }1 a
  RouteB(config)#ip route 0.0.0.0  0.0.0.0  s0/0
  @% {8 N$ G' Y1 ]$ C  配置完成可以使用ping命令进行检测
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-5 16:56 , Processed in 0.273564 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表