4.4 Your Computer on the Network
Key Takeaways
- Hosts join a local network; routers forward between networks; the Internet is the global interconnection of networks
- ip addr show (modern) and ifconfig (legacy) display interface addresses; ip route show and route display the routing table
- DNS resolver settings live in /etc/resolv.conf; /etc/hosts maps names to addresses locally without querying DNS
- IPv4 uses dotted decimal (e.g. 192.0.2.10); IPv6 uses colon-hex notation; ping tests reachability; host queries DNS names
- netstat and ss show socket/connection state—ss is the modern replacement on many systems, but Essentials may mention either
Your Computer on the Network (Objective 4.4)
Linux Essentials expects a clear mental model of networking—not Cisco-level routing design. You should know how a host gets an address, how it finds a default gateway, how names become addresses, and which commands show that information.
Networks, routers, and the Internet
A network is a group of devices that can reach each other under shared addressing and local forwarding rules (your home LAN or office VLAN is a network). A router (or gateway) forwards packets between networks—for example, from your LAN to your ISP. The Internet is the global interconnection of many networks using standard protocols (especially IP). Your laptop is one host on a local network; when you browse a website, packets typically leave via a default route toward a router that can reach the wider Internet.
Addressing: IPv4 and IPv6
| Family | Shape (Essentials view) | Example style |
|---|---|---|
| IPv4 | 32-bit addresses, usually written dotted decimal | 192.0.2.10 |
| IPv6 | 128-bit addresses, colon-separated hex | 2001:db8::1 |
Interfaces may have IPv4, IPv6, or both (dual stack). Essentials does not require calculating subnet masks by hand, but you should recognize which notation is which and that both can appear in ip/ifconfig output.
Showing addresses: ip and ifconfig
| Command | Role |
|---|---|
ip addr show (or ip a) | Modern way to list interfaces and IP addresses |
ip link show | Link/state information for interfaces |
ifconfig | Legacy tool still seen in docs and older systems |
On current distributions, the ip command from iproute2 is preferred. ifconfig may be missing unless a legacy package is installed, but exam questions may still mention it as the older equivalent for “show my IP.” When reading output, identify the interface name (eth0, ens33, wlan0, …) and the address lines.
Routes: ip route and route
| Command | Role |
|---|---|
ip route show (or ip r) | Modern routing table view |
route / route -n | Legacy routing table display |
The routing table answers: “For this destination, which interface and next hop?” The default route (often shown as default or 0.0.0.0/0) points at your gateway/router for destinations not on the local network. Without a working default route (and a reachable gateway), local LAN traffic might work while Internet sites fail.
Connections and sockets: netstat and ss
| Command | Role |
|---|---|---|
| ss | Modern socket statistics (listening ports, connections) |
| netstat | Legacy counterpart; still referenced widely |
Essentials-level use is awareness: these tools list network sockets—for example, which ports are listening or which remote hosts you are connected to. You do not need every flag; know that ss replaces netstat on many systems.
Name resolution: /etc/resolv.conf and /etc/hosts
Humans use names (example.com); IP stacks need addresses. Two classic files matter:
| File | Purpose |
|---|---|
/etc/resolv.conf | Lists DNS resolvers (nameserver IPs) the stub resolver should query |
/etc/hosts | Local static name→address mappings checked without asking DNS |
If /etc/resolv.conf points at unreachable resolvers, browsing by name fails even when ping to a raw IP works. /etc/hosts is useful for small local overrides (lab VMs, blocked names, short aliases). On systems using systemd-resolved or NetworkManager, resolv.conf may be managed automatically—you still need to know what the file is for.
Checking reachability and DNS: ping and host
| Command | Purpose |
|---|---|
ping <target> | Send ICMP echo requests; test basic reachability and round-trip time |
ping -c 4 <target> | Common pattern: send a fixed count then stop (flag availability varies slightly by OS) |
host <name> | Query DNS for a name (and related lookups) |
ping answers “can I reach this IP/host at the IP layer (if ICMP is allowed)?” Firewalls may block ping even when a service is up, so a failed ping is a clue—not absolute proof the host is down. host answers “what address does DNS return for this name?” Related tools (dig, nslookup) exist; Essentials highlights host in the objective set.
A simple connectivity checklist
ip addr show— Do I have an address on the right interface?ip route show— Is there a default gateway?pingthe gateway, then an Internet IP (if allowed).- Check
/etc/resolv.conf, thenhost example.com(or similar). - Remember
/etc/hostsif a single name behaves differently from DNS.
Common exam traps
- Confusing
/etc/hosts(local static map) with/etc/resolv.conf(which DNS servers to ask). - Assuming
ifconfigis always installed; knowip addr showas the modern equivalent. - Thinking a failed
pingalways means “host down”—ICMP may be filtered. - Mixing up routing (
ip route show) with address assignment (ip addr show).
Private lab addresses (for example ranges reserved for local use) still appear in the same command output as public addresses; Essentials cares that you can read the tools, not that you memorize every RFC1918 block.
Putting name resolution and reachability together
Separate layer problems when you practice. If ping 203.0.113.10 works but ping www.example.com fails, suspect DNS: read /etc/resolv.conf, then try host www.example.com. If even the numeric IP fails, check address and route with ip addr show and ip route show, then ping the gateway. If one short name resolves oddly while others are fine, inspect /etc/hosts for a stale static line. Legacy names matter too: an older tutorial may say ifconfig, route, or netstat—map those to ip addr, ip route, and ss so you are not stuck when the modern binary is what your distro ships.
Exam focus
Match tasks to tools: display address → ip addr show/ifconfig; show routes → ip route show/route; resolver config → /etc/resolv.conf; local static names → /etc/hosts; reachability → ping; DNS lookup → host. Know IPv4 vs IPv6 notation and that routers interconnect networks to form paths toward the Internet.
Which file traditionally lists the DNS nameserver addresses your system should query?
On a modern Linux system, which command is the preferred way to display IP addresses assigned to network interfaces?
Which statement correctly describes the relationship among hosts, routers, and the Internet at Essentials level?