實驗環境:Dynamips 虛擬實驗室,三台 2621 路由器
實驗目的:掌握 ip classless 命令的作用
拓樸圖:
基本配置
London 路由器
Router# configure terminal
Router(config)# hostname London
London(config)# line console 0
London(config-line)# loggin synchronous
London(config-line)# exit
London(config)# interface loopback 0
London(config-if)# ip address 10.1.1.1 255.255.255.0
London(config-if)# no shutdown
London(config-if)# exit
London(config)# interface serial 0/1
London(config-if)# ip address 172.16.1.1 255.255.255.0
London(config-if)# no shutdown
London(config-if)# exit
Florence路由器
Router# configure terminal
Router(config)# hostname Florence
Florence (config)# line console 0
Florence (config-line)# loggin synchronous
Florence (config-line)# exit
Florence (config)# interface loopback 0
Florence (config-if)# ip address 10.3.3.1 255.255.255.0
Florence (config-if)# no shutdown
Florence (config-if)# exit
Florence (config)# interface serial 0/0
Florence (config-if)# ip address 172.16.1.2 255.255.255.0
Florence (config-if)# clock rate 64000
Florence (config-if)# no shutdown
Florence (config-if)# exit
Florence (config)# interface serial 0/1
Florence (config-if)# ip address 172.16.2.2 255.255.255.0
Florence (config-if)# clock rate 64000
Florence (config-if)# no shutdown
Florence (config-if)# exit
Denver路由器
Router# configure terminal
Router(config)# hostname Denver
Denver (config)# line console 0
Denver (config-line)# loggin synchronous
Denver (config-line)# exit
Denver (config)# interface loopback 0
Denver (config-if)# ip address 10.2.2.1 255.255.255.0
Denver (config-if)# no shutdown
Denver (config-if)# exit
Denver (config)# interface serial 0/0
Denver (config-if)# ip address 172.16.2.1 255.255.255.0
Denver (config-if)# no shutdown
Denver (config-if)# exit
在London及Denver路由器上配置預設路由
London(config)# ip route 0.0.0.0 0.0.0.0 172.16.1.2
Denver(config)# ip route 0.0.0.0 0.0.0.0 172.16.2.2
在 Florence路由器上配置靜態路由
Florence(config)# ip route 10.1.1.0 255.255.255.0 172.16.1.1
Florence(config)# ip route 10.2.2.0 255.255.255.0 172.16.2.1
London路由器的路由表
London# show ip route
......
Gateway of last resort is 172.16.1.2 to network 0.0.0.0
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, Serial0/1
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback0
S* 0.0.0.0/0 [1/0] via 172.16.1.2
Florence路由表
Florence# show ip route
......
Gateway of last resort is not set
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.1.0 is directly connected, Serial0/0
C 172.16.2.0 is directly connected, Serial0/1
10.0.0.0/24 is subnetted, 3 subnets
C 10.3.3.0 is directly connected, Loopback0
S 10.2.2.0 [1/0] via 172.16.2.1
S 10.1.1.0 [1/0] via 172.16.1.1
Denver路由表
Denver# show ip route
......
Gateway of last resort is 172.16.2.2 to network 0.0.0.0
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.2.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
C 10.2.2.0 is directly connected, Loopback0
S* 0.0.0.0/0 [1/0] via 172.16.2.2
由London路由器的Loopback 0端口ping 10.3.3.1
London# ping
Protocol [ip]:
Target IP address: 10.3.3.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 10.1.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/26/36 ms
由Denver路由器的Loopback 0端口ping 10.3.3.1
Denver# ping
Protocol [ip]:
Target IP address: 10.3.3.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 10.2.2.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/36/48 ms
在London及Denver路由器上去掉ip classless命令後,再次由Loopback 0端口ping 10.3.3.1
London(config)# no ip classless
Denver(config)# no ip classless
London# ping
Protocol [ip]:
Target IP address: 10.3.3.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 10.1.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Denver# ping
Protocol [ip]:
Target IP address: 10.3.3.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 10.2.2.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
OK!實驗成功
上述最後的實驗無法 ping 通,是因為在 London 及 Denver 路由表中雖然有 10.0.0.0 主網段,但是並沒有 10.3.3.0 網段的具體路由,而且 ip classless 命令也被關閉,所以路由器丟棄該封包(因為思科路由器預設是以 Classful 在運作的,如果 ip classless 命令開啟,則路由器就會以 Classless的方式運作,在 Cisco IOS 11.3 版以後就預設開啟)。
如果在 Florence 路由器上再建立 Loopback 1 端口,IP 位址設成 11.1.1.1/24
則由 London 路由器上的 Loopback 0 端口 ping 11.1.1.1 時,是會透過預設路由轉發封包的(因為在路由表中沒有有關 11.0.0.0 主網段的任何路由訊息)。
沒有留言:
張貼留言