Use Basic Networking Commands in Linux (Ping, Tracert, Nslookup, Netstat, ARP, RARP, Ip, Ifconfig, Dig, Route)
Use Basic Networking Commands in Linux (Ping, Tracert, Nslookup, Netstat, ARP, RARP, Ip, Ifconfig, Dig, Route)
Linux ifconfig stands for interface configurator. It is one of the most basic commands used in
network inspection.
ifconfig is used to initialize an interface, configure it with an IP address, and enable or disable
it. It is also used to display the route and the network interface.
1. IP address
2. MAC address
3. MTU(Maximum Transmission Unit)
Syntax:
Ifconfig
Output:
This picture shows the IP address of 3 networks, Ethernet, local network, and WLAN.
Using this command, you can get details of a specific interface. This is shown below.
Commands:
ifconfig eth0
ifconfig lo
ifconfig wlan0
2. ip
Syntax:
1. ip a
2. ip addr
This command can also be used to get the details of a specific interface.
Syntax:
ip a show eth0
ip a show lo
ip a show wlan0
3.traceroute
Linux traceroute is one of the most useful commands in networking. It is used to troubleshoot
the network. It detects the delay and determines the pathway to your target. It basically helps
in the following ways:
traceroute <destination>
If you don't have the traceroute service installed in your system, you can install it using the
following command:
Example:
Command:
$ traceroute google.com
Linux ping is one of the most used network troubleshooting commands. It basically checks
for the network connectivity between two nodes.
The ping command sends the ICMP echo request to check the network connectivity.
Syntax:
ping <destination>
Example:
Command:
$ ping google.com
5. netstat
It provides statistical figures about different interfaces which include open sockets, routing
tables, and connection information.
Syntax:
netstat
Output:
Syntax:
netstat -p
Syntax:
netstat -s
Syntax:
netstat -r
6. dig
Linux dig command stands for Domain Information Groper. This command is used in DNS
lookup to query the DNS name server. It is also used to troubleshoot DNS related issues.
It is mainly used to verify DNS mappings, MX Records, host addresses, and all other DNS
records for a better understanding of the DNS topography.
Syntax:
dig <domainName>
Example:
$ dig google.com
Output:
dig command outputs the A records by default. If you want to specifically search for MX or
NS type, use the syntax below.
Command:
$ dig google.com MX
To get all types of records at once, use the keyword ANY ass below:
Command:
The dig command does the query on the servers listed in /etc/resolv.conf.
7. nslookup
Linux nslookup is also a command used for DNS related queries. It is the older version of
dig.
Syntax:
nslookup <domainName>
Example:
nslookup google.com
Output:
google.com
8. route
Linux route command displays and manipulates the routing table existing for your system.
A router is basically used to find the best way to send the packets across to a destination.
Syntax:
route
Output:
The above output displays all the existing routing table entries for the system. It says that if
the destination address is within the network range of 10.0.0.0 to 10.0.0.255, then the
gateway is *, which 0.0.0.0. This is a special address that indicates a non-existent
destination.
The packets which lie outside this network range will be forwarded to the default gateway,
which is further routed.
You can use -n in the option in the syntax to display the output incomplete numerical form.
Syntax:
route -n
To add a gateway
The packets that are not within the range are forwarded to the specific gateway. You can
specify the gateway address using the following command.
Syntax:
The kernel maintains all the routing cache information in a table for faster routing. To list the
routing cache information, use the following command,
Syntax:
route -Cn
9. arp
Linux arp command stands for Address Resolution Protocol. It is used to view and add
content to the kernel's ARP table.
Syntax:
arp
All the systems maintain a table of IP addresses and their corresponding MAC addresses.
This table is called the ARP Lookup table. When a destination is requested to connect
through IP address, your router will check for the MAC address in this table. If it is cached,
the table will not be used.
By default, arp displays the hostnames. You can get the IP addresses, by using :
Command:
$ arp -n
10.RARP
Output: