11 Essential Linux Commands For Network Configuration and Troubleshooting

Like other Operating System, Linux is also a multi-tasking and multi user Operating System. The systems are connected each other through networking media to exchange information each other. That being said, every Linux System talks to other system through network and it’s media. The network configuration of a system is also a part of System Admin profile. So, to be a good System Administrator you should have a sound knowledge of Networking also. In this post, we are going to see some essential Linux networking commands which may be useful in daily operations.

Also Read:-

Linux commands Part-1
Linux commands Part-2
Linux commands Part-3
Linux commands Part-4

1. ip or ifconfig
The ip command is available quite some time now. But the people are still using deprecated ifconfig command. An ip command is more powerful and is going to replace ifconfig command in coming days. With ip command we can configure IP address to the interface instantly and also can add or remove route in routing table. Also you can see the network devices and configuration details like IP Address, Gateway, MAC or Ethernet address of NIC etc.
Below command shows Interfaces details like IP Address, Gateway, Ethernet address etc.
ifconfig
ip addr show
Enable a single network interface with command below (In your case interface name may vary).
# ifconfig enp0s3 up
# ip link set enp0s3 up
Disable single network interface with command below(In your case interface name may vary).

# ifconfig enp0s3 down
# ip link set enp0s3 down
Sample output
2. ping

ping is the very first command to check the availability or reachability of the system which sends ICMP “Echo Request” to the interface and waits for response. Ping is use to test the connectivity and determine the response time. If we won’t get a reply for a certain period of time, that means either system is dead or system is not in a network.

Syntax
$ ping <IP>

3. traceroute or tracepath
traceroute command is deprecated and unavailable in CentOS/RHEL 8 version and same is replaced by tracepath command. This is a very important command to find the path used by packet to reach a destination. This tool is very helpful for troubleshooting to narrow down the network unreachable issue. 
4. netstat or ss 
netstat command is also deprecated and replaced by ss command. However, it’s still available most of the Linux system. The ss command is to dump socket statistics and display information like netstat command. With this command, you will get detail information about how the Linux system is communicating with other system. This tool helps for troubleshooting of various networking issues.
# ss -t -a
-a : Display all Listening or Established TCP connections
-t : tcp connections
Sample output
5. ip route
This is the command to management routing tables to show, add and delete static route. 
# ip route add 172.24.24.0/24 via 172.24.24.1 dev enp0s3
# ip route del 172.24.24.0/24 via 172.24.24.1 dev enp0s3
In your case interface name enp0s3 might be differ. So change it appropriately. To know more about ip route command do “man ip route” from console.

6. dig
Domain Information Gropher aka DIG command is to query DNS information of domain. It is also use for troubleshooting of DNS related issue.
Sample output
A : “A” record for domain
NS : “Name Server” for domain
AAAA : IPv6 “A” record

7. nslookup
Name Server Lookup or nslookup command line tool is to query domain name system (DNS) to obtain domain name or IP address mapping.


To know more about nslookup command do “man nslookup from console.
8. host
host command is also to perform DNS lookups it will resolve hostname to IP address or vice-versa.

9. nmcli
Network Manager Command Line tool “NMCLI” which is use to control NetworkManager. nmcli command is to create, show, edit, interface up or down. Also you can manage teaming information using nmcli command.

10. telnet

telnet command is to connect remote system over a TCP/IP which runs on port 23. If telnet command executes without argument, it will enter into command or interactive mode and shows it’s prompt as “telnet>”With telnet command you can check the running service at remote system also.

11. tcpdump

tcpdump is a command line tool to capture network packets going through or receiving in your system. It’s a powerful network packet analyzer tool. This will help to troubleshoot the network issues.
# tcpdump -i enp0s3
This will print packets in and out through interface enp0s3 (In your case interface name might be different).
Sample Output.
That’s It. In this article, we have seen some of the network commands for Linux administrator to configure and troubleshooting the network related issues if any in Linux system. Please like and share it with others. Also like us on our Facebook Official Page.

 

Leave a Comment