본문 바로가기

Network

traceroute

traceroute의 동작 & traceroute block


TTL=1 부터 시작하여 TTL +1 증가하는 패킷을 전송하여 목적지까지의 hop 구한다.

 

처음에 TTL=1 packet 받은 라우터는 Time-To-Live Exceed 출발지로 전송한다.

패킷을 받은 출발지는 해당 라우터의 IP 가능한경우 DNS 이름을 기록하게 된다.

다음 TTL=2 패킷을 전송하여 다음 hop 찾아내는 작업을 이어간다.

 

Traceroute 정상범위가 아닌 포트 번호를 포함한 패킷을 전송하는데, 패킷이 최종목적지에서 수신 되면 Port Unreachable 메시지가 출발지로 전송 것이다. 것을 보고 목적지까지 패킷이 도달하였음을 판단하게 된다. (근데 실제 패킷을 떠보니 그런것 같지 않다? - Windows 에서 - 이것은 뒤에서 볼 것이지만 Unix 에서의 동작이다)

 


Windows 에서의 traceroute 동작


 

 


 

 

 

 

Google 까지 traceroute 실행한 것으로 중간에 Port unreachable PC 수신 되었으나 계속 진행 되는 것을 있다. 아무래도 목적지 IP에서 받은 port unreachable 아니기 때문으로 생각이 된다.

 

그리고 google쪽에 도달한 패킷은 port unreachable 아닌 echo reply 응답이 되었다.

 

 

traceroute_analysis.pcapng

 

 

 

 

 

Traceroute Windows Unix 또는 프로그램별로 동작하는 방법이 다르다!

 

The challenge with traceroute is that different OS's and applications implement the traceroute function differently.  The standard Windows traceroute run the MS-DOS prompt which sends ICMP echo request packets to the destination, incrementing the IP TTL for each hop.  The standard Unix traceroute, on the other hand, sends UDP packets using ports 33434-33534 to the destination incrementing the IP TTL for each hop.

 

With this behavior in mind, to block Windows traceroutes, create a security rule using the "ping" application.  To block Unix traceroutes use a custom application created for UDP ports 33434-33534.

 

 

원본 위치 <https://live.paloaltonetworks.com/t5/Configuration-Articles/How-to-Block-Traceroute-through-the-Firewall/ta-p/60813>

 

 

 

Ubuntu 에서의 traceroute 동작

 

 

 

 

 

 

TTL 값을 증가 시키는 것은 윈도우와 동일하나 invalid port number 포함한 UDP 패킷을 전송 하고 있다.

그리고 마지막 목적지에서는 Port unreachable 응답한다.

 

 

tracert_ubuntu.pcapng

 

 

따라서 traceroute 응답을 하지 않도록 하는 iptables rule은 일반적으로 아래와 같이 2 종류를 추가 한다.

 

/* DROP Port Unreachable */
iptables -A OUTPUT -o 인터페이스 -p icmp --icmp-type 3/3 -j DROP

 

/* DROP Time-to-live Exceed */
iptables -A OUTPUT -o 인터페이스 -p icmp --icmp-type 11 -j DROP

 

 

 

참고 링크

 

http://www.rjsmith.com/tracerte.html

 

http://www.terms.co.kr/traceroute.htm

 

https://live.paloaltonetworks.com/t5/Configuration-Articles/How-to-Block-Traceroute-through-the-Firewall/ta-p/60813