howtouselinux

4 Ways to Check Network Status on Linux

Table of Contents

Linux network management is an important task for Linux admins. We’ll cover the basics of network status via the Linux command line today. These Linux commands below are based on the TCP/IP model. These commands are safe to run without changing any of our network configurations.

Check network status using ifconfig command in Linux

To check the network status in Linux, you can use the ‘ifconfig’ command. This command will give you information on the status of your network interfaces.

If you want to check the status of a specific interface, you can use the ‘ifconfig’ command followed by the interface name. For example, if you want to check the status of your ‘eth0’ interface, you would use the following command:

ifconfig eth0

This command will give you information on the status of your ‘eth0’ interface, including the IP address, netmask, broadcast address, and more.

If you want to see all of the interfaces on your system, you can use the ‘-a’ option with the ‘ifconfig’ command. For example:

ifconfig -a

This command will show you all of the interfaces on your system, including any that are not currently active.

The ifconfig command is also used to configure a network interface. The basic syntax for the ifconfig command is: ifconfig interface ip address netmask broadcast_address

This will set the IP address, netmask and gateway for the specified network interface. You can also use the ifconfig command to enable or disable a network interface. The basic syntax for this is: ifconfig interface up or down

The “ifconfig” command is a command-line utility that is used to display information about your network interfaces. This command is available on most Unix-like operating systems, including Linux and macOS. We can also use ifconfig command to troubleshoot network issues.

If you receive a message “ifconfig command not found” when you try to use it, you can run the following command to install it.

On Debian based distros:
# apt update
# apt install net-tools

On Red Hat based distros:
# dnf install net-tools

Related: Step by Step Guide to troubleshoot a network issue in Linux

Layer 1: The physical layer

  1. # ip link show – check network interface status (up /down)
  2. # ethtool eth0 – ethtool is used for querying settings of an ethernet device like network speed, packet drop info etc

 

ip link show

The “ip link show” command is used to show detailed information about the network interfaces on your system. The “ip link show” command has the following syntax: ip link show [<interface>]. The “interface” parameter specifies the name of the interface that you want to view information about.

Here’s an example: ip link show eth0. This command will display information about interface eth0, MAC address, interfaces status etc (the first Ethernet interface).

ethtool

ethtool is a tool that can be used to view or change the settings of a network interface. Here’s an example: ethtool eth0. This command will display information about interface eth0 (the first Ethernet interface).

 

Layer 2: The data link layer

  1. # ip neighbor show – shows the current neighbor table in kernel. 
  2. # arp – lists the current contents of the ARP cache without any additional options

 

arp

The “arp” command is used to view and modify the ARP (Address Resolution Protocol) cache on your system. The “arp” command has the following syntax: arp [-i interface] [-a] [-d host] [-s host] [address]. The “interface” parameter specifies the name of the interface that you want to view information about.

Here’s an example: arp -i eth0. This command will display ARP information about interface eth0 (the first Ethernet interface).

 

Layer 3: The network/internet layer

  1. # ip address show – show the ip address for each network interface
  2. # ifconfig -a – show the ip address for all the network interfaces
  3. # ping www.google.com
  4. # traceroute www.google.com
  5. # ip route show – show the route table
  6. # nslookup www.google.com – DNS lookup for google.
  7. # dig google.com – DNS lookup for google.com

 

ip address show

The “ip address show” command is used to view information about the IP addresses assigned to a network interface. The “interface” parameter specifies the name of the interface that you want to view information about. Here’s an example: ip address show eth0

This command will display information about the IP addresses assigned to interface eth0

 

Layer 4: The transport layer

  1. # ss -tunlp4 – get statistics about your network connections
  2. # telnet database.example.com 3306 – check the remote port status
  3. # nc 192.168.122.1 -u 80 – check the remote port status
  4. # netstat -anpl – check all the network connections

 

netstat

The “netstat” command is used to view information about the active network connections and sockets on your system.This command will display information about all of the active network connections and sockets on your system.

The “netstat” command has the following syntax: netstat [-a] [-t] [-n] [-u]

  • The “-a” parameter displays all of the active network connections and sockets.
  • The “-t” parameter displays the TCP connections.
  • The “-n” parameter displays the IP addresses and port numbers in numerical form.
  • The “-u” parameter displays the UDP connections.

Here’s an example: netstat -a. This command will display information about all of the active network connections and sockets, including the TCP, UDP, and RAW sockets.

 

Related Post:

6 ways to Check a remote port is open in Linux

Troubleshoot Network Slow Problems In Linux

 

 

David Cao
David Cao

Hey there! I am David, a Cloud & DevOps Enthusiast and 18 years of experience as a Linux engineer. I work with AWS, Git & GitHub, Linux, Python, Ansible, and Bash. I am a technical blogger and a Software Engineer, enjoy sharing my learning and contributing to open-source.