본문 바로가기
Linux

[linux] Gateway ip address 확인: Ubuntu

by ds31x 2024. 2. 6.

Ubuntu (or Debian)

Ubuntu에서 Gateway의 IP를 확인하는 명령어는 다음과 같음: `ip` 를 사용

ip route show

 

위의 명령어는 현재 시스템의 아래와 같이 routing table을 출력한다.

default via 192.168.1.1 dev eth0 proto dhcp metric 100 
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 metric 100 
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 600
  • 해당 정보에서 `default via`로 시작하는 line (첫번째 line)에서 해당 문구 다음이 바로 Gateway의 ip address임.
  • 즉 192.168.1.1 이 Gateway의 ip address임.
  • `dev` 다음에 있는 정보는 연결에 사용되는 network interface를 의미하며 `eht0`라고 표시됨.
  • `eth0`는 보통 etherent으로 유선 연결을 주로 의미함.
위는 ip tool을 사용하는 방식이며,
그냥 ip route만 해도 같은 결과를 얻음.
사실 ip route는 `add`, `del`, `change` 등의 다른 하위명령을 지원함.

다른 방법으로는 다음과 같이 `route` 명령어에 `-n` 옵션을 주는 방식임.

route -n

 

위 명령어는 다음과 같은 형태의 출력이 나옴.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    600    0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     600    0        0 eth0

여기서 `0.0.0.0` 을 Destination으로 하는 line의 Gateway 열에 Gateway의 ip address가 존재함.

`-n` 옵션을 줘야 numerical address로 보여줌 (기본으로는 symbolic name으로 나오는터라...)


같이 읽어보면 좋은 자료들

https://dsaint31.tistory.com/450

 

[CE] Gateway

번역하면 관문이다. 여기에서 나타내듯이 gateway는 다른 네트워크로 들어가는 관문의 역할을 하는 장비 또는 S/W를 가르킨다. 다른 네트워크로 들어가기 위해 거쳐야하는 관문 이란 결국 특정 네

dsaint31.tistory.com

https://dsaint31.tistory.com/entry/CE-Internet-Protocol-Address

 

[CE] Internet Protocol Address (IP Address)

네트워크 상에서 어떤 한 컴퓨터를 찾아낼 수 있는 주소 (= 인터넷 상에서 데이터를 송수신할 목적으로 컴퓨터에게 부여하는 값.)이며 약어로 IP Address로 기재됨. Network 계층 (Layer 3)에서 사용되는

dsaint31.tistory.com

 

728x90