R1:
R1>enable
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface serial 0/1/0
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#clock rate 64000
R2:
R2>en
R2#conf t
R2(config)#int s
R2(config-if)#ip add 192.168.2.2 255.255.255.0
R2r(config-if)#no shutdown
R2(config-if)#clock rate 64000
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int f0/0
R2(config-if)#ip address 192.168.3.254 255.255.255.0
R2r(config-if)#no shutdown
這時再給PC1和PC2配置ip
PC0:192.168.1.1
PC1:192.168.3.1
配置過IP以後我們來測試一下連通性:
PC1與網關:
PC2>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與網關:
PC1>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正常
兩個路由器直接的通訊:
R2#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正常
PC1與PC2:
PC1>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, Serial
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.0是R1需要學習的目標網絡地址,192.168.2.2爲下一跳地址或者接這個路由信息出去的接口
R2:
Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
同上
這時我們再分別看R1和R2的路由表裏有沒有對方的網段信息:
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, Serial
C 192.168.3.0/24 is directly connected, FastEthernet0/0
這時彼此都有對方的網段信息了,這時我們再來測試一下PC1和PC2能否正常通訊:
PC1>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。
好了,謝謝大家,實驗做到這裏就完成了,謝謝觀看,下次再見。