三、配置静态路由
方 法 一:使用直连的下一路由的接口地址
实验拓扑:
![]()
1、ip地址表:
R1 S2/0 192.168.10.1/24
R2 S2/0 192.168.10.2/24
R2 S3/0 192.168.20.1/24
R3 S2/0 192.168.20.2/24
2、
R1的配置:
Router>en
Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R1 R1(config)#interface serial 2/0//进入S2/0 R1(config-if)#ip address 192.168.10.1 255.255.255.0//接口配置ip R1(config-if)#no shutdown//激活接口
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
R1(config-if)#exit R1(config)#ip route 192.168.20.0 255.255.255.0 192.168.10.2//访问20网段的路由指向R2
S2/0
R1(config)#exit %SYS-5-CONFIG_I: Configured from console by console R1#writ Destination filename [startup-config]? Building configuration... [OK] R1#
R2的配置:
Router>en
Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R2 R2(config)#interface serial 2/0 R2(config-if)#ip address 192.168.10.2 255.255.255.0 R2(config-if)#no shutdown//激活接口,此时本口与对端口处于up状态
%LINK-5-CHANGED: Interface Serial2/0, changed state to up
R2(config-if)#clock rate 64000//设置时钟频率为64000 R2(config-if)# %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up R2(config-if)#exit R2(config)#interface serial 3/0 R2(config-if)#ip address 192.168.20.1 255.255.255.0 R2(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial3/0, changed state to down
R2(config-if)#clock rate 64000 R2(config-if)#exit R2(config)#exit %SYS-5-CONFIG_I: Configured from console by console R2#write Destination filename [startup-config]? Building configuration... [OK] R2#
R3的配置:
Router>en
Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R3 R3(config)#interface serial 2/0 R3(config-if)#ip address 192.168.20.2 255.255.255.0 R3(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial2/0, changed state to up
R3(config-if)# %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up R3(config-if)#exit R3(config)#exit %SYS-5-CONFIG_I: Configured from console by console R3#write Destination filename [startup-config]? Building configuration... [OK] R3#
验证配置:
R1#ping 192.168.10.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 68/79/104 ms
R1#ping 192.168.10.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 34/39/45 ms
R1#ping 192.168.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 34/37/42 ms
R1#ping 192.168.20.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.2, timeout is 2 seconds: ..... Success rate is 0 percent (0/5)
R1#
//R1 ping 192.168.20.2 不通,原因是R3上没有设置去192.168.1.0/24网段的路由
R3的配置:
R3(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1
验证配置:
R1#ping 192.168.20.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 69/77/88 ms
R1#
不知道写没写清楚,希望大家多提出意见和建议,小弟不胜感激!!!!!
本文出自 51CTO.COM技术博客
|
转载于:https://blog.51cto.com/headlessfly/221226