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.
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
Help about traceroute commands can get like below.
关于traceroute命令的帮助如下。
$ traceroute
查找到主机的路由,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.
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.
显示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.
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.
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.
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.
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.
打印自治系统(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.
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.
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 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.