Linux Traceroute命令教程和示例

2023-11-06

The network is an important part of the system administration. Because without a network the server has nothing to do. While administrating Linux servers troubleshooting network is very important. When a network problem occurs in a Linux server first step is checking network services and the route information. Network services can be checked with systemctl or similar commands. Network routes can be checked with different tools but the most popular and straightforward tool is traceroute . We will look at usage examples of traceroute in this tutorial.

网络是系统管理的重要组成部分。 因为没有网络,服务器无关。 在管理Linux服务器时,对网络进行故障排除非常重要。 当Linux服务器中出现网络问题时,第一步是检查网络服务和路由信息。 可以使用systemctl或类似命令检查网络服务。 可以使用其他工具检查网络路由,但是最流行和最直接的工具是traceroute 。 我们将在本教程中查看traceroute的用法示例。

关于traceroute命令 (About traceroute Command)

Networking is a stand-alone profession done by its professionals. But some simple tools need to know by system administrators. Traceroute mainly uses ICMP packets. ICMP is a protocol mainly developed for network troubleshooting and information sharing. ICMP packets are transmitted between network-capable devices to share information about network traffic. ICMP packets have TTL value. TTL is time to live where holds information about hop count. Generally, all network devices are one hop and as an example when ICMP packets send to poftut.com 

网络是由其专业人员完成的独立工作。 但是系统管理员需要了解一些简单的工具。 Traceroute主要使用ICMP数据包。 ICMP是主要为网络故障排除和信息共享而开发的协议。 ICMP数据包在具有网络功能的设备之间传输,以共享有关网络流量的信息。 ICMP数据包具有TTL值。 TTL是生存时间,用于保存有关跳数的信息。 通常,所有网络设备都是一跳,以ICMP数据包发送到poftut.com

traceroute命令语法 (traceroute Command Syntax)

The syntax of the traceroute is like below.

traceroute的语法如下。

 traceroute OPTIONS HOST PACKET_LENGTH

traceroute命令帮助 (traceroute Command Help)

Help about traceroute commands can get like below.

关于traceroute命令的帮助如下。

$ traceroute
Help
Help
帮帮我

查找到主机的路由,IP地址,网站(Find Route To The Host, IP Address, Website)

As we stated before traceroute will find the route to the given destination like host, IP address, website, etc. In this example, we will route to the site named but the destination can be an IP address or hostname in a local area network.

正如我们在traceroute之前所述,将找到到给定目标的路由,例如主机,IP地址,网站等。在此示例中,我们将路由到命名的站点,但目标可以是局域网中的IP地址或主机名。

$ traceroute poftut.com
Find Route To The Host, IP Address, Website
Find Route To The Host, IP Address, Website
查找到主机的路由,IP地址,网站

This example provides information about the route. There are 18 hops to the destination. Which is shown in the first column. In the second column, the hop names are provided. and in the other columns, the operation metrics are provided. If we look to the example we see that * * * lines. Those are used to inform that these hops do not provide information about themselves.

本示例提供有关路线的信息。 到目的地有18跳。 在第一列中显示。 在第二列中,提供了跃点名称。 在其他列中,提供了操作指标。 如果查看示例,则会看到* * *行。 这些用于通知这些跃点不提供有关其自身的信息。

LEARN MORE  Introduction To Scapy Network Packet Generator
了解更多Scapy网络数据包生成器简介

显示IP地址不解析主机名(Show IP Address Do Not Resolve Host Name)

In the previous example, the hosts are expressed with their hostnames. Hostnames give more clues about the host. But the disadvantage of the hostname is that it should be resolved. As we know all operation is done with IP addresses but the IP addresses are expressed with their hostnames by using DNS. This will slow the trace operation. The -n option can be used to disable hostname resolution.

在前面的示例中,主机以其主机名表示。 主机名提供了有关主机的更多线索。 但是主机名的缺点是应该解析它。 众所周知,所有操作都是通过IP地址完成的,但是IP地址是通过使用DNS的主机名来表示的。 这将减慢跟踪操作。 -n选项可用于禁用主机名解析。

$ traceroute -n poftut.com
Show IP Address Do Not Resolve Host name
Show IP Address Do Not Resolve Hostname
显示IP地址不解析主机名

设定回应时间(Set Response Time)

By tracing the path the ICMP packet transmission will occur. We will send the ICMP packet to the destination hop and we will wait for the answer. Sometimes this answer can come back late or never came back. This will slow our network trace operation. We can set time for the response and make our network trace operation faster. In the example, we set a timeout for the trace 1 second with -w option.

通过跟踪路径,将发生ICMP数据包传输。 我们将把ICMP数据包发送到目标跃点,我们将等待答案。 有时,这个答案可能会迟到或永远不会回来。 这将减慢我们的网络跟踪操作。 我们可以设置响应时间,并使我们的网络跟踪操作更快。 在示例中,我们使用-w选项为跟踪设置了1秒超时。

$ traceroute -n -w 1 poftut.com
Set Response Time
Set Response Time
设定回应时间

设置每跳查询数(Set Number Of Queries Per-Hop)

We send ICMP packets to the hop and this hop sends back responses. We call this round trip as a query. Traceroute by default makes 3 queries for each hop. This is a changeable property. This can be changed with -q parameter. In the following example, we set the query count as 1 for each hop.

我们将ICMP数据包发送到该跃点,并且此跃点发送回响应。 我们将此往返称为查询。 默认情况下,Traceroute对每个跃点进行3个查询。 这是一个可变属性。 可以使用-q参数更改。 在以下示例中,我们将每个跃点的查询计数设置为1。

$ traceroute -n -q 1 poftut.com
Set Number Of Queries Per Hop
Set Number Of Queries Per-Hop
设置每跳查询数

为ICMP设置TTL( Set TTL For ICMP)

We have previously talked about the TTL value. By default, this TTL value is set as 30. This means that we can only reach up to 30 hops. Because in each hop this TTL value is incremented and after hop number 30 the TTL will be 0 and the packet will not be transmitted to the next hop. In this example, we will set TTL number 8 which will only reach the first 8 hops.

我们之前已经讨论过TTL值。 默认情况下,此TTL值设置为30。这意味着我们最多只能达到30个跃点。 因为在每个跃点中,此TTL值都会增加,并且在跃点编号30之后,TTL将为0,并且不会将数据包传输到下一个跃点。 在此示例中,我们将设置TTL数字8,仅到达前8个跃点。

$ traceroute  -m 8  poftut.com
 Set TTL For ICMP
Set TTL For ICMP
为ICMP设置TTL

设定TTL计数 (Set TTL Count)

By default, the traceroute command will show all hops starting from 1 to the last hop. In some situations, we only need only some part of the hops starting from the n’th hop. This can be set with the -f option. In this example, we will start from hop number 10.

缺省情况下,traceroute命令将显示从1到最后一跳的所有跳。 在某些情况下,我们仅需要从第n个跃点开始的跃点的一部分。 可以使用-f选项设置。 在此示例中,我们将从第10跳开始。

$ traceroute  -f 10  poftut.com
Set Start TTL
Set Start TTL
设定开始TTL

打印自治系统(AS)号 (Print Autonomous System (AS) Numbers)

The Internet is a very big public network. There are a lot of parties that provide connections for each other in a mesh topology. These parties are generally ISP’s or big companies and those are called in internet terminology as Autonomous Systems. All AS’s have their unique identifiers called AS numbers. While hoping in different AS’s their AS numbers can be printed with -A option.

互联网是一个非常大的公共网络。 在网格拓扑中,有很多参与方彼此提供连接。 这些参与方通常是ISP或大公司,在互联网术语中称为“自治系统”。 所有AS都有其唯一的标识符,称为AS号。 当希望输入不同的AS时,可以使用-A选项打印其AS编号。

$ traceroute  -A  poftut.com
Print Autonomous System (AS) Numbers
Print Autonomous System (AS) Numbers
打印自治系统(AS)号

We can see the AS numbers like [AS9121] after the IP address of hop.

跳的IP地址后面可以看到[AS9121]类的AS号。

LEARN MORE  IPv4 vs IPv6 - What Are Similarities and Differences?
了解更多IPv4与IPv6-异同是什么?

指定源接口 (Specify Source Interface)

In enterprise environments, Linux systems generally have multiple interfaces for high availability. Multiple interfaces mean multiple paths to the destination. Linux has default routes which mean primary interfaces for out of network destinations. This is used by default but we can specify another interface with the -i option. But first, we will list available interfaces with the ip command.

在企业环境中,Linux系统通常具有多个接口以实现高可用性。 多个接口意味着到达目的地的多个路径。 Linux具有默认路由,这意味着用于网络外目标的主要接口。 默认情况下使用它,但是我们可以使用-i选项指定另一个接口。 但是首先,我们将使用ip命令列出可用的接口。

$ ip link
Specify Source Interface
List Interfaces
列出接口

Now we will specify the network device name. But keep in mind that these options require root privileges which can be provided with sudo command.

现在,我们将指定网络设备名称。 但是请记住,这些选项需要root特权,可以通过sudo命令提供。

$ sudo traceroute  -i ens3  poftut.com
Specify Source Interface
Specify Source Interface
指定源接口

指定网关(Specify Gateway)

IP packets are firstly redirected to the host where it’s specified in the network configuration of the source system. This first hop/host is called a gateway. By default, this gateway is used by traceroute. We can change this gateway information with the -g option. In this example, we will set IP address 192.168.122.1 as gateway address.

IP数据包首先被重定向到源系统的网络配置中指定的主机。 此第一跳/主机称为网关。 默认情况下,traceroute使用此网关。 我们可以使用-g选项更改此网关信息。 在此示例中,我们将IP地址192.168.122.1设置为网关地址。

$ sudo traceroute  -g 192.168.122.1  poftut.com

翻译自: https://www.poftut.com/linux-traceroute-command-tutorial-examples/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux Traceroute命令教程和示例 的相关文章

  • 与 Eclipse 中的 Java Content Assist 交互

    作为我的插件项目的一部分 我正在考虑与 Eclipse 在 Java 文件上显示的内容辅助列表进行交互 我正在尝试根据一些外部数据对列表进行重新排序 我看过一些有关创建新内容辅助的教程 但没有看到有关更改现有内容辅助的教程 这可能吗 如果是
  • Android:文本淡入和淡出

    我已阅读此 stackoverflow 问题和答案 并尝试实现文本淡入和淡出 Android中如何让文字淡入淡出 https stackoverflow com questions 8627211 how to make text fade
  • 将巨大的模式编译成Java

    有两个主要工具提供了将 XSD 模式编译为 Java 的方法 xmlbeans 和 JAXB 问题是 XSD 模式确实很大 30MB 的 XML 文件 大部分模式在我的项目中没有使用 所以我可以注释掉大部分代码 但这不是一个好的解决方案 目
  • java inputstream 打印控制台内容

    sock new Socket www google com 80 out new BufferedOutputStream sock getOutputStream in new BufferedInputStream sock getI
  • 如何在单个查询中搜索 RealmObject 的 RealmList 字段

    假设我有一堂课 public class Company extends RealmObject private String companyId private RealmList
  • 在主目录中安装库

    在 Linux Ubuntu 中 我尝试运行一个工具 但它显示错误 库丢失 我无权在系统中安装任何内容 或者根本无法从我的用户帐户执行 sudo 是否可以在我的主目录 没有 sudo 中安装缺少的库 在我的例子中为 libstdc so 6
  • Java 中如何将 char 转换为 int? [复制]

    这个问题在这里已经有答案了 我是Java编程新手 我有例如 char x 9 我需要得到撇号中的数字 即数字 9 本身 我尝试执行以下操作 char x 9 int y int x 但没有成功 那么我应该怎么做才能得到撇号中的数字呢 ASC
  • arm-linux-gnueabi 编译器选项

    我在用 ARM Linux gnueabi gcc在 Linux 中为 ARM 处理器编译 C 程序 但是 我不确定它编译的默认 ARM 模式是什么 例如 对于 C 代码 test c unsigned int main return 0x
  • 从jar中获取资源

    我有包含文件的 jar myJar res endingRule txt myJar wordcalculator merger Marge class 在 Marge java 中我有代码 private static final Str
  • Akka 与现有 java 项目集成的示例

    如果我已经有现有的javaWeb 应用程序使用spring and servlet容器 将 Akka 集成到其中的正确方法是什么 就像我将会有Actor1 and Actor2互相沟通的 开始使用这些演员的切入点是什么 例如 1 把它放在那
  • 如何将 HTML 链接放入电子邮件正文中?

    我有一个可以发送邮件的应用程序 用 Java 实现 我想在邮件中放置一个 HTML 链接 但该链接显示为普通字母 而不是 HTML 链接 我怎样才能将 HTML 链接放入字符串中 我需要特殊字符吗 太感谢了 Update 大家好你们好 感谢
  • 使用 Elastic Beanstalk 进行 Logback

    我在使用 Elastic Beanstalk 记录应用程序日志时遇到问题 我正在 AWS Elastic Beanstalk 上的 Tomcat 8 5 with Corretto 11 running on 64bit Amazon Li
  • 轻松的反应

    我有一个与这里描述的类似的案例 动态更改RESTEasy服务返回类型 https stackoverflow com questions 3786781 dynamically change resteasy service return
  • 手动设置Android Studio的JDK路径

    如何为 Android Studio 使用自定义 JDK 路径 我不想弄乱 PATH 因为我没有管理员权限 是否有某个配置设置文件允许我进行设置 如果您查看项目设置 您可以从那里访问 jdk 在标准 Windows 键盘映射上 您可以在项目
  • Android S8+ 警告消息“不支持当前的显示尺寸设置,可能会出现意外行为”

    我在 Samsung S8 Android 7 中收到此警告消息 APP NAME 不支持当前的显示尺寸设置 可能会 行为出乎意料 它意味着什么以及如何删除它 谢谢 通过添加解决supports screens 机器人 xlargeScre
  • 如何更改 Ubuntu 14.04 上的 php-cli 版本?

    我是 Linux 新手 在篡改时破坏了一些 php 设置 如果我执行一个包含以下内容的 php 脚本 phpinfo 它显示 php 版本为 5 6 但通过命令行 如果我运行php v它返回 7 0 版本 我想让两个版本匹配 我怎样才能修复
  • java 中的蓝牙 (J2SE)

    我是蓝牙新手 这就是我想做的事情 我想获取连接到我的电脑上的蓝牙的设备信息并将该信息写入文件中 我应该使用哪个 api 以及如何实现 我遇到了 bluecove 但经过几次搜索 我发现 bluecove 不能在 64 位电脑上运行 我现在应
  • Spring RESTful控制器方法改进建议

    我是 Spring REST 和 Hibernate 的新手 也就是说 我尝试组合一个企业级控制器方法 我计划将其用作未来开发的模式 您认为可以通过哪些方法来改进 我确信有很多 RequestMapping value user metho
  • java'assert'和'if(){}else exit;'之间的区别

    java和java有什么区别assert and if else exit 我可以用吗if else exit代替assert 也许有点谷歌 您应该记住的主要事情是 if else 语句应该用于程序流程控制 而assert 关键字应该仅用于
  • Java 和/C++ 在多线程方面的差异

    我读过一些提示 多线程实现很大程度上取决于您正在使用的目标操作系统 操作系统最终提供了多线程能力 比如Linux有POSIX标准实现 而windows32有另一种方式 但我想知道编程语言水平的主要不同 C似乎为同步提供了更多选择 例如互斥锁

随机推荐

  • 求字符相似度的广度优先搜索问题请教

    有n名选手在玩游戏 他们每个人有一个字符 每个字符都有自己固定的若干个特征 特征的种类数为k 每个人的特征为特征总集的一个子集 两个字符的相似度定义为 如果两个字符A和B同时拥有某个特征或者同时没有某个特征 它们的相似度加一 蒜头君想创造出
  • 区块链三加一:去中心化的分布式记账系统

    区块链分布式账本技术的发展有利于人们掌控个人信息 并通过不变的记录保存服务或产品交易 减少对集中系统的依赖 而这场革命正在创造一个去中心化的可信环境 从而颠覆传统业务 区块链技术的核心是分布式记账 去中心化 不容易篡改 比特币等数字货币是区
  • 【PTA】【C语言】判断给定整数是否素数[加强版]

    素数是指在大于1的自然数中 除了1和它本身以外 不能被其他自然数整除的数 本题要求编写程序 判断从键盘输入的数是否素数 如果是素数 输出XX is prime number 的信息 输出XX is not prime number 的信息
  • jquery 取值 radio 问题

    1 获取选中值 三种方法都可以 input radio checked val input type radio checked val input name rd checked val 2 设置第一个Radio为选中值 input ra
  • android 文字高斯模糊,android高斯模糊

    高斯模糊 param context param sentBitmap param radius 0 lt radius lt 25 return SuppressLint NewApi public static Bitmap fastB
  • 【HUAWEI】PPP&PPPoE配合Radius认证配置案例

    背景 对于在一个大的园区网 要保证接入的安全性和合法性 有许多种手段 对于到端的接入用户 可以使用802 1X 对于移动办公人员 可以使用SSL 可以配合使用IPS 防火墙 上网行为管理等手段 不过 对于网关分布的网络呢 或者说 公司合并
  • 如何替代即将淘汰的Flash方案?

    欢迎大家前往腾讯云 社区 获取更多腾讯海量技术实践干货哦 本文由MarsBoy发表于云 社区专栏 导语 Web技术飞速发展的如今 我们在感受新技术带来的便捷和喜悦的同时 也时常在考虑着一个问题 老技术如何迁移 正如本文的主题一样 Flash
  • unity 项目仿cs知识点

    一 简介 1 人物部分 a 人物移动 b 镜头旋转 c 玩家开枪 动画 音频 枚举 弹孔 倍镜 2 敌人部分 a 敌人克隆 b 走向玩家 距离 方向 朝向 点乘 叉乘 二 人物部分 1 人物移动 CharacterController c
  • 几种主流国产linux操作系统配置pyqt5环境说明

    一 银河麒麟桌面 pyqt5已安装 直接运行就行 二 银河麒麟服务器 python3 get pip py local bin pip3 install pyqt5 python3 test1 py This application fai
  • JavaScript中的深拷贝

    1 什么是深拷贝 浅拷贝只是解决了第一层的拷贝问题 拷贝第一层的 基本类型值 以及第一层的 引用类型地址 并没有递归拷贝第二层以后的属性 深拷贝会拷贝所有的属性 拷贝的属性指向动态分配的内存 当对象和它所引用的对象一起拷贝时即发生深拷贝 深
  • C语言头插法创建双链表

    1 问题描述 使用头插法创建双链表 2 与单链表不同的是 双链表的结构体中多了一个变量就是指向当前节点的前驱节点 这样我们在循环遍历的时候可以通过当前节点的前驱指针找到前驱节点 在创建双链表的时候比单链表多了一个步骤就是对于前驱指针的操作
  • OpenMMLab OpenMMLab mmdeploy v1.1.0模型部署(一)

    一 MMDepoly整体框架 模型部署是指把机器学习训练生成的算法模型 部署到各类云 边 端设备上去 并使之高效运行 从而将算法模型实际地应用到现实生活中的各类任务中去 从而实现AI 的智能化转型 目前 我们已经支持 5 个算法库和 5 种
  • 动态规划:国王与金矿

    题目解析 有一个国家发现了5座金矿 每座金矿的黄金储量不同 需要参与挖掘的工人数也不同 参与挖矿工人的总数是10人 每座金矿要么全挖 要么不挖 不能派出一半人挖取一半金矿 要求用程序求解出 要想得到尽可能多的黄金 应该选择挖取哪几座金矿 第
  • 乔宇:深度模型让机器理解场景

    点击上方 深度学习大讲堂 可订阅哦 编者按 所谓场景 无论是 万家灯火 亦或是 巴山夜雨 于人是一种直观自然的感受 然而 对于机器而言 再多的温情脉脉 都也只是计算机世界冰冷的二进制符号 这区别的背后 其实是人在成长过程中形成的对世界的认知
  • OpenMV IDE通信协议分析

    OpenMV IDE通信协议分析 OpenMV IDE 通过usb cdc模式连接板端 也就是usb上虚拟了一个串口 基于串口实现了一套指令应答的交互协议 早期基于stm32 usb口实现 目前openmv适配扩展到多芯片上ide dbg调
  • linux循环结构和选择结构,Shell脚本:选择结构、循环结构、

    1 选择结构 1 选择结构的定义 选择结构是程序中带有判断的一种逻辑结构 只有符合一定的条件 程序体才会被执行 2 Linux shell 选择结构分类 if then控制结构 case esac控制结构 if then 控制结构 单分支
  • Python对某视频弹幕进行爬取,完成文本数据分析

    本文主要使用jieba requests wordcloud matplotlib imageio等包完成数据爬取 文本数据分析 可视化 弹幕数据 目录 1 爬取弹幕数据 分词并统计高频词 爬取数据 统计高频词 2 词性分析并生成词性分布条
  • Unity的C#编程教程_61_委托和事件 Delegates and Events 详解及应用练习

    文章目录 C Delegates C Events Example Working with C Delegates and Events Challenge Teleport Events Practical Event Driven P
  • 如何下载更改typora的主题

    文件 偏好设置 外观 获取主题 进入typora主题页typora主题页网址 选择合适的主题 从github页下载到第5步所打开的文件夹中 将css文件与pie文件夹放在typora主题文件夹中 在typora编辑器中更改主题 完成
  • Linux Traceroute命令教程和示例

    The network is an important part of the system administration Because without a network the server has nothing to do Whi