متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 68Network · Linux

How to trace the network path to a host

A site is slow or unreachable from one office but fine from another. Somewhere between you and the server, packets are lost or delayed — but where? tracepath, traceroute and mtr show every hop (router) on the way and the time to it. This how-to runs them, explains how to read the result (and why * * * is usually not the problem), uses TCP tracing through firewalls, and collects a report you can send to the provider.

  • 5 الدروس
  • 5 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

68.1

The quick answer

tracepath -n shop.example.com
mtr -rwzc 50 shop.example.com
traceroute -T -p 443 -n shop.example.com

mtr (my traceroute) = traceroute + ping for every hop — the best tool for a report. Packages: mtr (RHEL: mtr), traceroute; tracepath is in iputils.

الأوامر في هذا الدرس

68.2

Step by step

  1. Start simple — is the host up, and what is the normal time?
ping -c 5 shop.example.com
  1. See the hops — tracepath needs no root and also shows the path MTU:
tracepath -n shop.example.com
 1?: [LOCALHOST]                      pmtu 1500
 1:  10.0.1.1                          0.512ms
 2:  192.0.2.1                         4.201ms
 3:  no reply
 4:  203.0.113.9                      21.877ms reached
  1. Measure loss per hop with mtr (50 rounds, report mode):
mtr -rwzc 50 shop.example.com
HOST                    Loss%   Snt   Last   Avg  Best  Wrst StDev
1. AS???  10.0.1.1       0.0%    50    0.5   0.6   0.4   1.1   0.1
2. AS64500 192.0.2.1     0.0%    50    4.1   4.3   3.9   6.0   0.4
3. AS64500 198.51.100.7 40.0%    50   12.2  12.5  11.9  14.1   0.4
4. AS64501 203.0.113.9   0.0%    50   21.8  22.1  21.5  24.0   0.5
  1. Read it the right way:
  • Loss at one middle hop but not at the later hops (hop 3 above) = that router just does not answer pings with priority. Not a problem.
  • Loss that starts at a hop and continues to the end = a real problem from there on.
  • A big jump in time that stays for all later hops = a slow link (or a long distance, for example Europe → Asia).
  • * * * / no reply = the router does not answer. Normal on many networks.
  1. Through firewalls that block ICMP/UDP — trace with TCP to the real port:
traceroute -T -p 443 -n shop.example.com
mtr -rwzc 50 --tcp --port 443 shop.example.com
  1. Send a good report to the provider or the network team: the mtr report from both directions (from you to the server, and from the server back to you), time of the test, and your public IP.

68.3

Check that it worked

You know where the path goes wrong: inside your network (first hops), at your provider, on the internet, or at the server's side (last hops). After the fix, mtr shows 0 % loss at the last hop and normal times.

68.4

Common problems

ProblemCauseFix
Only * * * after hop 2Firewalls drop the UDP/ICMP probes.Use TCP: traceroute -T -p 443 or mtr --tcp.
traceroute: command not foundNot installed.dnf install traceroute mtr / apt install traceroute mtr-tiny, or use tracepath.
You do not have enough privileges to use this traceroute methodTCP mode needs root.Run with sudo.
Loss shown at a middle hop onlyICMP rate limiting on that router.Ignore it — look at the last hop.
The way back is differentInternet routing is often not symmetric.Run mtr from the server to you too.
pmtu smaller than 1500A VPN or tunnel on the way.Lower the MTU / MSS clamping on the VPN, if big packets fail.

68.5

Go further

1mtr shows 40 % loss at hop 3 but 0 % at hops 4 and 5. Is there a problem?

No — that router only gives low priority to answering probes; the traffic itself passes.

2How do you trace through a firewall that blocks ICMP?

Trace with TCP to an open port: traceroute -T -p 443 HOST or mtr --tcp --port 443 HOST.

كل الأوامر في هذا الفصل