본문 바로가기

Ryu's Tech

LAB 4 - OSPF [ Single-area ]



■ Introduce OSPF [ Open Shortest Path First ]

 

  • A link-state routing protocol
    • Use the Dijkstra Algorithm
      • router receives link-state advertisements
      • Dijkstra 알고리즘은 영역안에서 목적지까지 가기 위한 짧은 경로를 선택할때 쓰인다.
    • 큰 네트워크를 areas로 나눈다.
      • Backbone are (Area 0)
      • multi-area 토폴로드에서 모든 area는 백본 area와 연결된다.
      • 큰 네트워크에서 LSAs(Link-state Advertisements) 를 지역으로만 날리므로 트래픽을 감소시킨다.
    • Metric -> cost
      • A function of bandwidth
      • cost = 100,000,000 / bandwidth (in kbps)

 



■ Describe Designated Router (DR)



  • Router on multi-access network only form adjacencies with DR
    • DR elected by router priority, with larger numbers being more preferable 
    • With equal router priorities, DR elected by highest router ID
      • Router ID determined by loopback interface
      • Router ID determined by highest IP address, if no loopback configured



■ Enumerate OSPF network types


OSPF Network Type Characteristics
  Default OSPF network type on LAN interface
Broadcast 이웃이 자동으로 발견된다.
  모든 라우터는 같은 subnet에 있다.
  DR(Desgnated Router)이 존재한다.
  Default on F/R serial interfaces
Nonbroadcast 이웃이 정적으로 설정된다.
  모든 라우터는 같은 subnet에 있다.
  Has a DR
  Default on non-F/R serial interfaces
Point-to-Point Routers at each end of a link form adjacencies
  각각 p2p링크는 분리된 subnet에 있다.
  Does not have a DR
  어느 인터페이스나 설정이 가능하다.
Point-to-Multipoint 이웃은 자동으로 결정된다.
  모든 라우터는 같은 subnet에 있다.
  Does not have a DR







■ Show the syntax for OSPF configuration

 
Command 설명
Router(config)# router ospf process-id OSPF 시작
Router(config-router)# network network [wildcard-mask] area number 네트워크 주소가 어느 ospf area에 참여할지 설정
Router(config-if)# ip ospf priority 0 라우터 인터페이스가 DR에 참여하는 것을 방지




■ Configure OSPF



###R2
R2(config)#router ospf 1
R2(config-router)#network 10.1.2.0 0.0.0.255 area 0
R2(config-router)#network 192.168.1.0 255.255.255.252 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0
R2(config-router)#

위에서 보면 원래는 wildcard-mask를 써야 하지만 192.168.1.0 네트워크는 일부러 그냥 mask를 사용했습니다.
한번 확인해 볼까요?

!
router ospf 1
 log-adjacency-changes
 network 10.1.2.0 0.0.0.255 area 0
 network 192.168.1.0 0.0.0.3 area 0
 network 2.2.2.2 0.0.0.0 area 0
!

네 보시는대로 OSPF는 이를 자동으로 잡아 줍니다.
괜찮은 기능이죠.


###R1
R1(config)#router ospf 1
R1(config-router)#network 0.0.0.0 255.255.255.255 area 0
R1(config-router)#

0.0.0.0의 의미는.. 현재 연결된 모든 인터페이스를 area 0 으로 설정할 것이기 때문에
그냥 모든 네트워크를 area0 에 포함시킨다라는 의미로 생각하시면 됩니다.
일종의 shortcut이죠


###BB1
BB1(config)#router ospf 1
BB1(config-router)#network 0.0.0.0 255.255.255.255 area 0
BB1(config-router)#


##BB2
BB2(config)#router ospf 1
BB2(config-router)#network 0.0.0.0 255.255.255.255 area 0
BB2(config-router)#


자 이제 설정이 끝났으니 한번 확인해 보도록 하겠습니다.
구성하고, ping만 때려도 확인이 가능하겠지만...
라우팅 테이블을 확인할 수 있는 것이 더 중요하다고 생각합니다.


###R1

R1#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:34    192.168.1.2     FastEthernet0/0
3.3.3.3           0   FULL/  -        00:00:38    172.16.1.2      Serial0/0.1
4.4.4.4           0   FULL/  -        00:00:39    172.16.2.2      Serial0/0.2
R1#

State를 한번 보시길 바랍니다.
2.2.2.2 는 DR로 되어 있습니다. 앞에서 보셨듯이 Loopback IP가 높은 라우터가 DR로 선출되는데요.
그럼 왜 4.4.4.4 가 DR이 아닐까요?


R1#show ip ospf interface fa0/0
FastEthernet0/0 is up, line protocol is up
  Internet address is 192.168.1.1/30, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State BDR, Priority 1
  Designated Router (ID) 2.2.2.2, Interface address 192.168.1.2
  Backup Designated Router (ID) 1.1.1.1, Interface address 192.168.1.1
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:05
  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 2.2.2.2  (Designated Router)
  Suppress hello for 0 neighbor(s)
R1#

BMA이군요..

그렇담 Serial 인터페이스는...

R1#sh ip ospf interface serial 0/0.1
Serial0/0.1 is up, line protocol is up
  Internet address is 172.16.1.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, Priority 0
  No designated router on this network
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:05
  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 3.3.3.3
  Suppress hello for 0 neighbor(s)
R1#


R1#sh ip ospf interface serial 0/0.2
Serial0/0.2 is up, line protocol is up
  Internet address is 172.16.2.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, Priority 0
  No designated router on this network
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:08
  Index 4/4, 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 4.4.4.4
  Suppress hello for 0 neighbor(s)
R1#

Point-to-point 네트워크이네요.
앞에서 설명드렸듯이 Point-to-point 네트워크에서는 DR을 가지지 않습니다.
그래서 3.3.3.3 과 4.4.4.4가 DR이 될 수 없는 이유입니다.


마지막으로 라우팅 테이블을 확인해 보도록 하겠습니다.
R1#sh ip route

     1.0.0.0/32 is subnetted, 1 subnets

C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 192.168.1.2, 00:09:19, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
O       3.3.3.3 [110/65] via 172.16.1.2, 00:06:15, Serial0/0.1
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 172.16.2.2, 00:05:10, Serial0/0.2
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O       10.1.1.0/30 [110/128] via 172.16.1.2, 00:06:15, Serial0/0.1
                    [110/128] via 172.16.2.2, 00:05:10, Serial0/0.2
O       10.1.2.0/24 [110/2] via 192.168.1.2, 00:09:19, FastEthernet0/0
     172.16.0.0/30 is subnetted, 2 subnets
C       172.16.1.0 is directly connected, Serial0/0.1
C       172.16.2.0 is directly connected, Serial0/0.2
     192.168.1.0/30 is subnetted, 1 subnets
C       192.168.1.0 is directly connected, FastEthernet0/0
R1#

10.0.0.0/8 네트워크에 관한 부분을 보겠습니다.
RIP나 EIGRP에서는 default 설정을 했을때는 summary 때문에 제대로 잡히지 않았으나
OSPF는 알아서 제대로 잡아주는 것을 볼 수 있습니다.


■ Manipulate the IP OSPF priority for an interface

자 그럼 앞에서 계획했던대로 R1을 DR로 선출해보도록 하겠습니다.



###R2

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int fa0/0
R2(config-if)#ip ospf priority 0
R2(config-if)#shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to administratively down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to down
00:17:05: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from FULL to Down: Interface down or detached
R2(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#

앞에서 배운 명령 ip ospf priority 0 을 이용해서 설정을 하고
인터페이스를 shutdown과 no shutdown을 사용해서 인터페이스를 disable 후 enable 시킵니다.
그러면 neighbors가 다시 맺어지는 것을 볼 수 있습니다.

R2#sh ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/DR         00:00:39    192.168.1.1     FastEthernet0/0
R2#

확인해 보니 이제 1.1.1.1이 DR로 선출 되었군요.


R2#sh ip ospf inter fa0/0
FastEthernet0/0 is up, line protocol is up
  Internet address is 192.168.1.2/30, Area 0
  Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DROTHER, Priority 0
  Designated Router (ID) 1.1.1.1, Interface address 192.168.1.1
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:03
  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 1.1.1.1  (Designated Router)
  Suppress hello for 0 neighbor(s)
R2#

마지막으로 R1으로 가보겠습니다.

R1#sh ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           0   FULL/DROTHER    00:00:35    192.168.1.2     FastEthernet0/0
3.3.3.3           0   FULL/  -        00:00:33    172.16.1.2      Serial0/0.1
4.4.4.4           0   FULL/  -        00:00:34    172.16.2.2      Serial0/0.2
R1#

이제 2.2.2.2가 DR OTHER 로 state가 바뀐것을 확인해 볼 수 있네요.


■ Verify OSPF operation
마지막으로 확인

R1#ping 1.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/12/15 ms

R1#ping 2.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 31/31/32 ms

R1#ping 3.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 48/60/63 ms

R1#ping 4.4.4.4

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 47/59/63 ms

R1#