需求:
讓R1到達3.3.3.0網絡優選R2到達
配置:
R1
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 13.1.1.1 255.255.255.0
ip ospf network broadcast
duplex half
!
interface Serial1/0
ip address 12.1.1.1 255.255.255.0
ip ospf network broadcast
serial restart-delay 0
router ospf 1
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.1 0.0.0.0 area 0
network 12.1.1.1 0.0.0.0 area 0
network 13.1.1.1 0.0.0.0 area
line con 0
exec-timeout 0 0
password console
logging synchronous
login
line aux 0
line vty 0 4
R2
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Serial1/0
ip address 12.1.1.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 23.1.1.1 255.255.255.0
serial restart-delay 0
router ospf 1
router-id 2.2.2.2
log-adjacency-changes
network 2.2.2.2 0.0.0.0 area 0
network 12.1.1.1 0.0.0.0 area 0
network 12.1.1.2 0.0.0.0 area 0
network 23.1.1.1 0.0.0.0 area 0
R3
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
ip address 13.1.1.2 255.255.255.0
duplex half
!
interface Serial1/0
ip address 23.1.1.2 255.255.255.0
serial restart-delay 0
router ospf 1
router-id 3.3.3.3
log-adjacency-changes
network 3.3.3.3 0.0.0.0 area 0
network 13.1.1.1 0.0.0.0 area 0
network 13.1.1.2 0.0.0.0 area 0
network 23.1.1.2 0.0.0.0 area 0
驗證配置;
R1#show ip route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 12.1.1.2, 00:36:26, Serial1/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 13.1.1.2, 00:36:26, FastEthernet0/0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/65] via 13.1.1.2, 00:36:26, FastEthernet0/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, FastEthernet0/0
R1選擇以太網接口直接到達R3的3.3.3.0網絡,因爲這條路徑的COST(度量值)最低,如果選擇R2到達R3,COST是129(64+64+1)
那爲什麼以太網接口的連得路徑度量值是2。是這樣的嗎(1+1),環回接口的鏈路度量值是1
修改R1和R2接口的OSPF度量值
R1(config)#int s1/0
R1(config-if)#ip ospf cost 1
R2(config)#int s1/1
R2(config-if)#ip ospf cost 1
再次查看R1路由表
R1#show ip route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 12.1.1.2, 00:00:07, Serial1/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/66] via 12.1.1.2, 00:00:07, Serial1/0
23.0.0.0/24 is subnetted, 1 subnets
O 23.1.1.0 [110/65] via 12.1.1.2, 00:00:07, Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, FastEthernet0/0
這一步中因爲度量值兩條路徑是一樣的都是2—實驗測試中(我也納悶),路由表中任然是顯示以太網接口的路徑,後來我就改變R1和R3以太網接口
的度量值,結果才顯示路徑選取走R2到達3.3.3.0網段。但是這個度量值爲什麼是66,我又悶啊啊?????
R1#traceroute 3.3.3.3
Type escape sequence to abort.
Tracing the route to 3.3.3.3
1 12.1.1.2 20 msec 64 msec 80 msec
2 23.1.1.2 92 msec 96 msec *
總結與思考:
本實驗收穫:
1.ospf中不能宣告空接口,如:
network 12.1.1.1 0.0.0.0 area 0
network 12.1.1.2 0.0.0.0 area 0
我根本就沒有配置12.1.1.1 的接口,這樣宣告不會找到鄰居的當然鄰居路由表中是不會有到你的ospf路由表,本實驗中因爲R2和R3這樣宣告空接口,致使鄰居R1上沒有ospf的路由表
2.爲什麼各個路由器的Id的Ip地址非直連的都是以32位的顯示在路由表中,而我的掩碼是24位
Router-id是以IPv4的形式定義的 本地有效,環回口不管你怎樣配置 都是以32位顯示在路由表裏的
3,當修改後不起作用時,可更改以前路徑上的路由器接口的度量值,如上,但是這個度量值的計算不明白??
4。ospfCOST修改的三種方法:a.修改接口帶寬,b,接口下IP ospf cost (1-65535)命令,c.參考帶寬 auto-cost reference-bandwidth ref-bw(以Mbits爲單位的參考帶寬,取值爲1-4294967,默認爲100)