DEV Community

David Cao
David Cao

Posted on • Updated on

5 commands you need know about Linux networking

Here are five commands that you can use to check the network status in Linux:

ifconfig

ifconfig: This command displays information about the network interfaces on your system, including their IP addresses, netmasks, and network statistics.

netstat

netstat: This command displays a variety of network-related information in Linux, including active network connections, routing tables, and network statistics.

If you are having trouble connecting to a network resource, such as a web server, you can use netstat to see if there are any active connections to that server. To do this, you can use the -a flag to display all active connections, and the -n flag to display the connections using numerical addresses rather than hostnames. For example:

$ netstat -an | grep <server_ip_address>

This will display any active connections to the server, along with their status and protocol. If there are no active connections, or if the connections are in a state such as TIME_WAIT or CLOSED, it could indicate a problem with the connection.

This article explains more about how to check network status in Linux.

traceroute

traceroute: This command displays the route that packets take to reach a specified network host. It can be useful for troubleshooting network connectivity issues.

ping

ping: This command sends a small packet of data to a specified network host and measures the time it takes for the host to send a reply. You can use this command to determine whether the host is reachable and to measure the round-trip time for packets sent to that host.

If you are having trouble accessing a network resource, such as a web server or a file share, you can use ping to test the connectivity between your system and the host.

To do this, you can use the ping command followed by the IP address or hostname of the target host. For example:

Copy code
$ ping
This will send a series of ICMP echo request packets to the target host and display the results, including the round-trip time for each packet and the percentage of packets that were received.

If the host is reachable, you should see a series of replies from the host indicating that the packets were received. If the host is not reachable, you will see a series of request timeouts indicating that the packets were not received.

If the host is not reachable, there could be a problem with the network connectivity between your system and the host. You can use the traceroute command to see the route that packets are taking between your system and the host, which can help you identify the source of the connectivity issue.

This article explains more about how to use ping command to troubleshooting network issues.

nslookup

nslookup: This command allows you to query Domain Name System (DNS) servers to resolve domain names to IP addresses and vice versa. You can use it to troubleshoot DNS-related issues or to find the IP address associated with a specific domain name.

Top comments (0)