장치별 gate way 를 출력 하고 싶습니다 !!

wootz의 이미지

장치별 gateway 를 출력 하고 싶은데
뭐 좋은 방법이 없을까요 ?
장치는 : static , dhcp , pppoe 이런 종류가 한장치에 있습니다 !!
이런 장치를 같은 명령어로 gateway 정보를 출력 할수 있는 게 뭐가 있을까요 ?
netstat -rn 으로 하니깐 default 만 나오네요 ~~
다른 명령이 없을까요 ?
제가 gateway 를 3개 사용 하고 있습니다 !!
좋은 방법 없을까요 ?

지리즈의 이미지

traceroute를 이용하세요.

There is no spoon. Neo from the Matrix 1999.

무혼인형의 이미지

지리즈 wrote:
traceroute를 이용하세요.

좀 자세히 알려주시겠습니까?
Quote:
[root@localhost root]# traceroute
Version 1.4a12
Usage: traceroute [-dFInrvx] [-g gateway] [-i iface] [-f first_ttl]
[-m max_ttl] [ -p port] [-q nqueries] [-s src_addr] [-t tos]
[-w waittime] [-z pausemsecs] host [packetlen]

저도 같은 경우 인데..

Quote:
traceroute -i eth0 168.126.63.1 -m 1
로 eth0의 게이트 웨이는 알아 낼 수 있었는데..

Quote:
ping -I eth1 168.126.63.1
로는 핑이 잘 나가요..
그러나
route 데이블에 디폴트 게이트웨이가 없는 eth1의 경우
Quote:
traceroute -i eth1 168.126.63.1 -m 1
로 eth1의 게이트웨이를 알아볼려고 하니 타임아웃이 나오더군요..

디폴트로 안잡혀 있는건 어떻게 알아낼 수 있을까요?

mushim의 이미지

커널의 모든 라우팅 정보는 /proc/net/route 에 저장되고, netstat -nr 은 이 라우팅 테이블을 알기 쉽게 보여줍니다.

따라서, netstat -nr 만 보면 모든 게이트웨이에 대한 정보를 알 수 있습니다.

무혼인형의 이미지

netstat 만으로 알아낼 수 있나요?

# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
61.xx.xx.1      0.0.0.0         255.255.255.255 UH        0 0          0 ppp0
xxx.xx.xxx.xxx  0.0.0.0         255.255.255.192 U         0 0          0 eth0
210.xxx.xxx.0   0.0.0.0         255.255.252.0   U         0 0          0 eth1
0.0.0.0         210.xxx.xxx.1   0.0.0.0         UG        0 0          0 eth1

eth0 는 내부 스위치로 연결되어 있고
eth1 는 케이블 모뎀
eth2 는 ADSL(PPPoE)
디폴트 게이트 웨이는 eth1.. 즉 케이블 모뎀쪽만 볼 수 있습니다.(210.xxx.xxx.1)
eth2의 ppp0의 게이트웨이는 host 로 등록되어있어, 61.xx.xx.1 이라는것 을 알수 있는데..

dhcp-dhcp 로 연결 한 경우 즉..
eth0 는 내부 스위치로 연결되어 있고
eth1 는 케이블 모뎀
eth2 는 ADSL(DHCP)

# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
ooo.ooo.oo.oo   0.0.0.0         255.255.255.192 U         0 0          0 eth0
211.ooo.ooo.0   0.0.0.0         255.255.255.0   U         0 0          0 eth1
211.oo.ooo.0    0.0.0.0         255.255.255.0   U         0 0          0 eth2
0.0.0.0         211.oo.ooo.1    0.0.0.0         UG        0 0          0 eth2

로 봐서는 디폴트 게이트웨이로 나오는 eth2밖에 알아낼 수 없습니다..

IP대역(eg.211.ooo.ooo.0/24)만 가지고 계산하는 법은 없을까요?

무혼인형의 이미지

장치가 dhcp인 경우 알아냈습니다 :)

레드햇8은 dhcp 클라이언트로 dhclient를 사용하네요.. 이프로그램은 접속정보가 /var/lib/dhcp 에 저장이 되는데..

cat /var/lib/dhcp/dhclient-eth1.lease | grep routers

이런 식으로 뽑아 올 수 있었습니다..

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.