Yêu cầu
-
Thực hiện các cấu
hình cơ bản cho mỗi router
-
Cấu hình định tuyến
trên tất cả các router
-
Cấu hình thay đổi
Router-ID
-
Thực hiện các lệnh
show kiểm tra hoạt động của OSPF
-
Cấu hình COST
trong ospf
-
Cấu hình thay đổi
thời gian Hello-interval và Dead-interval
Hướng dẫn
Công việc 1
: Thực
hiện các cấu hình cơ bản cho mỗi router.
Công việc 2
: Cấu
hình định tuyến trên tất cả các router.
- Gán IP cho các interface như
hình vẽ
- Bật OSPF bằng 2 cách :
Cách 1 Cấu hình
quảng bá đường mạng (network/subnet work)
Router1(config)#router ospf 1
Router1(config-router)#network 172.16.1.16 0.0.0.15
area 0
Router1(config-router)#network 192.168.10.0 0.0.0.3
area 0
Router1(config-router)#network 192.168.10.4 0.0.0.3
area 0
Cách 2 Cấu hình
trực tiếp đến IP của từng cổng
Router1(config)#router ospf 1
Router1(config-router)#network 172.16.1.17 0.0.0.0
area 0
Router1(config-router)#network 192.168.10.1 0.0.0.0
area 0
Router1(config-router)#network 192.168.10.5 0.0.0.0
area 0
- Cấu hình tương tự cho router 2 và router 3
Công việc 3
: Cấu
hình thay đổi Router ID
Số
Router ID của giao thức OSPF là duy nhất cho mỗi router tham gia vào định tuyến
OSPF. Router ID có dạng của một địa chỉ IP. Các router Cisco được cấp Router ID
bởi một trong ba cách sau đây (xếp theo độ ưu tiên từ cao đến thấp)
1.
Gán bằng lệnh router-id.
Router1(config)#router ospf 1
Router1(config-router)#router-id 1.1.1.1
2.
Địa chỉ IP cao nhất trong các địa chỉ IP loopback của router.
3.
Địa chỉ IP cao nhất trong các địa chỉ IP của các cổng đang ở trạng thái active.
ð Sau khi thay đổi router-id để có tác dụng lên router
ta phải :
-
khởi động lại
router bằng lệnh reload
-
hoặc chạy lệnh : clear ip ospf process (chọn yes)
ð Router ID được hiển thị trong kết quả xuất ra của các
câu lệnh :
#show ip protocols
#show
ip ospf
#show ip ospf interface
ð Tưong tự router id của router 2, router 3 là : 2.2.2.2 và 3.3.3.3
Router1#show ip protocols
Routing
Protocol is "ospf 1"
Outgoing update filter list for all
interfaces is not set
Incoming update filter list for all
interfaces is not set
Router
ID 1.1.1.1
Number of areas in this router is 1. 1 normal
0 stub 0 nssa
Maximum path: 4
Routing for Networks:
172.16.1.16 0.0.0.15 area 0
192.168.10.0 0.0.0.3 area 0
192.168.10.4 0.0.0.3 area 0
Routing Information Sources:
Gateway Distance Last Update
192.168.10.6 110 00:11:46
192.168.10.2 110 00:11:46
Distance: (default is 110)
Router1#show ip ospf
Routing Process "ospf 1" with ID
1.1.1.1
Supports only single TOS(TOS0) routes
Supports opaque LSA
SPF schedule delay 5 secs, Hold time between
two SPFs 10 secs
Minimum LSA interval 5 secs. Minimum LSA
arrival 1 secs
Number of external LSA 1. Checksum Sum
0x00fecf
Number of opaque AS LSA 0. Checksum Sum
0x000000
Number of DCbitless external and opaque AS LSA
0
Number of DoNotAge external and opaque AS LSA
0
Number of areas in this router is 1. 1 normal
0 stub 0 nssa
External flood list length 0
Area BACKBONE(0)
Number of interfaces in this area is 3
Area has no authentication
SPF algorithm executed 3 times
Area ranges are
Flood list length 0
Router1#show ip ospf interface
FastEthernet0/0
is up, line protocol is up
Internet address is 172.16.1.17/28, Area 0
Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 1.1.1.1, Interface
address 172.16.1.17
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit
5
Hello due in 00:00:00
Index 1/1, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0
msec
Neighbor Count is 0, Adjacent neighbor count
is 0
Suppress hello for 0 neighbor(s)
Serial0/0/1 is up, line protocol is up
Internet address is 192.168.10.5/30, Area 0
Process
ID 1, Router ID 1.1.1.1, Network Type POINT-TO-POINT, Cost: 64
Transmit Delay is 1 sec, State
POINT-TO-POINT,
Timer intervals configured, Hello 10, Dead
40, Wait 40, Retransmit 5
Hello due in 00:00:00
Index 2/2, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0
msec
Neighbor Count is 1 , Adjacent neighbor count
is 1
Adjacent with neighbor 192.168.10.6
Suppress hello for 0 neighbor(s)
Serial0/0/0 is up, line protocol is up
Internet address is 192.168.10.1/30, Area 0
Process ID 1, Router ID 1.1.1.1, Network Type
POINT-TO-POINT, Cost: 64
Transmit Delay is 1 sec, State
POINT-TO-POINT,
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit
5
Hello due in 00:00:01
Index 3/3, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0
msec
Neighbor Count is 1 , Adjacent neighbor count
is 1
Adjacent with neighbor 192.168.10.2
Suppress hello for 0 neighbor(s)
Công việc 4
: Thực
hiện các lệnh show kiểm tra hoạt động của OSPF
Router1#show ip ospf neighbor
Neighbor
ID Pri State Dead Time Address Interface
3.3.3.3 1
FULL/- 00:00:39 192.168.10.6 Serial0/0/1
2.2.2.2 1
FULL/- 00:00:39 192.168.10.2 Serial0/0/0
Lưu ý : trong kết quả ở trên
Neighbor ID : router-id của các láng giềng.
Pri : Priority=1 (mặc định)
State : trạng thái kết nối FULL.
Dead Time : 40 giây.
Address : địa chỉ IP của nexthop (IP của láng giềng).
Interface : Interface của router
mình nối với láng giềng.
Router1#show ip route
Codes:
C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA
- OSPF inter area
N1
- OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF
external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 -
IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user
static route, o - ODR
P - periodic downloaded static route
Gateway
of last resort is 0.0.0.0 to network 0.0.0.0
1.0.0.0/32 is subnetted, 2 subnets
C 1.0.0.1 is directly connected, Loopback1
C 1.1.1.1 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
O
10.10.10.0 [110/65] via 192.168.10.2, 00:53:29, Serial0/0/0
172.16.0.0/16 is variably
subnetted, 2 subnets, 2 masks
C 172.16.1.16/28 is directly connected,
FastEthernet0/0
O
172.16.1.32/29 [110/65] via 192.168.10.6, 00:00:10, Serial0/0/1
192.168.10.0/30 is subnetted, 3 subnets
C 192.168.10.0 is directly connected,
Serial0/0/0
C 192.168.10.4 is directly connected,
Serial0/0/1
O
192.168.10.8 [110/128] via 192.168.10.2, 00:01:01, Serial0/0/0
[110/128] via 192.168.10.6, 00:00:10, Serial0/0/1
Lưu ý : Trong bảng routing trên ta thấy để đi đến
mạng 192.168.10.8 ta có 2 đường đi với cost bằng nhau và bằng 128
Công việc 5
: Cấu
hình COST trong ospf
ð Để hiển thị Cost ta có thể dùng một trong các lệnh ở
bên trên là :
#show ip ospf interface
#show ip route
#show ip route ospf
Router1#show ip ospf interface
Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
………
Serial0/0/1 is up, line protocol is up
Internet address is 192.168.10.5/30, Area 0
Process
ID 1, Router ID 1.1.1.1, Network Type POINT-TO-POINT, Cost: 64
Router1#show ip route
O 10.10.10.0 [110/65] via 192.168.10.2, 00:53:29,
Serial0/0/0
….
O 172.16.1.32/29 [110/65] via 192.168.10.6, 00:00:10,
Serial0/0/1
….
O 192.168.10.8 [110/128] via 192.168.10.2, 00:01:01,
Serial0/0/0
[110/128] via 192.168.10.6, 00:00:10, Serial0/0/1
Router1#show ip route ospf
10.0.0.0/24 is subnetted, 1 subnets
O 10.10.10.0/24 [110/65] via 192.168.10.2, 01:06:56,
Serial0/0/0
172.16.0.0/16 is variably subnetted, 2
subnets, 2 masks
O 172.16.1.32/29 [110/65] via 192.168.10.6, 00:13:38,
Serial0/0/1
192.168.10.0/30 is subnetted, 3 subnets
O 192.168.10.8/30 [110/128] via 192.168.10.2, 00:14:29, Serial0/0/0
[110/128]
via 192.168.10.6, 00:13:38,
Serial0/0/1
Để thay đổi cost ta có thể thực hiện 1
trong 2 cách sau
Cách 1 Thay
đổi bandwidth (băng thông)
ð Sử dụng lệnh show
interfaces serial [số thứ tự cổng] để xem băng thông
Router1#show interfaces serial 0/0/0
Serial0/0/0
is up, line protocol is up (connected)
Hardware is HD64570
Internet address is 192.168.10.1/30
MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, rely 255/255, load 1/255
Encapsulation HDLC, loopback not set,
keepalive set (10 sec)
Last input never, output never, output hang
never
Last clearing of "show interface"
counters never
Input queue: 0/75/0 (size/max/drops); Total
output drops: 0
Queueing strategy: weighted fair
Output queue: 0/1000/64/0 (size/max
total/threshold/drops)
Conversations 0/0/256 (active/max active/max total)
Reserved Conversations 0/0 (allocated/max
allocated)
5 minute input rate 64 bits/sec, 0
packets/sec
5 minute output rate 64 bits/sec, 0
packets/sec
DCD=up
DSR=up DTR=up RTS=up
CTS=up
Lưu ý : Trên các cổng
serial bandwidth mặc định là 1544 kb/s
ð Sử dụng lệnh bandwidth trong mode interface để thay đổi
bandwidth
Router1(config)#interface s0/0/0
Router1(config-if)#bandwidth 64
- Sau
khi thực hiện lệnh trên cost của đường serial bây giờ là 108/64000(b/s)=1562
-
Dùng lệnh show ip ospf interface để
xem lại giá trị cost
Cách 2 Sử dụng lệnh ip ospf cost trong mode interface để cấu hình cost trên router
Ta
cấu hình thay đổi cost cho router 3
Router3(config)#interface s0/1/0
Router3(config-if)#ip ospf cost 1562
Lưu ý :
Sau
khi thay đổi cost ta thấy để đi đến mạng 192.168.10.8 từ router1 ta có 2 đường
đi với cost khác nhau và như vậy chỉ có đường với giá trị cost thấp mới được đưa
vào bảng định tuyến. (dùng lệnh show ip
route để kiểm tra lại)
Công việc 6 Cấu
hình thay đổi thời gian Hello-interval và Dead-interval
Lưu ý : Hello timer
và Dead timer phải giống nhau trên 2 đầu của 2 router thì quan hệ láng giềng mới
được thiết lập cho 2 router này.
-
Ta muốn thay đổi hello=5 giây, dead=20 giây thì thực hiện như sau :
Router1(config)#interface s0/0/1
Router1(config-if)#ip ospf
hello-interval 5
Router1(config-if)#ip ospf dead-interval
20
-
Ta phải thực hiện lệnh trên ở cả 2 router nối với nhau thì mới có thể thiết lập
quan hệ láng giềng.
-
Dùng lệnh show ip ospf interface serial
0/0/1 để xem giá trị hello và dead.
| ||||