Operations 11 min read

Master Linux Network Commands: ifconfig, ping, traceroute, and More

This guide explains how to use essential Linux networking utilities—including ifconfig, ping, traceroute, netstat, dig, nslookup, route, host, arp, ethtool, iwconfig, and hostname—covering their purpose, common options, and practical command‑line examples for system administration tasks.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Network Commands: ifconfig, ping, traceroute, and More

ifconfig

The ifconfig utility displays and configures network interface parameters in the Linux kernel. Changes made with ifconfig are temporary and disappear after a reboot unless they are written to the interface configuration files (e.g., /etc/sysconfig/network-scripts/ifcfg-eth0).

# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.24.186.123  netmask 255.255.240.0  broadcast 172.24.191.255
        ether 00:16:3e:24:5d:8c  txqueuelen 1000  (Ethernet)
        RX packets 36773275  bytes 9755326821 (9.0 GiB)
        TX packets 31552596  bytes 6792314542 (6.3 GiB)
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        RX packets 36893510  bytes 27158894604 (25.2 GiB)
        TX packets 36893510  bytes 27158894604 (25.2 GiB)

To view a specific interface, run ifconfig eth0. Assign an IP address and netmask with:

# ifconfig eth0 192.168.1.110 netmask 255.255.255.0

Enable or disable the interface with ifup eth0 and ifdown eth0 respectively.

Change the MTU size (default 1500) with: # ifconfig eth0 mtu 9000 Put the interface into promiscuous mode (requires root) with:

# ifconfig eth0 promisc

ping

The ping utility sends ICMP echo‑request packets to test connectivity. By default it runs until interrupted; use -c N to stop after N packets.

# ping 127.0.0.1
# ping www.rumenz.com
# ping -c 5 www.rumenz.com

traceroute

traceroute

displays the sequence of hops a packet traverses to reach a destination, showing each hop’s IP address and round‑trip time.

# traceroute 8.8.8.8

netstat

netstat

prints various network statistics, including routing tables, interface counters, and open sockets.

# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         gateway         0.0.0.0         UG      0   0        0   eth0
link-local      0.0.0.0         255.255.0.0     U       0   0        0   eth0
172.24.176.0    0.0.0.0         255.255.240.0   U       0   0        0   eth0

dig

dig

queries DNS servers and prints detailed answer sections, useful for troubleshooting DNS resolution.

# dig www.rumenz.com
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.7 <<>> www.rumenz.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11798
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.rumenz.com.            IN  A
;; ANSWER SECTION:
www.rumenz.com.     583 IN  A   42.194.162.109
;; Query time: 0 msec
;; SERVER: 100.100.2.136#53(100.100.2.136)
;; WHEN: Sat Nov 20 21:45:32 CST 2021
;; MSG SIZE  rcvd: 48

nslookup

nslookup

performs DNS lookups and can query specific record types with the -type (or -t) option.

# nslookup www.rumenz.com
Server:         100.100.2.136
Address:        100.100.2.136#53

Non-authoritative answer:
Name:   www.rumenz.com
Address: 42.194.162.109

# nslookup -type=CNAME www.baidu.com
www.baidu.com is an alias for www.a.shifen.com.

route

The route command displays and manipulates the kernel IP routing table.

# route
# route add -net 10.10.10.0/24 gw 192.168.0.1
# route del -net 10.10.10.0/24 gw 192.168.0.1
# route add default gw 192.168.0.1

host

host

looks up DNS records for a given name. Use -t to specify the record type (e.g., CNAME, NS, MX, SOA).

# host www.rumenz.com
www.rumenz.com has address 42.194.162.109
# host -t CNAME www.baidu.com
www.baidu.com is an alias for www.a.shifen.com.

arp

arp

displays and modifies the ARP cache, mapping IP addresses to MAC addresses.

# arp -e
Address              HWtype  HWaddress           Flags Mask            Iface
gateway              ether   ee:ff:ff:ff:ff:ff   C      eth0

ethtool

ethtool

queries and changes Ethernet device settings such as speed, duplex, and link status.

# ethtool eth0
Settings for eth0:
        Link detected: yes

iwconfig

iwconfig

configures wireless network interfaces or displays their parameters. Install it on RHEL/CentOS with yum install -y wireless-tools.

# iwconfig eth0
eth0      no wireless extensions.

hostname

hostname

shows or sets the system’s network name. To make a permanent change, edit /etc/sysconfig/network (or /etc/hostname on newer distributions) and reboot.

# hostname
rumenz.com
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

networkpingtraceroutenetstatdignslookupifconfig
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.