Skip to main content
In this lesson we refresh the networking fundamentals you’ll need when working with Linux hosts and Kubernetes: switching, routing, gateways, CNIs, plus a short introduction to DNS (CoreDNS) and Linux network namespaces. This is a hands-on, sysadmin- and developer-oriented guide — lots of commands, examples, and troubleshooting pointers to help you inspect and debug networking on hosts and in container environments.
A presentation slide titled "Networking Prerequisites" listing topics such as switching and routing (switching, routing, default gateway), DNS (DNS configurations on Linux, CoreDNS), network namespaces, and Docker networking. The text is centered inside a rounded, shaded box on a dark blue background.
What is a network? At its simplest, a network connects two or more hosts so they can exchange packets. Consider two machines, A and B (physical machines, VMs, or laptops). To let A reach B you typically plug both into the same switch and give each host a network interface and an IP address on the same subnet. On Linux:
  • Inspect interfaces with ip link.
  • Assign IP addresses with ip addr.
Example — bring up two hosts on a single subnet 192.168.1.0/24 and verify connectivity:
Switches and subnets A switch forwards Ethernet frames within a single Layer‑2 broadcast domain — typically one IP subnet. If you place hosts A and B on 192.168.1.0/24 they can reach each other directly via the switch. If hosts C and D are on another subnet (for example 192.168.2.0/24), a router is required to forward packets between the two subnets. A router has interfaces in both subnets (for example 192.168.1.1 and 192.168.2.1). Hosts use a gateway (a route) to send packets destined for other subnets to that router.
A network diagram titled "Gateway" showing two subnets (192.168.1.0 and 192.168.2.0) with hosts A/B on the first and C/D on the second. Each host connects via eth0 to its subnet cloud and both subnets tie into a central gateway/router with IPs 192.168.1.1 and 192.168.2.1.
Routing — view and configure The kernel routing table determines where packets are sent. View it with ip route or route -n. Initially you may see no explicit route for an off-subnet network:
To allow a host on 192.168.1.0/24 to reach 192.168.2.0/24 via a router at 192.168.1.1:
Verify the new route:
Default route (internet access) To reach arbitrary Internet destinations you add a default route that points to the router connected to the Internet. This is a 0.0.0.0/0 route:
Example route -n output with a default route:
Multiple routers If you have multiple routers (for example one for internal networks and one for the Internet), add specific routes for the internal networks and a default route for everything else:
Troubleshooting internet connectivity often begins by checking your routing table and confirming a valid default gateway. Using a Linux host as a router Suppose you have three hosts:
  • A: 192.168.1.5 (on 192.168.1.0/24)
  • B: 192.168.1.6 and 192.168.2.6 (B has two interfaces: eth0 on 192.168.1.0 and eth1 on 192.168.2.0)
  • C: 192.168.2.5 (on 192.168.2.0/24)
To enable A ↔ C communication, configure routes: On host A (route to 192.168.2.0 via B on 192.168.1.6):
On host C (route to 192.168.1.0 via B on 192.168.2.6):
If you attempt to ping before adding routes you will likely see:
After adding routes, packets reach B, but Linux will not forward packets between interfaces by default. Kernel packet forwarding is controlled by net.ipv4.ip_forward. Enable forwarding temporarily:
Persist forwarding across reboots by adding to /etc/sysctl.conf:
Then reload:
Remember: changes made with ip addr and ip route are not persistent across reboots. To make IPs and routes persistent, update your distribution’s network configuration (for Debian/Ubuntu, /etc/network/interfaces or Netplan files; for RHEL/CentOS, use NetworkManager or /etc/sysconfig/network-scripts). For IP forwarding, update /etc/sysctl.conf as shown above.
Quick reference — useful commands DNS and CoreDNS (brief introduction) On Linux, DNS resolution is typically configured via /etc/resolv.conf. System resolvers (systemd-resolved, NetworkManager) may manage this file — inspect the active configuration to understand where DNS queries are sent. In Kubernetes, CoreDNS is the default cluster DNS service. It provides DNS resolution for service discovery inside the cluster (pods resolving my-service.default.svc.cluster.local, etc.). When troubleshooting DNS in Kubernetes:
  • Check the CoreDNS pods (kubectl get pods -n kube-system).
  • Inspect CoreDNS logs (kubectl logs -n kube-system <coredns-pod>).
  • Verify pod /etc/resolv.conf and that DNS policies are correct for the pod.
Network namespaces (short overview) Linux network namespaces isolate network resources — each namespace has its own interfaces, routing table, and firewall rules. Containers use network namespaces to provide isolation between workloads. Useful debugging commands:
  • ip netns — list network namespaces.
  • ip netns exec <ns> <command> — run a command inside a namespace.
  • ip link, ip addr, ip route — run inside a namespace to inspect interfaces, addresses, and routes for that namespace.
Further reading and references That’s it for this lesson — these basics are practical building blocks you’ll rely on when working with container networking, CNIs, and Kubernetes networking concepts.

Watch Video