Linux Tutorial / Understand IP Addresses, DNS, and Ports
An IP address identifies a network endpoint, DNS looks up records associated with a domain name, and a port identifies a communication endpoint within a host. Reaching a website requires working name resolution, a route to the destination, and a service that accepts the connection.
After separating addresses, names, and ports, use network troubleshooting to test failures at each layer.
System configuration exercises use a conventional Ubuntu 26.04 LTS or Rocky Linux 9 VM as the reference environment. Containers, WSL, and other releases can differ in service and package configuration. Prepare console recovery and record your versions using the virtual machine setup lesson.
Separate addresses, names, and ports in one connection
Consider https://example.com/. The browser and operating system obtain address information according to their caches and resolver configuration, choose a route, and contact the server. HTTPS normally uses port 443; the actual exchange can involve TCP and TLS or a transport such as QUIC. A successful DNS lookup alone does not prove that the website is reachable.
| Item | Purpose | Example |
|---|---|---|
| IP address | Address used to send packets | 192.0.2.10 or 2001:db8::10 |
| DNS | Look up records associated with names | A, AAAA, and MX records |
| Port and protocol | Distinguish communication endpoints | TCP 443 and UDP 443 are distinct |
The ranges 192.0.2.0/24 and 2001:db8::/32 are documentation examples, not reachable lab servers. TCP and UDP have separate port spaces, so a firewall rule must identify the protocol as well as the number.
Understand IPv4, IPv6, and private addresses
IPv4 uses 32-bit addresses commonly written as dotted decimal; IPv6 uses 128-bit addresses commonly written in hexadecimal groups separated by colons. An interface can have several addresses and support both families. 127.0.0.1 and ::1 are loopback addresses. A service listening only on loopback is not directly available from another computer.
IPv4 private ranges are 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. They can be reused in private networks and are not globally routed public addresses. Outbound access may use network address translation (NAT). Do not assume IPv6 is merely IPv4 without NAT, or that an IPv4 firewall rule automatically protects IPv6.
Read prefixes and the default route
In 192.168.10.20/24, /24 is Classless Inter-Domain Routing (CIDR) notation for a 24-bit network prefix. Routing chooses a matching destination prefix, generally favoring a more specific one. A default via ... entry provides a next hop when no more specific route applies. A gateway and a DNS server may share an address, but they perform different jobs.
ip -brief address
ip route
ip -6 route
getent ahosts example.com
ip belongs to the iproute2 project, but distribution package names differ: iproute2 on Ubuntu 26.04 and iproute on Rocky Linux 9. These commands show interface addresses, routes, and system name-service resolution. getent can use /etc/hosts and other configured sources as well as DNS; addresses and interface names vary by machine.
Check installed versions with dpkg-query -W iproute2 on Ubuntu or rpm -q iproute on Rocky. The official Rocky Linux 9 BaseOS repository also shows the RPM package name.
Test name resolution separately from the service
An A record contains an IPv4 address and an AAAA record contains an IPv6 address. A name may return multiple addresses, and caching can affect what you see. On a system using systemd-resolved, the first command below displays resolver configuration. If it is unavailable, inspect the NetworkManager or resolver configuration used by that distribution.
resolvectl status
ss -lnt
curl -I --connect-timeout 5 --max-time 15 https://example.com/
ss -lnt lists local listening TCP sockets, not ports on the remote website. curl requests remote HTTPS response headers. Install it with sudo apt install curl on Ubuntu or sudo dnf install curl on Rocky Linux if needed. Proxy settings, certificate trust, and network policy can all affect the result.
Choose the next check from the evidence
- If the interface has no address, inspect the VM network connection and interface configuration.
- If an address exists but no usable route exists, investigate routing and the gateway.
- If only name resolution fails, inspect resolver and name-service configuration.
- If resolution and routing work, distinguish listening ports, filtering, TLS errors, and application errors.
The commands in this lesson do not change configuration. Avoid overwriting resolver files or disabling a firewall as a first response. Identify the failing layer before making a targeted change.




