Rate this post

Last Updated on May 15, 2021 by Vikash Ekka

Basic Networking Commands
Basic Networking Commands in Linux


A network is a group of computers and computing devices like mobile phones, printers and scanners, etc.. these devices are connected through cables or wireless media.

Computers are connected in a network to exchange information or resources with each other. Computer loaded with Linux Operating System can also be a part of a network whether it is a small or large network by its multitasking and multi-user natures. Maintaining of system and network up and running is a task of a System/ Network Administrator’s job.


Ifconfig command

Ifconfig (also known as Interface Configurator), is the first type of basic command used by network administrators. This command is used to view the IP address and MAC address of the system.

Using ifconfig, you can enable or disable an interface on demand as required. Also, ifconfig with an interface (eth0) command only shows specific interface details like IP Address, MAC Address, etc.

The command shows the desired output like MAC or Hardware Address, IPv4, and IPv6 address for the eth0 adapter.


vetechno@sr:~$ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.12.52 netmask 255.255.252.0 broadcast 192.168.19.255
inet6 ff81::971c:18ff:fe45:19a3 prefixlen 64 scopeid 0x20<link>
ether 9a:2d:67:65:19:w31 txqueuelen 1000 (Ethernet)
RX packets 31151731 bytes 2815986106 (2.8 GB)
RX errors 0 dropped 3320148 overruns 0 frame 0
TX packets 174658 bytes 15527750 (15.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


To enable or disable a specific interface, command #ifup eth0 or #ifdown eth0.

Ping command

PING(Packet Internet Groper) is used to test connectivity between two nodes located on Local Area Network (LAN) or Wide Area Network (WAN)

Ping uses ICMP (Internet Control Message Protocol) to communicate to other devices. You can ping hostname or IP address using the below command as shown in the adjoining image.

vikash.ekka@vetechno:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=113 time=39.5 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=113 time=28.9 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=113 time=36.8 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=113 time=34.4 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 28.939/34.892/39.459/3.880 ms

In Linux ping command keep executing until you interrupt. To terminate the continuous ping, press the key combination of the Control key and “C”.


Traceroute command

traceroute is a network troubleshooting utility that shows the number of hops taken to reach a destination and also determines packets traveling path.


Traceroute helps in tracing the route to the global DNS server IP Address and able to reach the destination also shows the path of that packet traveling on the network or Internet. The image shows the traceroute command to the google.com web server.

traceroute is a network troubleshooting utility which shows the number of hops

Netstat command

Netstat (Network Statistic) command displays connection information, routing table information, etc. Netstat is also used to find the open ports in a particular network based connection.

The adjoining image shows the netstat command used to list the open ports during a network based connection.

Netstat is used to

  • Print network connections

  • Routing tables

  • Interface statistics

  • Masquerade connections and multicast groups.

Netstat (Network Statistic) command

Basic networking command -dig and nslookup

The basic networking tools to gather DNS related information is

Dig (domain information groper)
        
       
DIG will query DNS related information like A Record, CNAME, MX (that is Mail exchange) Record etc. This command is mainly used to troubleshoot DNS related queries.
          
The image shows the dig command to gather information about website vetechno.in

Dig (domain information groper)

 

The second command is nslookup, this command is also used to find out DNS related queries. The following example shows A Record (IP Address) of the website vetechno.in

nslookup command in linux

ethtool command

ethtool is a utility for Linux kernel-based operating systems for displaying and modifying parameters of network interface controllers (NICs) and their device drivers. 
  • ethtool is developed and inbuilt to the Linux kernel.

  • ethtool is used to view, setting speed and duplex of your Network Interface Card (NIC)

The table shows the optional basic networking commands.


Networking tools / commands


Description

 
    nmap

Scan open ports on a network, important for security analysis

  
    iptraf

Monitor network traffic in text mode

 
  
    mtr

Combines functionality of ping and traceroute, to give upadated display

  
    tcpdump

Dumps network traffic for analysis


 

By Vikash Ekka

Hi All, My name is Vikash Ekka from India. I’m the founder and tech editor of https://www.vetechno.in. I have completed my Graduation in BCA. I love to write technical articles like Windows, Linux & MAC Tutorials, Tips, Tricks, How To fix, Tutorials About Ethical Hacking & Cyber Security Guide, and Software Review. Currently, I have been working as an IT professional since 2018.

Leave a Reply

Your email address will not be published. Required fields are marked *