728x90
반응형

 

Routing 개요

  • Routing은 OSI 7 Layer에서 Network Layer 즉 3계층에서 수행되는 과정
  • 네트워크 주소인 IP 주소를 이용하여 목적지까지 전달하기 위한 경로 선택 과정
  • 해당 과정은 Routing Table을 통해 경로를 지정할 수 있으며, Routing 우선순위를 설정할 수 있음
  • 다중 네트워크 인터페이스를 사용할 경우 우선순위에 따라 원하는 통신이 안될 수도 있음

 

 

 

Routing Table 확인

  • 보통 아래 3가지 명령어로 확인
    # route 
    # route -n
    # netstat -rn

  • Destination: 목적지, 네트워크 대역 or 호스트 주소, 0.0.0.0은 모든 대역
  • Gateway: 게이트웨이 주소
  • Genmask: 목적지의 넷마스크
  • Flags: U=라우팅 가능, H=목적지가 호스트, G=해당 게이트웨이를 경유
  • Metric: 여러 경로 중 최적의 경로 설정 (우선순위), 숫자가 낮을수록 우선순위 높음
  • Ref: 경로 참조 횟수
  • Use: 경로 검사 횟수
  • Iface: 패킷을 보낼 네트워크 인터페이스

 

 

 

Routing Table 형식

Inbound Routing 추가/삭제

# route [add/del] [-net/-host] <Destination address> netmask <netmask address> gw (gateway ip) dev <interface> metric (1~9999)

  • [add/del]: 추가/삭제
  • [-net/-host]: 네트워크 대역/호스트
  • netmask <netmask address>: genmask 설정
  • gw (gateway ip): 경로할 Gateway 주소, 생략 시 0.0.0.0 설정
  • dev <interface>: Network Interface 이름
  • metric (1~9999): 우선 순위 설정, 생략 시 0 설정

* [ ] = 선택  <> = 필수  ( ) = 생략가능

 

 

Default Routing

  • Routing Table에 매칭된 경로가 없는 경우 마지막 경로 Default Routing을 사용
  • Default Routing 경로는 보통 Destination이 0.0.0.0이며, 모든 대역을 의미

 

 

Outbound Routing 추가/삭제

# route [add/del] default gw <gateway ip> dev (interface) metric (1~9999)

  • [add/del]: 추가/삭제
  • default : Default route 즉 Destination 0.0.0.0 설정
  • gw <gateway ip>: 경로할 Gateway 주소
  • dev (interface): Network Interface 이름, 생략 시 해당 대역에 맞는 Interface 설정
  • metric (1~9999): 우선 순위 설정, 생략 시 0 설정

 

# route [add/del] [-net/-host] <Destination address> netmask <netmask address> gw <gateway ip> dev (interface) metric (1~9999)

  • [add/del]: 추가/삭제
  • [-net/-host]: 네트워크 대역/호스트
  • netmask <netmask address>: genmask 설정
  • gw <gateway ip>: 경로할 Gateway 주소
  • dev (interface): Network Interface 이름, 생략 시 해당 대역에 맞는 Interface 설정
  • metric (1~9999): 우선 순위 설정, 생략 시 0 설정

 

 

 

 

Routing Table 예시

  • ens34는 내부망과 통신 시 사용 (192.168.1.0/24), 내부망은 외부와 통신 불가능
  • ens37은 외부와 통신 시 사용 (192.168.0.0/24)

 

[Inbound] Routing Table 추가/삭제

  • [inbound] 전 대역의 Gateway에서, 목적지가 192.168.1.0/24의 대역인 경우 Interface ens34로 라우팅 (추가)
    # route add -net 192.168.1.0 netmask 255.255.255.0 dev ens34
    # route -n

 

  • [inbound] 전 대역의 Gateway에서, 목적지가 192.168.1.0/24의 대역인 경우 Interface ens34로 라우팅 (삭제)
    # route del -net 192.168.1.0 netmask 255.255.255.0 dev ens34
    # route -n

 

  • Routing Tables 추가 시 network 통신이 가능한 Routing만 추가 됨 
  • 없는 네트워크 대역은 추가 되지 않음

 

 

 

[outbound] Routing Table 추가/삭제

  • [outbound] 192.168.0.1의 게이트웨이에서 목적지가 전 대역(Default Routing 0.0.0.0)인 경우 라우팅 (추가)
    # route add default gw 192.168.0.1
    # route -n

 

 

  • [outbound] 192.168.0.1의 게이트웨이에서 목적지가 전 대역(Default Routing 0.0.0.0)인 경우 라우팅 (삭제)
    # route del default gw 192.168.0.1
    # route -n

 

  • [outbound] 목적지가 172.168.0.0/24의 주소인 경우 gw 192.168.1.1을 통해 라우팅 (추가)
    # route add -net 172.16.0.0 netmask 255.255.255.0 gw 192.168.1.1

 

  • [outbound] 목적지가 172.168.0.0/24의 주소인 경우 gw 192.168.1.1을 통해 라우팅 (삭제)
    # route del -net 172.16.0.0 netmask 255.255.255.0 gw 192.168.1.1

 

 

 

[L - 08] 다중 Network Interface Routing 우선순위

개요 다중 Network Interface를 사용하는 경우 Routing 우선순위에 따라 통신이 안될 수도 있음 동일한 네트워크 주소가 Destination에 다중으로 등록되어 있으면, Metric에 따라 Routing 수행 Routing 우선 순위.

sa2da-sac.tistory.com

 

728x90

'*OS > [ L ] Linux' 카테고리의 다른 글

[L - 09] proc 디렉터리  (0) 2022.01.20
[L - 08] 다중 Network Interface Routing 우선순위  (0) 2022.01.19
[L - 06] xinetd 서비스 설정 파일  (0) 2022.01.06
[L - 05] Linux 로그 파일 요약  (0) 2022.01.04
[L - 04] Linux 명령어  (0) 2021.12.31

+ Recent posts