네트워크

CISCO 네트워크 - OSPF

slcry 2022. 12. 5. 11:33

CISCO Router

 

OSPF

 - OSPF(Open Shortest Path First)는 계층화 된 라우팅 프로토콜이다.

 

 - IGP(Internal Gateway Protocol)
   - AS(Autonomous System)내부에 사용
 

 - Area에 의해 효율적인 라우팅 정보 관리가 가능하다.
   - Backbone area(Area0)을 통해 연결된다.
   - Area0에 연결되지 못하면 Virtual link를 통해 연결한다.
   - Area 내에서 LSA를 교환한다.
 

 - Link의 cost를 기반으로 경로를 배정한다.
   - Hop 제한이 없다.
   - Dijkstra의 SPF알고리즘을 바탕으로 경로가 선택된다.
   - link cost = 기준대역폭/실제대역폭

 

 - VLSM을 지원한다.

 

* router rip은 라우터가 자신의 라우터 정보를 무작위로 뿌리는데 hop count가 16을 넘어가면 상관하지 않는것뿐이다. 

 

 

OSPF ‐ area

 - ABR : Area Border Router
 - IR : Internal Router
 - ASBR : Autonomous System Boundary Router                                                                                                                               

 

OSPF ‐ 구조                                                                                                                                                                             

라우터의 구분
 - IR : Area 내부 라우터
 - ABR : Area를 연결하는 라우터
 - ASBR : AS와 연결하는 외부 연결 라우터
 - DR(Designated Router)
   : Link stat 정보를 취합, 관리하는 라우터
   : IR과 DR간에 link stat 정보를 주고 받는다.

 - BDR(Backup DR)

 

OSPF는 neighbor 간에 라우팅 정보를 공유한다.
 - 라우터 간에 이런 adjacency를 위한 조건이 필요하다.
 - 동일 area에 위치한다.
 - 동일한 인증 정보
 - 동일한 Hello interval 및 Dead interval을 가져야한다.
   - 이들 값은 토플로지에 따라 자동으로 결정된다.
   - 10초, 40초 : ppp, ethernet                                                                                                                                                                                                                                                                                                                                                    OSPF의 네이버(Neighbor)와 인접 관계(Adjacency)는 동일한 의미가 아니다.
 - 네이버 라우터 중에 인접관계인 라우터와 LSA를 교환한다.
 - 이를 통해 모든 라우터가 동일한 링크 정보를 유지한다.
 - Adjancency 는 DR(BDR)과 IR간에 이뤄진다.                                  

 

 

OSPF ‐ Neighbor, Adjacency
 - OSPF의 네이버(Neighbor)와 인접 관계(Adjacency)는 동일한 의미가 아니다.
   - 네이버 라우터 중에 인접관계인 라우터와 LSA를 교환한다.
   - 이를 통해 모든 라우터가 동일한 링크 정보를 유지한다.
   - Adjancency 는 DR(BDR)과 IR간에 이뤄진다.

 

OSPF – Point to Point

 - Poing to Point Link : HDLC, PPP등의 Serial Link
 - DB/BDR를 선출하지 않는다.
 - OSPF Hello 및 LSU 패킷은 Multicast 224.0.0.5를 이용한다.
   - Hello Packet : 10s
   - Dead Interval : 40s

 

 

OSPF – Multiaccess Network

 - Ethernet등의 LAN Link
 - DR/BDR을 선출한다.
   - Priority가 기준이 된다.
   - 가장 높은 router id가 DR이 된다.
 - 모든 라우터는 DR/BDR과만 인접관계가 된다.
 - DR과 통신
   - TO DR : 224.0.0.6
   - FROM DR : 224.0.0.5

 

 

OSPF ‐ 패킷
라우팅을 위한 패킷 유형
 - Hello 패킷
   - Neighbor를 맺기 위해 전송하는 정보

 - DBD(Database Description)
   - 저장된 네트워크 정보에 대한 요약 정보
 - LSR(Link State Request)
   - DBD를 받았을 때 가지지 못한 정보를 요청
 - LSU(Link State Update)
  - LSR에 대한 응답
 - 네트워크에 대한 자세한 링크 정보
  - LSAck(Link State Ack)

 

 

OSPF ‐ 패킷
 OSPF LSA 송수신
• LSA는 라우터가 가진 네트워크 링크 정보를 분할한 패킷
• Neighbor 간에 네트워크 정보는 공유된다.
• 동기화가 마무리 되면 변경된 정보만 전달된다.
• 30분마다 정보를 확인한다.
• Area 내에 라우터 간에 링크 정보는 LSA(Link State
Advertisement)로 전달한다.

 

OSPF 설정
1. OSPF 라우팅 프로세스 활성화
2. Router ID
 - Router ID는 OSPF를 사용하는 Router를 식별하기 위한 식별정보다.
   - Router는 Router ID로 식별된다.
 - 인터페이스 IP중 가장 높은 IP가 ID로 사용된다.
 - Router ID가 인터페이스의 상태에 따라 달라지는 것을 방지한다.
   ‐ router‐id 명령으로 id를 지정한다.
   ‐ local loopback 인터페이스에 IP를 할당한다.
 - 반드시 필요한 과정은 아니다.
3. 각 인터페이스의 네트워크 등록
4. OSPF 작동 확인

 

OSPF 설정 ‐ Serial

OSPF 설정 ‐ OSPF 프로세스 활성화
OSPF 프로세스 활성화
 - 프로세스 ID에 대한 제약은 거의 없다.
 - 관리자의 정책에 따라 결정한다.
 - 명령

router ospf [process‐id]
ex) router ospf 1

R1(config)# router ospf 1
R1(config‐router)#
R2(config)# router ospf 1
R2(config‐router)#
R3(config)# router ospf 1
R3(config‐router)#

 

 

OSPF 설정 ‐ Router ID 설정

Router ID 설정
R1(config)# router ospf 1
R1(config‐router)# router‐id 1.1.1.1
R1(config‐router)#
R2(config)# router ospf 1
R2(config‐router)# router‐id 2.2.2.1
R2(config‐router)#
R3(config)# router ospf 1
R3(config‐router)# router‐id 3.3.3.1
R3(config‐router)#

 

OSPF 설정 ‐ 인터페이스 설정
각 인터페이스를 등록한다.

R1(config)# router ospf 1
R1(config‐router)# router‐id 1.1.1.1
R1(config‐router)# network 1.1.1.1 0.0.0.0 area 0
R1(config‐router)# network 12.1.1.1 0.0.0.0 area 0
R1(config‐router)# network 31.1.1.1 0.0.0.0 area 0

R2(config)# router ospf 1
R2(config‐router)# router‐id 2.2.2.1
R2(config‐router)# network 2.2.2.1 0.0.0.0 area 0
R2(config‐router)# network 23.1.1.2 0.0.0.0 area 0
R2(config‐router)# network 12.1.1.2 0.0.0.0 area 0

R3(config)# router ospf 1
R3(config‐router)# router‐id 3.3.3.1
R3(config‐router)# network 3.3.3.1 0.0.0.0 area 0
R3(config‐router)# network 31.1.1.3 0.0.0.0 area 0
R3(config‐router)# network 23.1.1.3 0.0.0.0 area 0

 

OSPF 설정 ‐ 인터페이스 설정
패시브인터페이스 설정

R1(config)# router ospf 1
R1(config‐router)# passive‐interface g0/0
R1# show run
......
router ospf 1
router‐id 1.1.1.1
log‐adjacency‐changes
passive‐interface GigabitEthernet0/0
network 1.1.1.1 0.0.0.0 area 0
network 12.1.1.1 0.0.0.0 area 0
network 31.1.1.1 0.0.0.0 area 0......

 

OSPF 설정 ‐ 동작 확인

R1# show ip route ospf
2.0.0.0/24 is subnetted, 1 subnets
O       2.2.2.0 [110/65] via 12.1.1.2, 00:06:52, Serial0/0/0
3.0.0.0/24 is subnetted, 1 subnets
O       3.3.3.0 [110/65] via 31.1.1.3, 00:05:28, Serial0/0/1
23.0.0.0/24 is subnetted, 1 subnets
O       23.1.1.0 [110/128] via 12.1.1.2, 00:05:28, Serial0/0/0
[110/128] via 31.1.1.3, 00:05:28, Serial0/0/1

 - OSPF로 교환된 라우팅 정보만을 확인한다.
 - O는 OSPF 정보를 의미한다.
 - cost

OSPF 설정 ‐ 동작 확인

R1# show ip ospf int s0/0/0
Serial0/0/0 is up, line protocol is up
Internet address is 12.1.1.1/24, 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:05
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 2.2.2.1
Suppress hello for 0 neighbor(s)

 

OSPF가 작동하고 있는 interface의 정보 확인
 - Router ID
 - Area ID
 - ……

 

OSPF 설정 ‐ 동작 확인

R1# show ip ospf neighbor
Neighbor ID     Pri State           Dead Time   Address         Interface
3.3.3.1           0   FULL/  ‐ 00:00:31    192.168.31.3    Serial0/0/1
2.2.2.1           0   FULL/  ‐ 00:00:31    192.168.12.2    Serial0/0/0

네이버의 상태 정보 표시
 - Full / ‐
   : 서로가 LSDB를 교환함
 - Full / DR
   : 서로가 LSDB를 교환함, 네이버가 DR
 - Full / BDR
   : 서로가 LSDB를 교환함, 네이버가 BDR
 - Full / DROther
   : 서로가 LSDB를 교환함
 - 2Way / DRother
   : 서로가 LSDB를 교환하지 못하는 단순 네이버 관계

 

OSPF 설정 ‐ extra : default route
OSPF을 이용한 default route 정보 전달
 - 정적 라우팅 환경에서는 라우터에 직접 default route 정보를 설정했으나 

   RIP에서는 default route 정보를 RIP를 통해 전달 가능하다.

 

명령
 - default‐information originate
   : RIP을 통해 default route 정보를 전달한다.

 

Default router 설정
 - default route 설정은 정적 라우팅 설정과 동일하다.
 - 외부 네트워크로 local loopback 인터페이스를 이용한다.
   - loopback 인터페이스를 인터넷(ISP) 연결로 간주한다.

 

OSPF 설정 ‐ extra : default route
loopback 인터페이스를 활성화 한다.

R1(config)# int loopback0
R1(config‐if)#
%LINK‐5‐CHANGED: Interface Loopback0, changed state to up
%LINEPROTO‐5‐UPDOWN: Line protocol on Interface Loopback0, changed state to up
R1(config‐if)# ip add 10.10.10.1 255.255.255.0
R1(config‐if)# do show ip int brief
Interface              IP‐Address      OK? Method Status                Protocol
GigabitEthernet0/0     1.1.1.1         YES NVRAM  up                    up
GigabitEthernet0/1     unassigned      YES NVRAM  administratively down down
Serial0/0/0            12.1.1.1        YES manual up                    up
Serial0/0/1            31.1.1.1        YES manual up                    up
Loopback0              10.10.10.1      YES manual up                    up
Vlan1                  unassigned      YES unset  administratively down down

 - 가상 인터페이스로 no shutdown 명령이 불필요하다.
 - 10.10.10.0/24는 RIP 라우팅에 등록하지 않는다.

 

default route 인터페이스를 지정하고 이를 rip이 광고하도록 설정한다.

R1(config)# ip route 0.0.0.0 0.0.0.0 loopback0
R1(config)# router ospf
R1(config‐router)# default‐information originate
R1# show ip route
......
......
......
L       31.1.1.1/32 is directly connected, Serial0/0/1
S*   0.0.0.0/0 is directly connected, Loopback0

 

R2, R3 에서도 default route 정보가 갱신되었는지 확인한다.

R2# show ip route
......
O*E2 0.0.0.0/0 [110/1] via 12.1.1.1, 00:01:14, Serial0/0/1


R3# show ip route
......
......
O*E2 0.0.0.0/0 [110/1] via 31.1.1.1, 00:02:25, Serial0/0/0

 - PC2,  PC3 에서도 10.10.10.1에 연결되는지 확인한다.

 

 

OSPF 설정 ‐ LAN

R1# show ip route ospf
2.0.0.0/24 is subnetted, 1 subnets
O       2.2.2.0 [110/2] via 5.5.5.2, 00:01:41, GigabitEthernet0/0
3.0.0.0/24 is subnetted, 1 subnets
O       3.3.3.0 [110/2] via 5.5.5.3, 00:01:41, GigabitEthernet0/0
4.0.0.0/24 is subnetted, 1 subnets
O       4.4.4.0 [110/2] via 5.5.5.4, 00:01:41, GigabitEthernet0/0
R1# show ip ospf neighbor
Neighbor ID   Pri State           Dead Time   Address   Interface
4.4.4.1         1   FULL/DR         00:00:31    5.5.5.4   GigabitEthernet0/0
3.3.3.1         1   FULL/BDR        00:00:33    5.5.5.3   GigabitEthernet0/0
2.2.2.2         1   2WAY/DROTHER    00:00:35    5.5.5.2   GigabitEthernet0/0

 

OSPF 설정 – DR, BDR
DR, BDR 선정
① Interface의 priority가 높은 순서로 DR, BDR 선정
② 라우터 ID가 높은 순서로 DR, BDR 선정
③ DR, BDR이 선출되면 새로운 라우터 추가에도 재선정 하지 않음
④ DR, BDR 다운시에 새로 선출

 

DR, BDR 재 선정
 - DR, BDR 다운(DR, BDR 재부팅)
 - clear ip ospf process 명령

 

Interface priority 변경

R1(config)# interface gi0/0
R1(config‐if)# ip ospf priority ##

 - ## : 0~255
   - 0 : DR, BDR에 참여하지 않는다.

 

 

Multi area OSPF

 

Router 설정

R0_1(config)# router ospf 1
R0_1(config‐router)# router‐id 192.168.0.1
R0_1(config‐router)# network 192.168.0.1 0.0.0.0 area 0
R0_1(config‐router)# network 192.168.1.1 0.0.0.0 area 1


R0_2(config)# router ospf 1
R0_2(config‐router)# router‐id 192.168.0.2
R0_2(config‐router)# network 192.168.0.2 0.0.0.0 area 0
R0_2(config‐router)# network 192.168.2.1 0.0.0.0 area 2


R1(config)# router ospf 1
R1(config‐router)# router‐id 192.168.10.1
R1(config‐router)# network 192.168.10.1 0.0.0.0 area 1
R1(config‐router)# network 192.168.1.2 0.0.0.0 area 1


R2(config)# router ospf 1
R2(config‐router)# router‐id 192.168.20.1
R2(config‐router)# network 192.168.20.1 0.0.0.0 area 2
R2(config‐router)# network 192.168.2.2 0.0.0.0 area 2

 

Router 설정_추가

R0_1(config)# router ospf 1
R0_1(config‐router)# router‐id 192.168.0.1
R0_1(config‐router)# network 192.168.0.1 0.0.0.255 area 0
R0_1(config‐router)# network 192.168.1.1 0.0.0.255 area 1


R0_2(config)# router ospf 1
R0_2(config‐router)# router‐id 192.168.0.2
R0_2(config‐router)# network 192.168.0.2 0.0.0.255 area 0
R0_2(config‐router)# network 192.168.2.1 0.0.0.255 area 2


R1(config)# router ospf 1
R1(config‐router)# router‐id 192.168.10.1
R1(config‐router)# network 192.168.10.1 0.0.0.255 area 1
R1(config‐router)# network 192.168.1.2 0.0.0.255 area 1


R2(config)# router ospf 1
R2(config‐router)# router‐id 192.168.20.1
R2(config‐router)# network 192.168.20.1 0.0.0.255 area 2
R2(config‐router)# network 192.168.2.2 0.0.0.255 area 2

 

 

OSPF 설정 확인
OSPF 확인 명령
 - show ip ospf neighbor
   - OSPF 네이버를 확인한다.
 - show ip ospf
   - OSPF 프로세서에 대한 정보를 확인한다.
 - show ip ospf interface
   - OSPF에 참여하는 인터페이스의 자세한 상태정보를 확인한다.
 - show ip ospf database
   - OSPF 링크 상태 데이터베이스를 열람한다.
   - LSA의 요약정보를 보여주지만 실제 링크 상태는 알 수 없다.
 - show ip ospf database [추가]
   - router, network, summary ......