10 Linux Network Commands and How to Use Them

Linux, like other advanced operating systems, supports communication over the network. In Linux all settings are stored in accessible files. In this way, certain files can be edited, and necessary settings can be made easily. You can easily manage the commands used for network and DNS settings from the command screen.

In this article you will find information about the most used basic network commands in Linux and how to edit DNS settings.

1. For Network Connection and IP Configuration: ifconfig

The ifconfig command allows you to examine and change the network connection and IP configuration settings available in the system.


Firstly, you see the eth0 information. eth0 is the part that shows the information about your Ethernet card. If other Ethernet cards connected to the system, they would have names such as eth1, and eth2, respectively.

lo represents the computer itself, ie localhost.

If you are using a wireless network environment, you can also see the wlan0 information. wlan0 means the wireless network card.

Instead of using the ifconfig command this way, you can list the desired information one by one. For example, if you want to list only the Ethernet card information, ifconfig eth0 the command will suffice.

 ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet netmask broadcast
inet6 fe00::000:00xx:xx00:0x00 prefixlen 64 scopeid 0x20&lt;link&gt;
ether 08:00:00:00:0x:00 txqueuelen 1000 (Ethernet)
RX packets 11 bytes 3310 (3.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 25 bytes 3050 (2.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


For example, you saw above that the local IP address of eth0 is To change this IP address to

sudo ifconfig eth0 

With ifconfig, you can change the information here, as well as adjust the information cards you encounter in the output. ifconfig card_name down the command can remove the desired card from display, you can show this card again with ifconfig card_name up the command.

sudo ifconfig lo down

As can be seen from the output, the down parameter made the lo card invisible now.

sudo ifconfig lo up

2. A Kind of Control Mechanism: ping

The ping command checks whether communication is established between the target and your system. For example, you can query the communication speed between you and Google.


While doing this, I ended this process with the Ctrl + C combination after the 5th query package. If you use a command like a ping -c 4, you only send 4 query packets. The process will terminate after the number of query packets exhausted.

ping -c 4
PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=111 time=79.0 ms
64 bytes from ( icmp_seq=2 ttl=111 time=73.5 ms
64 bytes from ( icmp_seq=3 ttl=111 time=72.7 ms
64 bytes from ( icmp_seq=4 ttl=111 time=75.1 ms
--- ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3014ms
rtt min/avg/max/mdev = 72.710/75.089/79.030/2.432 ms

3. For IP Routing Table: route

The route command allows you to see the contents of the IP routing table on your system. You can type the route -n command in the console for this.

route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface UG 100 0 0 eth0 U 100 0 0 eth0

The gateway address here is the forwarding address used when passing from the local network to the internet network.

4. Forwarding Tracking for a Specific Target: traceroute

With Traceroute, your command shows you which hosts the packet sent to a specific destination has passed through. This time, let’s think of the target address as an example.

traceroute to (, 30 hops max, 60 byte packets
1 ( 0.430 ms 0.326 ms 0.414 ms
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *

As you can see, to be able to be directed to the desired address, first a request made to the address You can use the traceroute command to see such routing paths and to understand any routing problems that occur in the network.

5. For Domain Information: whois

The whois query contains information such as when the domain established, how long it is valid and so on. Let’s target as an example of a whois query.

Domain Name: GOOGLE.COM
Registry Domain ID: 2138514_DOMAIN_COM-VRSN
Registrar WHOIS Server:
Registrar URL: http:
Updated Date: 2019-09-09T15:39:04Z
Creation Date: 1997-09-15T04:00:00Z
Registry Expiry Date: 2028-09-14T04:00:00Z
Registrar: MarkMonitor Inc.
Registrar IANA ID: 292
Registrar Abuse Contact Email:
Registrar Abuse Contact Phone: +1.2083895740
Domain Status: clientDeleteProhibited https:
Domain Status: clientTransferProhibited https:
Domain Status: clientUpdateProhibited https:
Domain Status: serverDeleteProhibited https:
Domain Status: serverTransferProhibited https:
Domain Status: serverUpdateProhibited https:
Name Server: NS1.GOOGLE.COM
Name Server: NS2.GOOGLE.COM
Name Server: NS3.GOOGLE.COM
Name Server: NS4.GOOGLE.COM
DNSSEC: unsigned
URL of the ICANN Whois Inaccuracy Complaint Form: https:

Also, you can avoid having to use the command screen by using the best websites to look up whois information for free.

6. Getting Information About Target Address: host

The host command allows you to get information about the destination address. With the host command, you can access the domain name from the IP address and the IP address from the domain name.

7. To Look at DNS Records: dig

The dig command (domain information groper) is a common Linux network command used to lookup DNS records.

; <<>> DiG 9.17.21-1-Debian <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64917
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
; IN A
;; Query time: 3 msec
;; WHEN: Thu Apr 14 19:25:15 EDT 2022
;; MSG SIZE rcvd: 44

Also, you can examine NS (Nameserver) records with the dig command. You can use the -t NS the command for this.

dig -t NS
; <<>> DiG 9.17.21-1-Debian <<>> -t NS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41881
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0
;; ANSWER SECTION: 70621 IN NS 70621 IN NS 70621 IN NS 70621 IN NS
;; Query time: 3 msec
;; WHEN: Thu Apr 14 19:34:38 EDT 2022
;; MSG SIZE rcvd: 100

8. For IP-MAC Address Matchings: arp

The arp command shows the tables where IP-MAC Address mappings are kept.

Address HWtype HWaddress Flags Mask Iface ether 52:54:00:12:35:00 C eth0 ether 08:00:27:66:24:25 C eth0

9. For Connections Made by the System: tcpdump

The tcpdump command allows you to instantly view the connections made by your system and the connections made to your system.

tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
19:44:59.746452 IP &gt; homerouter.cpe.domain: 14329+ A? (37)
19:44:59.746574 IP &gt; homerouter.cpe.domain: 39924+ AAAA? (37)
19:44:59.770573 IP &gt; homerouter.cpe.domain: 44735+ A? (53)
19:44:59.770685 IP &gt; homerouter.cpe.domain: 31664+ AAAA? (53)

In addition, if you want to follow the links directly without address resolution, you can use the tcpdump -n command.

tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
19:47:41.327149 IP &gt; 44991+ A? (53)
19:47:41.327574 IP &gt; 46778+ AAAA? (53)
19:47:41.425041 IP > 44991 5/0/0 CNAME, A, A, A, A (157)
19:47:41.425042 IP > 46778 9/0/0 CNAME, AAAA 2600:9000:224a:e400:a:da5e:7900:93a1, AAAA 2600:9000:224a:1c00:a:da5e:7900:93a1, AAAA 2600:9000:224a:9400:a:da5e:7900:93a1, AAAA 2600:9000:224a:8200:a:da5e:7900:93a1, AAAA 2600:9000:224a:c00:a:da5e:7900:93a1, AAAA 2600:9000:224a:8e00:a:da5e:7900:93a1, AAAA 2600:9000:224a:9a00:a:da5e:7900:93a1, AAAA 2600:9000:224a:a400:a:da5e:7900:93a1 (317)
19:47:42.470901 IP &gt; 28874+ A? (45)

10. DNS Settings

Compared to other operating systems, settings DNS on Linux is quite easy. To do this, you can make some changes to the etc/resolv.conf file where DNS information stored.


If you want to add a new DNS here, you can use the echo command.

# echo nameserver >> etc/resolv.conf

After making these additions, when you browse the etc/resolv.conf file again, you will see that the desired changes made.


Inside the /etc/ folder, there is another file called hosts that acts as a domain nameserver. This file is checked when performing domain name resolution in the system. localhost kali
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Network Management Is Simpler With Linux Commands

Linux is one of the most widely used operating systems. Knowing the correct commands used in Linux will be very beneficial in terms of time and effort. When configuring your Linux network and looking for any problems that may occur in the network, you can make use of the Linux network commands.

linux network troubleshooting commands

The 9 Best Linux Network Troubleshooting Commands

Read Next

About The Author

Original Link

Leave a Comment

Your email address will not be published.