ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [네트워크] 32. 정적 경로 라우팅, 루프백 인터페이스, 디폴트 루트
    네트워크 2024. 1. 14. 19:37

    이 게시물은 <킹 오브 네트워킹 (피터전)>을 공부한 내용을 바탕으로 작성됨.

     


     

    정적 경로 라우팅

     

    바로 앞 게시글에서 배운 '라우팅 프로토콜'에 의해 선택된 경로는 바로 동적 경로(Dynamic route)이다. 이번 게시글에서 배울 정적 경로(Static route)는 라우팅 프로토콜이 아닌, 네트워크 관리자(사람)가 직접 설정한 경로를 의미한다.

     

     

     

     

    정적 경로 라우팅을 실습과 함께 배워보자.

     

    R1(config)#no ip domain-lookup
    R1(config)#enable secret cisco
    R1(config)#line console 0
    R1(config-line)#logg sync
    R1(config-line)#exec-t 0
    R1(config-line)#line vty 0 4
    R1(config-line)#password cisco
    R1(config-line)#exit

     

    R1,2,3 모든 라우터에 위 같은 설정을 적용한다.

     

     

    ① R1
    R1(config)#interface g0/0
    R1(config-if)#ip address 1.1.10.1 255.255.255.0
    R1(config-if)#no shut
    
    R1(config-if)#interface s0/3/0
    R1(config-if)#ip address 1.1.12.1 255.255.255.0
    R1(config-if)#no shut
    
    
    
    ② R2
    R2(config)#interface g0/0
    R2(config-if)#ip address 1.1.20.2 255.255.255.0
    R2(config-if)#no shut
    
    R2(config)#interface s0/3/0
    R2(config-if)#ip address 1.1.12.2 255.255.255.0
    R2(config-if)#no shut
    
    R2(config-if)#interface s0/3/1
    R2(config-if)#ip address 1.1.23.2 255.255.255.0
    R2(config-if)#no shut
    
    
    
    ③ R3
    R3(config)#interface g0/0
    R3(config-if)#ip address 1.1.30.3 255.255.255.0
    R3(config-if)#no shut
    
    R3(config-if)#interface s0/3/1
    R3(config-if)#ip address 1.1.23.3 255.255.255.0
    R3(config-if)#no shut

     

     

    세 라우터의 interface 설정은 위와 같다.

     

     

     

     

    R1#show ip route
    Codes: L - local, 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, 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 not set
    
         1.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
    C       1.1.10.0/24 is directly connected, GigabitEthernet0/0
    L       1.1.10.1/32 is directly connected, GigabitEthernet0/0
    C       1.1.12.0/24 is directly connected, Serial0/3/0
    L       1.1.12.1/32 is directly connected, Serial0/3/0

     

     

    R1에서 라우팅 테이블을 출력해보면 위와 같다. R1의 라우팅 테이블에서 PC1, R2가 확인된다. (사실 PC1, R2는 R1의 interface와 직접 되어있기 때문에 이들은 별 다른 작업 없이도 테이블에 항상 존재한다.)

     

     

     

    R1#ping 1.1.12.2
    
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 1.1.12.2, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 11/21/27 ms
    
    
    
    R1#ping 1.1.20.2
    
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 1.1.20.2, timeout is 2 seconds:
    .....
    Success rate is 0 percent (0/5)

     

     

    R1에서 R2(1.1.12.2)로는 핑이 가능하다. 하지만 PC2(1.1.20.2)로는 핑이 실패했다. R1의 라우팅 테이블에는 R2의 주소는 있지만, 직접 연결되어있지 않은 PC2(1.1.20.2)의 주소는 아직 모른다.

     

     

     

     

    <R1 정적경로 설정하기>
    R1(config)#ip route 1.1.20.0 255.255.255.0 1.1.12.2
    R1(config)#ip route 1.1.30.0 255.255.255.0 1.1.12.2
    R1(config)#ip route 1.1.23.0 255.255.255.0 1.1.12.2

     

     

    정적경로 설정은 위 명령어 형식으로 이루어진다.

     

    ip route <목적지 network 주소> / <목적지 net의 subnet mask> / <목적지 net으로 가기 위한 net hop의 IP 주소>

     

     

    R1에서 목적지 R3을 정적경로를 설정하기 위해서는 R1 ➜ R2 ➜ R3의 경로에 존재하는 모든 네트워크를 정적 경로로 설정해주어야 한다.

     

     

     

    <R2 정적경로 설정>
    R2(config)#ip route 1.1.10.0 255.255.255.0 1.1.12.1
    R2(config)#ip route 1.1.30.0 255.255.255.0 1.1.23.3
    
    <R3 정적경로 설정>
    R3(config)#ip route 1.1.10.0 255.255.255.0 s0/3/1
    R3(config)#ip route 1.1.20.0 255.255.255.0 s0/3/1
    R3(config)#ip route 1.1.12.0 255.255.255.0 s0/3/1

     

     

    R2, R3도 경로를 설정해준다. 이로써 R1, R2, R3은 서로 자신의 주소를 알고있고, 서로에게 도달하기 위해 어느 방향으로 향해야 하는지도 알고있다. 또한 각 라우터들에서 PC1, 2, 3로 가는 경로도 설정해주었다.

     

     

     

    R3#show ip route
    
         1.0.0.0/8 is variably subnetted, 7 subnets, 2 masks
    S       1.1.10.0/24 is directly connected, Serial0/3/1
    S       1.1.12.0/24 is directly connected, Serial0/3/1
    S       1.1.20.0/24 is directly connected, Serial0/3/1
    C       1.1.23.0/24 is directly connected, Serial0/3/1
    L       1.1.23.3/32 is directly connected, Serial0/3/1
    C       1.1.30.0/24 is directly connected, GigabitEthernet0/0
    L       1.1.30.3/32 is directly connected, GigabitEthernet0/0

     

    R3의 라우팅 테이블은 위와 같다. 모든 서브넷이 다 입력되었다. 이제 R1에서 R3으로의 핑이 가능할 것이다.

     

     

     

    R1#ping 1.1.30.3
    
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 1.1.30.3, timeout is 2 seconds:
    !!!!!
    Success rate is 100 percent (5/5), round-trip min/avg/max = 2/36/52 ms

     

    R1에서 R3으로 핑 성공!

     

     

     

     

     

     

     


     

    루프백 인터페이스 (Loopback interface)

     

     

    루프백 인터페이스란, 실제 물리적인 네트워크와 연결되지 않아도 자체적으로 패킷을 수신하고 처리할 수 있는 interface를 말한다. 네트워크 연결 없이 자체적인 테스트를 통해 네트워크가 정상 작동 하는지 확인하는 용도로 사용할 수 있다. 또한 CSU 등에서 신호를 돌려주는 루프백 테스트 등, 장비의 테스트나 네트워크 연결 확인 등에 유용하게 사용된다.

     

     

    R1(config)#interface loopback 0
    R1(config-if)#ip address 1.1.1.1 255.255.255.0
    
    R2(config)#interface loopback 0
    R2(config-if)#ip address 1.1.2.2 255.255.255.0
    
    R3(config)#int lo0
    R3(config-if)#ip address 1.1.3.3 255.255.255.0

     

     

    루프백 interface 설정은 위 명령어로 수행한다. 이때 loopback interface 번호는 0부터 21억 사이의 아무숫자나 입력해도 된다. 보통 루프백 인터페이스를 하나만 만드는 경우에는 0을 사용하는 것이 국룰이다. 또한, no shut을 입력하지 않아도 자동으로 활성화 된다.

     

     

     

    R3#show ip route
    
         1.0.0.0/8 is variably subnetted, 9 subnets, 2 masks
    C       1.1.3.0/24 is directly connected, Loopback0
    L       1.1.3.3/32 is directly connected, Loopback0
    S       1.1.10.0/24 is directly connected, Serial0/3/1
    S       1.1.12.0/24 is directly connected, Serial0/3/1
    S       1.1.20.0/24 is directly connected, Serial0/3/1
    C       1.1.23.0/24 is directly connected, Serial0/3/1
    L       1.1.23.3/32 is directly connected, Serial0/3/1
    C       1.1.30.0/24 is directly connected, GigabitEthernet0/0
    L       1.1.30.3/32 is directly connected, GigabitEthernet0/0

     

     

    Loopback을 활성화 시킨 후의 R3의 라우팅 테이블 결과이다. R3 자신과 자신의 loopback interface (1.1.3.3)가 연결되어 있음을 확인할 수 있다.

     

     

     

     

    → Loopback 인터페이스는 실제 네트워크 연결에 사용하는 것은 아니지만, 네트워크 장비 내에 존재하는 인터페이스이다. 네트워크 에러가 발생했을 때 이를 처리하거나, 장비가 정상 작동하고 있는지 검사할 때 사용된다.

     

     


     

    디폴트 루트 (Default route)

     

     

    디폴트 루트(Default route)란 전송 패킷의 목적지 네트워크가 라우팅 테이블이 존재하지 않을 때, 그 패킷을 대신 전송하는 곳이다. 기본적으로 라우터는 목적지 네트워크 IP 주소가 라우팅 테이블에 없으면 그 패킷을 모두 차단한다. 하지만 디폴트 루트를 설정하면 해당 패킷을 디폴트 루트로 보낸다. 일반적으로 기업체의 네트워크에서 인터넷과 연결되는 라우터에는 대부분 디폴트 루트가 설정되어 있다.

     

     

     

    R3(config)#ip route 0.0.0.0 0.0.0.0 1.1.23.2

     

    디폴트 루트를 설정하는 방법은 위와 같다. 목적지 IP, 목적지 subnet에 전부 0을 입력한 후, 마지막에 디폴트 루트로 설정할 IP 주소를 입력한다.

     

     

     

    R3#show ip route
    
         1.0.0.0/8 is variably subnetted, 9 subnets, 2 masks
    C       1.1.3.0/24 is directly connected, Loopback0
    L       1.1.3.3/32 is directly connected, Loopback0
    S       1.1.10.0/24 is directly connected, Serial0/3/1
    S       1.1.12.0/24 is directly connected, Serial0/3/1
    S       1.1.20.0/24 is directly connected, Serial0/3/1
    C       1.1.23.0/24 is directly connected, Serial0/3/1
    L       1.1.23.3/32 is directly connected, Serial0/3/1
    C       1.1.30.0/24 is directly connected, GigabitEthernet0/0
    L       1.1.30.3/32 is directly connected, GigabitEthernet0/0
    S*   0.0.0.0/0 [1/0] via 1.1.23.2

     

     

    라우팅 테이블에서 디폴트 루트는 (*)로 표시된다.

Designed by Tistory.