Skip to main content

Networking Commands

====================================================================================

Show networking information

show current networking configuration and status

ip a

Show IPv4 or IPv6 specifically

ip -4 a

ip -6 a

Show IPs assigned to interfaces in simple format

ip -br addr

show network interfaces

ip l

show configuration for a specific interface

ip a s interfacename

show route table

ip r

show arp cache

ip n

------------------------------------------------------------------------------------------------------------------------------------------  

Changing networking information

Add an IP address to an interface:

ip a a IPADDRESS dev interfacename

Delete an IP from an interface

====================================================================================

Network Troubleshooting

------------------------------------------------------------------------------------------------------------------------------------------  

traceroute/6

The traceroute command is used to send a request to a domain/IP. The output then includes each server that the request has passed through to get to the target:

root@test:~# traceroute google.com
traceroute to google.com (142.250.185.78), 30 hops max, 60 byte packets
 1  pfsense.b4sed.xyz (192.168.1.1)  0.162 ms  0.120 ms  0.097 ms
 2  100.88.196.1 (100.88.196.1)  0.374 ms  0.392 ms  0.372 ms
 3  core23.fsn1.hetzner.com (213.239.203.141)  0.432 ms core22.fsn1.hetzner.com (213.239.254.113)  5.252 ms core23.fsn1.hetzner.com (213.239.203.141)  0.383 ms
 4  core21.fsn1.hetzner.com (213.239.224.14)  5.029 ms core5.fra.hetzner.com (213.239.224.78)  5.003 ms  4.982 ms
 5  72.14.218.176 (72.14.218.176)  5.067 ms 142.250.160.234 (142.250.160.234)  5.087 ms 72.14.218.94 (72.14.218.94)  6.109 ms
 6  * * *
 7  142.250.214.190 (142.250.214.190)  5.225 ms fra16s48-in-f14.1e100.net (142.250.185.78)  5.223 ms 142.250.210.208 (142.250.210.208)  6.215 ms

You can also use traceroute for IPv6 connections:

traceroute6 ip/hostname

------------------------------------------------------------------------------------------------------------------------------------------  

mtr ( My TraceRoute)

The mtr command is very similar to traceroute, except the data is formatted more nicely, and the output continuously updates.

mtr google.com

 Host                                           Loss%   Snt   Last   Avg  Best  Wrst StDev
 1. pfsense.b4sed.xyz                           0.0%    33    0.3   0.2   0.2   0.4   0.1
 2. 100.88.196.1                                0.0%    33    9.8   1.1   0.4   9.8   1.7
 3. core21.fsn1.hetzner.com                     0.0%    33    3.2   1.2   0.5   6.1   1.4
 4. hos-tr4.ex3k5.dc4.fsn1.hetzner.com          0.0%    32    5.3   5.3   5.1   5.6   0.1
 5. 142.250.160.234                             0.0%    32    5.2   5.4   5.1   6.5   0.3
 6. 72.14.239.217                               0.0%    32    5.4   5.6   5.2   7.1   0.4
 7. 142.250.62.151                              0.0%    32    5.4   5.3   5.2   5.5   0.1
 8. fra16s48-in-f14.1e100.net                   0.0%    32    5.3   5.3   5.1   5.5   0.1

------------------------------------------------------------------------------------------------------------------------------------------  

tracepath/6

Tracepath is similar to both of the above commands, however, it has more of a focus on the connection to each host. Tracepath spends 30 seconds analysis the connection between the local machine, and each machine identified as a hop in the trace, making it ideal to identify whether slow responses from a device on the trace are causing slow loading issues.

You can also use tracepath for IPv6 connections:

traceroute6 ip/hostname

====================================================================================