traceroute 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-traceroute
핵심 정리
- IP 패킷이 목적지 호스트까지 거치는 게이트웨이(홉)를 차례로 보여 줍니다.
- TTL을 1부터 하나씩 늘린 UDP 탐침을 보내고, 중간 게이트웨이가 돌려주는 ICMP
TIME_EXCEEDED로 경로를 알아냅니다. 목적지에서PORT_UNREACHABLE이 오면 끝납니다. - 홉마다 탐침 3개를 보내 왕복 시간을 보여 주며, 3초 안에 응답이 없으면
*가 나옵니다. - 자주 쓰는 플래그:
-n(이름 풀이 안 함, 빠름),-m(최대 홉, 기본 30),-q(홉당 탐침 수),-w(응답 대기 초),-s(출발지 주소). - 방화벽이 UDP 33434번 이후 포트나 ICMP를 막으면
* * *만 나올 수 있습니다. 네트워크에 부담을 주므로 자동 스크립트에서는 쓰지 않습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1에서 -d(소켓 디버깅)와 -g(IPv6 소스 라우팅 게이트웨이)가 더해짐) |
| 원문 | IBM Commands Reference — 5.3 Volume 5, 6.1 Volume 5 |
| 파일 | /usr/sbin/traceroute |
| 관련 명령어 | ping, netstat -rn, nslookup, route |
목적
IP 패킷이 네트워크 호스트까지 가는 경로를 출력합니다.
영어 원문
Prints the route that IP packets take to a network host.
구문
traceroute [ -m Max_ttl ] [ -n ] [ -p Port ] [ -q Nqueries ] [ -r ] [ -d ] [ -g gateway_addr ]
[ -s SRC_Addr ] [ -t TypeOfService ] [ -f flow ] [ -v ] [ -w WaitTime ] Host [ PacketSize ]
-d와 -g는 6.1 구문에만 있습니다.
설명
주의: traceroute는 네트워크 시험, 측정, 관리용이며 주로 손으로 장애 지점을 좁힐 때 씁니다. 네트워크에 부담을 주므로 평소 운영 중이나 자동 스크립트에서는 쓰지 않습니다.
traceroute 명령은 최대 생존 시간(Max_ttl)을 작게 한 UDP 탐침 패킷을 보내고, 가는 길의 게이트웨이가 돌려주는 ICMP TIME_EXCEEDED 응답을 들어 인터넷 호스트까지 IP 패킷이 가는 경로를 추적합니다. 탐침은 Max_ttl 1홉에서 시작해, ICMP PORT_UNREACHABLE이 돌아올 때까지 한 홉씩 늘립니다.
ICMP PORT_UNREACHABLE은 호스트를 찾았거나 추적할 수 있는 최대 홉 수에 이르렀음을 뜻합니다.
Max_ttl 값마다 탐침 3개를 보내 다음을 기록합니다.
Max_ttl값- 게이트웨이 주소
- 성공한 탐침마다 왕복 시간
탐침 수는 -q로 늘릴 수 있습니다. 탐침 응답이 서로 다른 게이트웨이에서 오면 응답한 시스템마다 주소를 출력합니다. 3초 타임아웃 안에 응답이 없으면 그 탐침 자리에 *를 출력합니다.
Max_ttl이 1홉 이하인데 응답이 오면 왕복 시간 뒤에 !를 붙입니다. 이는 보통 네트워크 소프트웨어마다 ICMP 응답을 다루는 방식이 맞지 않는다는 뜻으로, 마지막 Max_ttl 값을 두 배로 해서 다시 해 보면 대개 해결됩니다.
왕복 시간 뒤에 붙을 수 있는 다른 표시는 다음과 같습니다.
| 표시 | 뜻 |
|---|---|
!H |
호스트에 닿을 수 없음 |
!N |
네트워크에 닿을 수 없음 |
!P |
프로토콜에 닿을 수 없음 |
!S |
소스 라우팅 실패 |
!F |
단편화 필요 |
탐침 대부분이 오류를 내면 traceroute는 끝납니다.
꼭 줘야 하는 매개변수는 목적지 호스트 이름이나 IP 주소 하나뿐입니다. 탐침 패킷 길이는 나가는 인터페이스의 MTU로 정합니다. UDP 탐침 패킷의 포트는 목적지 호스트가 처리하지 않을 법한 값으로 정합니다.
영어 원문
Attention: The traceroute command is intended for use in network testing, measurement, and management. It should be used primarily for manual fault isolation. Because of the load it imposes on the network, the traceroute command should not be used during normal operations or from automated scripts.
The traceroute command attempts to trace the route an IP packet follows to an Internet host by launching UDP probe packets with a small maximum time-to-live (Max_ttl variable), then listening for an ICMP TIME_EXCEEDED response from gateways along the way. Probes are started with a Max_ttl value of one hop, which is increased one hop at a time until an ICMP PORT_UNREACHABLE message is returned.
The ICMP PORT_UNREACHABLE message indicates either that the host has been located or the command has reached the maximum number of hops allowed for the trace.
The traceroute command sends three probes at each Max_ttl setting to record the following:
Max_ttlvalueAddress of the gateway
Round-trip time of each successful probe
The number of probes sent can be increased by using the -q flag. If the probe answers come from different gateways, the command prints the address of each responding system. If there is no response from a probe within a 3-second time-out interval, an * (asterisk) is printed for that probe.
The traceroute command prints an ! (exclamation mark) after the round-trip time if the Max_ttl value is one hop or less. A maximum time-to-live value of one hop or less generally indicates an incompatibility in the way ICMP replies are handled by different network software. The incompatibility can usually be resolved by doubling the last Max_ttl value used and trying again.
Other possible annotations after the round-trip notation are:
- !H — Host unreachable
- !N — Network unreachable
- !P — Protocol unreachable
- !S — Source route failed
- !F — Fragmentation needed
If the majority of probes result in an error, the traceroute command exits.
The only mandatory parameter for the traceroute command is the destination host name or IP number. The traceroute command will determine the length of the probe packet based on the Maximum Transmission Unit (MTU) of the outgoing interface. The UDP probe packets are set to an unlikely value so as to prevent processing by the destination host.
플래그
| 플래그 | 설명 |
|---|---|
-d |
소켓 수준 디버깅을 켭니다. 6.1부터 |
-f flow |
IPv6 패킷 헤더의 흐름 레이블 필드. 기본 0. |
-g gateway_addr |
IP 소스 라우팅 옵션으로 지정한 게이트웨이를 거쳐 보냅니다. 라우터가 IP 소스 라우팅을 허용해야 하며, IPv6 주소에만 쓸 수 있습니다. 6.1부터 |
-m Max_ttl |
탐침 패킷의 최대 생존 시간(최대 홉 수). 기본 30홉(TCP 연결의 기본값과 같음). |
-n |
홉 주소를 이름과 숫자 대신 숫자로만 출력합니다. 경로의 게이트웨이마다 하는 이름 조회를 줄입니다. |
-p Port |
탐침에 쓸 기본 UDP 포트. 기본 33434. 목적지 호스트에서 기본 포트부터 (기본 + 홉 수 - 1)까지의 UDP 포트가 쓰이지 않아야 하며, 그렇지 않으면 이 옵션으로 쓰지 않는 범위를 고릅니다. |
-q Nqueries |
Max_ttl 값마다 보낼 탐침 수. 기본 3. |
-r |
보통의 라우팅 표를 거치지 않고 붙어 있는 네트워크의 호스트로 바로 보냅니다. 직접 연결된 네트워크가 아니면 오류를 냅니다. routed 데몬의 라우팅 표에 없는 인터페이스로 로컬 호스트를 확인할 때 씁니다. |
-s SRC_Addr |
탐침 패킷의 출발지 주소(숫자 형식). IP 주소가 여럿인 호스트에서 보내는 인터페이스가 아닌 주소를 출발지로 쓰게 합니다. 그 머신의 인터페이스 주소가 아니면 오류를 내고 보내지 않습니다. |
-t TypeOfService |
탐침 패킷의 서비스 유형(TOS, 0~255, 기본 0). 서비스 유형에 따라 경로가 달라지는지 볼 때 씁니다. 쓸모 있는 값은 -t 16(낮은 지연), -t 8(높은 처리량)입니다. |
-v |
TIME_EXCEEDED, PORT_UNREACHABLE 말고 받은 패킷도 보여 줍니다(자세한 출력). |
-w WaitTime |
탐침 응답을 기다릴 시간(초). 기본 3초. |
영어 원문
-d— Enables socket level debugging.-fflow — Sets the flow label field in IPv6 packet header. The default value is 0.-ggateway_addr— Routes the outgoing packets through a specified gateway with the IP source routing option. Before you use this flag, your router must enable IP source routing. This flag is only available for IP version 6 addresses.-mMax_ttl— Sets the maximum time-to-live (maximum number of hops) used in outgoing probe packets. The default is 30 hops (the same default used for TCP connections).-n— Prints hop addresses numerically rather than symbolically and numerically. This flag saves a name-server address-to-name lookup for each gateway found on the path.-pPort — Sets the base UDP port number used in probes. The default is 33434. The traceroute command depends on an open UDP port range of base to base + nhops - 1 at the destination host. If a UDP port is not available, this option can be used to pick an unused port range.-qNqueries — Specifies the number of probes the traceroute command sends at eachMax_ttlsetting. The default is three probes.-r— Bypasses the normal routing tables and sends the probe packet directly to a host on an attached network. If the specified host is not on a directly attached network, an error is returned. This option can be used to issue a ping command to a local host through an interface that is not registered in the routed daemon's routing table.
|
| | |
-sSRC_Addr— Uses the next IP address in numerical form as the source address in outgoing probe packets. On hosts with more than one IP address, the-sflag can be used to force the source address to be something other than the IP address of the interface on which the probe packet is sent. If the next IP address is not one of the machine's interface addresses, an error is returned and nothing is sent.-tTypeOfService — Sets the TypeOfService variable in the probe packets to a decimal integer in the range of 0 to 255. The default is 0. This flag can be used to investigate whether different service types result in different paths. For more information, see TCP/IP Protocols in Performance Tools Guide and Reference. Useful values are-t 16(low delay) and-t 8(high throughput).-v— Receives packets other thanTIME_EXCEEDEDandPORT_UNREACHABLE(verbose output).-wWaitTime — Sets the time (in seconds) to wait for a response to a probe. The default is 3 seconds.
매개변수
| 매개변수 | 설명 |
|---|---|
| Host | 목적지 호스트 이름이나 IP 주소. 꼭 줘야 합니다. |
| PacketSize | 탐침 데이터그램 길이. 기본은 나가는 인터페이스의 MTU로 정합니다. |
영어 원문
- Host — Specifies the destination host, either by host name or IP number. This parameter is required.
- PacketSize — Specifies the probe datagram length. The default packet size is determined by the traceroute command based on the MTU of the outgoing interface.
보안
RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 특권과 권한 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다(6.1 문서에만 있음).
영어 원문
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.
예제
- 사용 예와 출력입니다.
[yak 71]% traceroute nis.nsf.net.
traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 56 byte packet
1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms
7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms
8 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms
9 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms
10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms
11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms
2번과 3번 줄이 같은 것은 두 번째 홉 시스템(lbl-csam.arpa)의 커널 버그로 생존 시간이 0인 패킷을 전달했기 때문입니다. 6~10번 줄에 호스트 이름이 없는 것은 NSFNet(129.140)이 자기 노드의 주소-이름 변환을 제공하지 않기 때문입니다.
- 다른 출력 예입니다.
[yak 72]% traceroute rip.Berkeley.EDU (128.32.131.22)
traceroute to rip.Berkeley.EDU (128.32.131.22), 30 hops max
1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
6 csgw/Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 rip.Berkeley.EDU (128.32.131.22) 59 ms! 39 ms! 39 ms!
이 예에서는 게이트웨이 홉 12개(13은 최종 목적지) 가운데 정확히 반이 "빠져" 있지만, 사실 이 홉들은 게이트웨이가 아니었습니다. 목적지 호스트(Sun OS 3.5를 돌리는 Sun-3 워크스테이션)가 받은 데이터그램의 ttl을 ICMP 응답의 ttl로 그대로 써서 응답이 돌아오는 길에 시간이 다 된 것입니다. ICMP에 대해서는 ICMP를 보내지 않으므로 알림도 없었습니다. 왕복 시간 뒤의 !는 소프트웨어 호환성 문제를 나타냅니다. 원인은 경로 길이의 두 배로 탐침을 보낸 뒤에야 밝혀졌으며, 목적지는 실제로 일곱 홉 떨어져 있었습니다.
자주 쓰는 형태:
traceroute -n 10.20.30.40 # 이름 풀이 없이 빠르게
traceroute -n -q 1 -w 1 10.20.30.40 # 홉당 1번, 1초만 기다림
traceroute -n -s 10.1.2.10 10.20.30.40 # 출발지 주소를 정해서
영어 원문
- A sample use and output is:
[yak 71]% traceroute nis.nsf.net. traceroute to nis.nsf.net (35.1.1.48), 30 hops max, 56 byte packet
1 helios.ee.lbl.gov (128.3.112.1) 19 ms 19 ms 0 ms
2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
3 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 39 ms 19 ms
4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 39 ms
5 ccn-nerif22.Berkeley.EDU (128.32.168.22) 39 ms 39 ms 39 ms
6 128.32.197.4 (128.32.197.4) 40 ms 59 ms 59 ms
7 131.119.2.5 (131.119.2.5) 59 ms 59 ms 59 ms
8 129.140.70.13 (129.140.70.13) 99 ms 99 ms 80 ms
9 129.140.71.6 (129.140.71.6) 139 ms 239 ms 319 ms
10 129.140.81.7 (129.140.81.7) 220 ms 199 ms 199 ms 11 nic.merit.edu (35.1.1.48) 239 ms 239 ms 239 ms
Lines 2 and 3 are the same due to a bug in the kernel on the second hop system (lbl-csam.arpa) that forwards packets with a zero time-to-live. Host names are not printed in lines 6 through 10 because the National Science Foundation Network (NSFNet, 129.140) does not provide address-to-name translations for its nodes.
- Another output example might be:
[yak 72]% traceroute rip.Berkeley.EDU (128.32.131.22) traceroute to rip.Berkeley.EDU (128.32.131.22), 30 hops max
1 helios.ee.lbl.gov (128.3.112.1) 0 ms 0 ms 0 ms
2 lilac-dmc.Berkeley.EDU (128.32.216.1) 39 ms 19 ms 39 ms
3 lilac-dmc.Berkeley.EDU (128.32.216.1) 19 ms 39 ms 19 ms
4 ccngw-ner-cc.Berkeley.EDU (128.32.136.23) 39 ms 40 ms 19 ms
5 ccn-nerif35.Berkeley.EDU (128.32.168.35) 39 ms 39 ms 39 ms
6 csgw/Berkeley.EDU (128.32.133.254) 39 ms 59 ms 39 ms
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 rip.Berkeley.EDU (128.32.131.22) 59 ms! 39 ms! 39 ms!
In this example, exactly half of the 12 gateway hops (13 is the final destination) are "missing." However, these hops were actually not gateways. The destination host, a Sun-3 workstation running Sun OS3.5, used the ttl from the arriving datagram as the ttl in its ICMP reply; thus, the reply timed out on the return path. Because ICMPs are not sent for ICMPs, no notice was received. The ! (exclamation mark) after each round-trip time indicates some type of software incompatibility problem. (The cause was diagnosed after the traceroute command issued a probe of twice the path length. The destination host was really only seven hops away.)
Related information:
- netstat command
- nslookup command
- TCP/IP name resolution
- Trusted AIX®
- RBAC in AIX Version 7.1 Security
리눅스(GNU)와 다른 점
리눅스 traceroute도 기본으로 UDP 탐침(포트 33434부터)을 쓰고 -n, -m, -q, -w, -p, -s의 뜻이 거의 같습니다. 방화벽이 UDP를 막으면 traceroute -I(ICMP)나 traceroute -T -p 443(TCP SYN)을 쓰고, tracepath(권한 없이 MTU까지)나 mtr(ping과 traceroute를 합친 실시간 도구)도 많이 씁니다. 리눅스에서 -g는 IPv4 소스 라우팅 게이트웨이입니다.