Computers are usually connected in networks, which are groups of computer systems and other computing hardware devices that are linked together through communication channels, thus they can facilitate communication and resource sharing among a wide range of users.
This article describes some of the most commonly used network configuration and troubleshooting commands in Linux. They are various tools that can be useful when computers are connected on a network with other computers both within a local network and over the Internet, and you need to get more detailed information about other computers. All of these commands must be entered on the command line in your Linux and you must press the ENTER button to execute the desired command. Please note that all Linux commands are case sensitive.
Login to your Linux server using SSH
1. PING command
The “Ping” command is the best way to check the connection between the source computer and the specified destination computer. Ping uses ICMP (Internet Control Message Protocol) to communicate with other devices.
On Linux, the ping command continues execution until it is interrupted with Control + c from the keyboard. If you want to exit after N number of requests (success or failure) you must use the -c option.
ping -c 5 andreyex.ru
2. Ifconfig command
The “Ifconfig” command is used to display information about the current network configuration. In addition, you can configure the IP address, subnet mask, or broadcast address for the network interface. With this command you can view IP addresses and assign Hardware / MAC address for the interface.
The MTU and Metric fields show the current MTU and metric values for this interface. The RX and TX lines show how many packets were received or transmitted without errors, how many errors occurred, how many packets were lost (probably due to insufficient memory) and how many were lost due to overflow.
If you want to see a specific network interface like eth0 you need to enter:
3. TRACEROUTE command
Traceroute is a network troubleshooting utility that shows the number of flights taken to reach a destination. It also determines the path of packets.
4. DIG (Domain Information Groper) is a command line network administration tool for performing Domain Name System (DNS) queries to obtain information about host addresses, mail exchanges, name servers, and related information. This tool can be used on any Linux (Unix) or Macintosh OS X operating system. Typically, the most typical use is to simply request a single host.
If you want to query MX records for google.com enter the following command:
dig MX yandex.ru
Information about what we need in the answer in this section.
5. The NETSTAT command is a command line tool that displays network connections (inbound and outbound), routing tables, and a number of network interfaces (network interface controller or specific network interface software).
For example :
Gives us the following output:
Now we can see all active connections and TCP and UDP ports that the computer is listening to.
To display information about the routing table, use -r.