Lab 2.1 Cấu hình Cost và Priority trong OSPF

root

Leader IT/Architect
Dec 31, 2012
1,153
72
48
I. Yêu cầu

- Mô hình


- Yêu cầu:
  • Cấu hình IP theo sơ đồ
  • cấu hình định tuyến OSPF trên các Router và cấu hình cho phép các interface Loopback được tham gia định tuyến OSPF
  • Kiểm tra lại các cấu hình bằng lệnh Show
  • Cấu hình chỉnh sửa COST
  • Hiệu chỉnh Priority để: R1 làm DR, R2 làm BDR và R3 làm DROTHER
II. Triển khai
1. Cấu hình IP cho các Router
- Thực hiện cấu hình IP như hình vẽ

//Router 1
R1(config)#interface loopback 1
R1(config-if)#description Engineering Department
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#int f0/0
R1(config-if)#ip add 10.1.200.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int s1/0
R1(config-if)#ip add 10.1.100.1 255.255.255.0
R1(config-if)#no shut

//Router 2
R2(config-if)#interface loopback 2
R2(config-if)#description Marketing Department
R2(config-if)#ip add 10.1.2.1 255.255.255.0
R2(config-if)#int f0/0
R2(config-if)#ip add 10.1.200.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int s1/0
R2(config-if)#ip add 10.1.100.2 255.255.255.0
R2(config-if)#no shut

//Router 3
R3(config-if)#interface loopback 3
R3(config-if)#description Accounting Department
R3(config-if)#ip add 10.1.3.1 255.255.255.0
R3(config-if)#int f0/0
R3(config-if)#ip add 10.1.200.3 255.255.255.0
R3(config-if)#no shut

- Cấu hình định tuyến OSPF trên các Router
//Router 1
R1(config)#router ospf 1
R1(config-router)#network 10.1.100.0 0.0.0.255 area 0
R1(config-router)#network 10.1.200.0 0.0.0.255 area 0

//Router 2
R2(config)#router ospf 1
R2(config-router)#network 10.1.100.0 0.0.0.255 area 0
R2(config-router)#network 10.1.200.0 0.0.0.255 area 0

//Router 3
R3(config)#router ospf 1
R3(config-router)#network 10.1.200.0 0.0.0.255 area 0

- Sau khi cấu hình định tuyến xong các bạn sẽ thấy các thông báo Neighbor trong OSPF

Code:
R1(config-router)#
*Mar  1 00:11:08.175: %OSPF-5-ADJCHG: Process 1, Nbr 10.1.2.1 on Serial1/0 from LOADING to FULL, Loading Done
R1(config-router)#
*Mar  1 00:11:17.287: %OSPF-5-ADJCHG: Process 1, Nbr 10.1.2.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
R1(config-router)#
*Mar  1 00:11:27.287: %OSPF-5-ADJCHG: Process 1, Nbr 10.1.3.1 on FastEthernet0/0 from LOADING to FULL, Loading Done

2. Kiểm tra với các lệnh SHOW

- Thứ kiểm tra định tuyến trên Router 1 ta thấy
  • Router-ID của R1 là: 10.1.1.1
  • R1 đã thực hiện định tuyến OSPF với các mạng 10.1.100.0/24 và 10.1.200.0/24
Code:
R1#[COLOR=#ff0000][B]sh ip protocols[/B][/COLOR]
[COLOR=#ff0000]Routing Protocol is "ospf 1"[/COLOR]
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
[COLOR=#ff0000]  Router ID 10.1.1.1[/COLOR]
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:
[COLOR=#ff0000]    10.1.100.0 0.0.0.255 area 0[/COLOR]
[COLOR=#ff0000]    10.1.200.0 0.0.0.255 area 0[/COLOR]
 Reference bandwidth unit is 100 mbps
  Routing Information Sources:
    Gateway         Distance      Last Update
  Distance: (default is 110)
- Lệnh "show ip ospf" cho các bạn biết thêm được nhiều các thông số khác
  • Process-ID = 1
  • Router-ID = 10.1.1.1
Code:
R1#[COLOR=#ff0000][B]sh ip ospf[/B][/COLOR]
[COLOR=#ff0000] Routing Process "ospf 1" with ID 10.1.1.1[/COLOR]
 Start time: 00:09:34.632, Time elapsed: 00:15:57.400
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 Supports Link-local Signaling (LLS)
 Supports area transit capability
 Router is not originating router-LSAs with maximum metric
 Initial SPF schedule delay 5000 msecs
 Minimum hold time between two consecutive SPFs 10000 msecs
 Maximum wait time between two consecutive SPFs 10000 msecs
 Incremental-SPF disabled
 Minimum LSA interval 5 secs
 Minimum LSA arrival 1000 msecs
 LSA group pacing timer 240 secs
 Interface flood pacing timer 33 msecs
 Retransmission pacing timer 66 msecs
 Number of external LSA 0. Checksum Sum 0x000000
 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
 Number of areas transit capable is 0
 External flood list length 0
 IETF NSF helper support enabled
 Cisco NSF helper support enabled
    Area BACKBONE(0)
        Number of interfaces in this area is 2
        Area has no authentication
        SPF algorithm last executed 00:14:00.696 ago
        SPF algorithm executed 5 times
        Area ranges are
        Number of LSA 4. Checksum Sum 0x02F53D
        Number of opaque link LSA 0. Checksum Sum 0x000000
        Number of DCbitless LSA 0
        Number of indication LSA 0
        Number of DoNotAge LSA 0
        Flood list length 0
- Lệnh "show ip ospf neighbor" cho ta biết các Neighbor của Router R1. Như dưới đây ta có thể thấy R1 có 3 Neighbor trao đổi thông tin định tuyến với nó qua các interface F0/0 và S1/0
- Riêng Neighbor 10.1.2.1 được học 2 lần
  • 1 lần qua interface f0/0
  • 1 lần qua interface s1/0
- Vì trên môi trường Multiaccess phải bầu chọn Router làm DR(Designated Router) và BDR (Backup DR) dự phòng chi DR.
- Theo bảng Neighbor interface f0/0 của R1 ta thấy
  • R1 đang trao đổi thông tin với 1 Router có chức năng DR
  • R1 cũng đang trao đổi thông tin với 1 Router DROTHER
=> vầy là R1 đang làm chức năng của 1 DR Router

Code:
R1#[COLOR=#ff0000][B]sh ip ospf neighbor[/B][/COLOR]


Neighbor ID     Pri   State           Dead Time   Address         Interface
10.1.2.1          1   FULL/[COLOR=#ff0000]BDR[/COLOR]        00:00:38    10.1.200.2      FastEthernet0/0
10.1.3.1          1   FULL/[COLOR=#ff0000]DROTHER[/COLOR]    00:00:34    10.1.200.3      FastEthernet0/0
10.1.2.1          0   FULL/  -        00:00:32    10.1.100.2      Serial1/0
- Lệnh "show ip ospf interface" Lệnh này cho chúng ta biết
  • Các interface tham gia vào định tuyến OSPF
  • Các thông số của Interface tham gia đinh tuyến như: Network type, helo-timer, dead-timer...
Code:
R1#[COLOR=#ff0000][B]sh ip ospf interface[/B][/COLOR]
FastEthernet0/0 is up, line protocol is up
  Internet Address 10.1.200.1/24, Area 0
  Process ID 1, Router ID 10.1.1.1,[COLOR=#ff0000] Network Type BROADCAST[/COLOR], Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 10.1.1.1, Interface address 10.1.200.1
  Backup Designated router (ID) 10.1.2.1, Interface address 10.1.200.2
  Timer intervals configured, [COLOR=#ff0000]Hello 10, Dead 40, Wait 40, Retransmit 5[/COLOR]
    oob-resync timeout 40
    Hello due in 00:00:00
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  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 2, Adjacent neighbor count is 2
    Adjacent with neighbor 10.1.2.1  (Backup Designated Router)
    Adjacent with neighbor 10.1.3.1
  Suppress hello for 0 neighbor(s)
Serial1/0 is up, line protocol is up
  Internet Address 10.1.100.1/24, Area 0
  Process ID 1, Router ID 10.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
    oob-resync timeout 40
    Hello due in 00:00:03
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  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 1, Adjacent neighbor count is 1
    Adjacent with neighbor 10.1.2.1
  Suppress hello for 0 neighbor(s)
- Lệnh "show ip ospf database" để hiện thị bảng cơ sở dữ liệu trạng thái đường liên kết trên Router (LSDB - Link state Database)

Code:
R1#[COLOR=#ff0000][B]sh ip ospf database[/B][/COLOR]


            OSPF Router with ID (10.1.1.1) (Process ID 1)


                Router Link States (Area 0)


Link ID         ADV Router      Age         Seq#       Checksum Link count
10.1.1.1        10.1.1.1        1765        0x80000004 0x00B81E 3
10.1.2.1        10.1.2.1        1766        0x80000002 0x00BD18 3
10.1.3.1        10.1.3.1        1751        0x80000002 0x0093CB 1


                Net Link States (Area 0)


Link ID         ADV Router      Age         Seq#       Checksum
10.1.200.1      10.1.1.1        1755        0x80000002 0x00EC3C

3. Cho phép interface loopback tham gia OSPF
- cấu hình Router để interface loopback được tham gia vào định tuyến OSPF

//Router 1
R1(config)#router ospf 1
R1(config-router)#network 10.1.1.0 0.0.0.255 area 0

//Router 2
R2(config)#router ospf 1
R2(config-router)#network 10.1.2.0 0.0.0.255 area 0

//Router 3
R3(config)#router ospf 1
R3(config-router)#network 10.1.3.0 0.0.0.255 area 0

- Kiểm tra lại bảng định tuyến sau khi config

Code:
R1#sh ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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 not set


     10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
[COLOR=#ff0000]O       10.1.2.1/32 [110/11] via 10.1.200.2, 00:01:17, FastEthernet0/0[/COLOR]
[COLOR=#ff0000]O       10.1.3.1/32 [110/11] via 10.1.200.3, 00:00:51, FastEthernet0/0[/COLOR]
C       10.1.1.0/24 is directly connected, Loopback1
C       10.1.100.0/24 is directly connected, Serial1/0
C       10.1.200.0/24 is directly connected, FastEthernet0/0

- Chúng ta để ý nhé. Subnet trang các Loopback lúc nào cũng được OSPF quảng bá đi với Prefix-length là /32.
- Để thay đổi điều này, các bạn vào Loopback và lệnh sau

//Router 1
R1(config)#interface loopback 1
R1(config-if)#ip ospf network point-to-point

//Router 2
R2(config)#interface loopback 2
R2(config-if)#ip ospf network point-to-point

//Router 3
R3(config)#interface loopback 3
R3(config-if)#ip ospf network point-to-point


- Kiểm tra lại bảng định tuyến

Code:
R1#sh ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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 not set


     10.0.0.0/24 is subnetted, 5 subnets
[COLOR=#ff0000]O       10.1.3.0 [110/11] via 10.1.200.3, 00:01:09, FastEthernet0/0[/COLOR]
[COLOR=#ff0000]O       10.1.2.0 [110/11] via 10.1.200.2, 00:01:52, FastEthernet0/0[/COLOR]
C       10.1.1.0 is directly connected, Loopback1
C       10.1.100.0 is directly connected, Serial1/0
C       10.1.200.0 is directly connected, FastEthernet0/0
 
4. Hiệu chính COST trong OSPF

- Một vài giá trị COST trên các interface

Serial Link56 Kbps1785
Serial Link64 Kbps1562
T11.544 Mbps64
E12048 Mbps48
Token Ring4 Mbps25
Ethernet10
Token Ring16 Mbps6
FDDI1
X255208
Asynchronous10.000
ATM1


- Để hiệu chỉnh COST trong OSPF các bạn vào interface và điều chỉnh COST như sau

R1(config)#interface f0/0
R1(config-if)#ip ospf cost 50

- Kiểm tra lại kết quả

Code:
R1#sh ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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 not set


     10.0.0.0/24 is subnetted, 5 subnets
[COLOR=#ff0000]O       10.1.3.0 [110/51][/COLOR] via 10.1.200.3, 00:04:16, FastEthernet0/0
[COLOR=#ff0000]O       10.1.2.0 [110/51] [/COLOR]via 10.1.200.2, 00:04:16, FastEthernet0/0
C       10.1.1.0 is directly connected, Loopback1
C       10.1.100.0 is directly connected, Serial1/0
C       10.1.200.0 is directly connected, FastEthernet0/0

5. Chỉnh Interface Priority
- Các thông số trong bầu chọn DR và BDR gồm:
- Priority

  • Giá trị Priority cao nhất sẽ làm DR
  • Cao thứ 2 làm BDR
  • còn lại sẽ làm DROTHER
- Router ID: Nếu các Priority bằng nhau hết thì tới Router ID
  • Router ID cao nhất làm DR
- Chúng ta sẽ hiệu chỉnh Priority để
  • R1 làm DR
  • R2 làm BDR
  • R3 làm DROTHER
//Router 1
R1(config)#interface f0/0
R1(config-if)#ip ospf priority 10

//Router 2
R2(config)#interface f0/0
R2(config-if)#ip ospf priority 5

- Để việc thay đổi priority áp phê bạn cần thêm câu lệnh sau

R1#clear ip ospf process

- Kiểm tra lại ta thấy
  • R1 đã làm DR
  • R2 làm BDR
  • R3 làm DROTHER
Code:
R1#sh ip ospf neighbor


Neighbor ID     Pri   State           Dead Time   Address         Interface
10.1.2.1          5   FULL/[COLOR=#ff0000]BDR        [/COLOR]00:00:31    10.1.200.2      FastEthernet0/0
10.1.3.1          1   FULL/[COLOR=#ff0000]DROTHER    [/COLOR]00:00:31    10.1.200.3      FastEthernet0/0
10.1.2.1          0   FULL/  -        00:00:32    10.1.100.2      Serial1/0
- chi tiết hơn

Code:
R1#[B]sh ip ospf neighbor detail[/B]
 Neighbor 10.1.2.1, interface address 10.1.200.2
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 5, State is FULL, 12 state changes
[COLOR=#ff0000]    DR is 10.1.200.1 BDR is 10.1.200.2[/COLOR]
    Options is 0x52
    LLS Options is 0x1 (LR)
    Dead timer due in 00:00:33
    Neighbor is up for 00:00:52
    Index 3/3, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 0
    Last retransmission scan time is 0 msec, maximum is 0 msec
 Neighbor 10.1.3.1, interface address 10.1.200.3
    In the area 0 via interface FastEthernet0/0
    Neighbor priority is 1, State is FULL, 6 state changes
    DR is 10.1.200.1 BDR is 10.1.200.2
    Options is 0x52
    LLS Options is 0x1 (LR)
    Dead timer due in 00:00:33
    Neighbor is up for 00:23:01
    Index 2/2, retransmission queue length 0, number of retransmission 0
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 0, maximum is 0
    Last retransmission scan time is 0 msec, maximum is 0 msec
 Neighbor 10.1.2.1, interface address 10.1.100.2
    In the area 0 via interface Serial1/0
    Neighbor priority is 0, State is FULL, 12 state changes
    DR is 0.0.0.0 BDR is 0.0.0.0
    Options is 0x52
    LLS Options is 0x1 (LR)
    Dead timer due in 00:00:39
    Neighbor is up for 00:00:57
    Index 1/1, retransmission queue length 0, number of retransmission 2
    First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
    Last retransmission scan length is 2, maximum is 2
    Last retransmission scan time is 0 msec, maximum is 0 msec
 

About us

  • Securityzone.vn là một trang web chuyên về an ninh mạng và công nghệ thông tin. Trang web này cung cấp các bài viết, tin tức, video, diễn đàn và các dịch vụ liên quan đến lĩnh vực này. Securityzone.vn là một trong những cộng đồng IT lớn và uy tín tại Việt Nam, thu hút nhiều người quan tâm và tham gia. Securityzone.vn cũng là nơi để các chuyên gia, nhà nghiên cứu, sinh viên và người yêu thích an ninh mạng có thể trao đổi, học hỏi và chia sẻ kiến thức, kinh nghiệm và giải pháp về các vấn đề bảo mật trong thời đại số.

Quick Navigation

User Menu