Master Essential Linux Network Commands: ifconfig, host, route & traceroute
Learn how to use key Linux networking tools—including ifconfig, host, nslookup, route, and traceroute—to display interface details, query DNS, view routing tables, and trace packet paths, with practical examples, screenshots, and tips such as MAC address spoofing and interface listing.
Reading font
ifconfig
The ifconfig command, similar to Windows' ipconfig, displays network interfaces, subnet masks, and other details. The left column shows the interface name (e.g., lo for the loopback interface). Below is a screenshot of the command output.
Related Tips
1. Print network interface list
By using ifconfig and cut to extract the first ten characters of each line, you can list interface names. Screenshot below.
2. MAC address spoofing
In some cases, you may need to spoof a hardware (MAC) address for authentication or filtering. The following command (requires root) changes the MAC address. Screenshot shows the result.
host and nslookup
These are DNS lookup tools. host lists all IP addresses for a domain, while nslookup provides detailed DNS information. Example screenshot querying www.baidu.com.
route
The route command displays the routing table, which contains information about how packets are forwarded. Using the -n option shows addresses numerically. Screenshot below.
traceroute
tracerouteshows each gateway a packet traverses, helping measure the number of hops to a destination. Example tracing www.baidu.com shows 12 hops.
For questions about attribution, corrections or content rights, please contactand we will review it promptly.