Day 7 of #100DaysOfCode – Networking Fundamentals: Switching, Routing, IP Configuration, and DNS
Introduction
On Day 7 of my #100DaysOfCode challenge, I explored the fundamentals of networking. From understanding how data moves across networks using switches and routers, to configuring IP addresses, and diving into DNS (Domain Name System), the day was packed with foundational concepts that form the backbone of any modern network. Let’s break down these key concepts and the commands I learned along the way.
Switching and Routing
Switching and routing are critical in ensuring that data packets reach their intended destination on a network.
Switching: Operates within a local network (LAN) and ensures that data reaches the correct device.
Routing: Works at a broader level, ensuring that data can travel between different networks (WAN), using gateways and routers to direct traffic.
Switches and routers each play a role in managing traffic based on IP addresses and MAC addresses, ensuring that packets are sent efficiently and securely.
Gateways and Default Gateways
Gateway: Acts as an entry/exit point between networks. For instance, traffic between a private home network and the broader internet passes through a gateway device.
Default Gateway: The device that routes traffic from your local network to external networks. Without the correct gateway configuration, your devices can’t communicate with the internet.
Here are some commands related to gateway and IP configuration that I practiced today:
# View the network link status
ip link
# Add an IP address to a specific device (eth0)
ip addr add 192.168.1.10/24 dev eth0
# View current IP configuration
ip addr
# Add a route to a specific network via a gateway
ip route add 192.168.1.0/24 via 192.168.2.1
# Enable IP forwarding (so the machine can act as a router)
cat /proc/sys/net/ipv4/ip_forward
These commands give you direct control over configuring and managing network interfaces on a Linux machine.
DNS and Name Resolution
DNS (Domain Name System) is essentially the phonebook of the internet. It translates domain names (like example.com) into IP addresses, which are used by devices to communicate with each other.
Domain Names: Human-readable names used to access websites (e.g.,
www.google.com).Record Types: In DNS, different record types are used for various purposes, such as A (address), MX (mail exchange), and CNAME (canonical name).
Two essential tools I explored for working with DNS:
nslookup: A tool to query DNS to find the IP address associated with a domain.
nslookup example.comdig: A more advanced DNS lookup tool that provides detailed information about DNS queries.
dig example.com
These tools are invaluable for troubleshooting network issues and understanding how DNS works under the hood.
Conclusion
Understanding networking basics is crucial for anyone working in DevOps or cloud environments. Today’s exploration of switching, routing, IP configuration, and DNS deepened my understanding of how networks function and how to manage them effectively using Linux commands.
Stay tuned for more updates as I continue my #100DaysOfCode journey into the world of networking and cloud computing!