cisco 静态路由

      

   

   R:

R>enable

R(config)#interface fastEthernet 0/0

R(config-if)#ip address 192.168.1.254 255.255.255.0

R(config-if)#no shutdown

 

R(config-if)#exit

R(config)#interface serial 0/1/0

R(config-if)#ip address 192.168.2.1 255.255.255.0

R(config-if)#no shutdown

R(config-if)#clock rate 64000

 

 

R:

R>en

R#conf t

R(config)#int s0/1/1

R(config-if)#ip add 192.168.2.2 255.255.255.0

Rr(config-if)#no shutdown

R(config-if)#clock rate 64000

 

R#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

R(config)#int f0/0

R(config-if)#ip address 192.168.3.254 255.255.255.0

Rr(config-if)#no shutdown

 

这时再给PC1和PC2配置ip

PC0:192.168.1.1

PC1:192.168.3.1

 

配置过IP以后我们来测试一下连通性

PC1与网关:

PC>ping 192.168.3.254

 

Pinging 192.168.3.254 with 32 bytes of data:

 

Reply from 192.168.3.254: bytes=32 time=78ms TTL=255

Reply from 192.168.3.254: bytes=32 time=31ms TTL=255

Reply from 192.168.3.254: bytes=32 time=31ms TTL=255

Reply from 192.168.3.254: bytes=32 time=31ms TTL=255

 

Ping statistics for 192.168.3.254:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 31ms, Maximum = 78ms, Average = 42ms

OK正常

 

 

PC1与网关:

PC>ping 192.168.1.254

 

Pinging 192.168.1.254 with 32 bytes of data:

 

Reply from 192.168.1.254: bytes=32 time=62ms TTL=255

Reply from 192.168.1.254: bytes=32 time=31ms TTL=255

Reply from 192.168.1.254: bytes=32 time=32ms TTL=255

Reply from 192.168.1.254: bytes=32 time=31ms TTL=255

 

Ping statistics for 192.168.1.254:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 31ms, Maximum = 62ms, Average = 39ms

OK正常

 

两个路由器直接的通讯:

R#ping 192.168.2.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 16/28/32 ms

OK正常

 

PC1PC2

PC>ping 192.168.3.1

 

Pinging 192.168.3.1 with 32 bytes of data:

 

Reply from 192.168.1.254: Destination host unreachable.

Reply from 192.168.1.254: Destination host unreachable.

Reply from 192.168.1.254: Destination host unreachable.

Reply from 192.168.1.254: Destination host unreachable.

 

Ping statistics for 192.168.3.1:

Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

目标主机不可达

这时为什么呢?因为PC双方根本就不知道对方在哪,所以就无法到达,我们在来看一下路由表:

R1:

C    192.168.1.0/24 is directly connected, FastEthernet0/0

C    192.168.2.0/24 is directly connected, Serial0/1/0

 

这个路由表里根本就没有记录192.168.3.0网段的地址,我们在来看一下R2的路由表:

C    192.168.2.0/24 is directly connected, Serial0/1/1

C    192.168.3.0/24 is directly connected, FastEthernet0/0

这里也没有192.168.1.0网段的地址;所以嘛,这两个网段就没有办法访问,那怎么才能访问呢?

   这就用到要设置静态路由了

R1:

Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2

192.168.3.0R1需要学习的目标网络地址,192.168.2.2为下一跳地址或者接这个路由信息出去的接口

R2:

Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1

同上

这时我们再分别看R1R2的路由表里有没有对方的网段信息:

R1:

Router#show ip route

C    192.168.1.0/24 is directly connected, FastEthernet0/0

C    192.168.2.0/24 is directly connected, Serial0/1/0

S    192.168.3.0/24 [1/0] via 192.168.2.2

 

R2:Router#show ip route

Router#show ip route

S    192.168.1.0/24 [1/0] via 192.168.2.1

C    192.168.2.0/24 is directly connected, Serial0/1/1

C    192.168.3.0/24 is directly connected, FastEthernet0/0

 

这时彼此都有对方的网段信息了,这时我们再来测试一下PC1PC2能否正常通讯:

PC>ping 192.168.3.1

 

Pinging 192.168.3.1 with 32 bytes of data:

 

Reply from 192.168.3.1: bytes=32 time=93ms TTL=126

Reply from 192.168.3.1: bytes=32 time=94ms TTL=126

Reply from 192.168.3.1: bytes=32 time=94ms TTL=126

Reply from 192.168.3.1: bytes=32 time=93ms TTL=126

 

Ping statistics for 192.168.3.1:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 93ms, Maximum = 94ms, Average = 93ms

 

OK。

好了,谢谢大家,实验做到这里就完成了,谢谢观看,下次再见。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章