Networking and IP addressing are foundational concepts in Linux and all modern computing. They enable devices to communicate within local networks and across the global internet. An IP address gives each device a unique identifier, allowing data to be routed correctly between source and destination.
What is an IP Address?
An IP address is a unique numerical label assigned to devices (hosts) on a network. It identifies the host and provides the location in the network topology.
Two main versions exist:
1. IPv4: 32-bit addresses often represented as four decimal octets separated by dots, e.g., 192.168.1.10.
2. IPv6: 128-bit addresses represented in hexadecimal, e.g., 2001:0db8:85a3::8a2e:0370:7334, created to address IPv4 exhaustion.
Types of IP Addresses
Networking relies on different IP address types for internal and external communication. The list below outlines these categories and their practical uses.
1. Public IP Addresses: Globally unique identifiers assigned to devices that need to communicate directly over the Internet. They are routable across the global network, allowing systems to be reachable from anywhere in the world.
2. Private IP Addresses: Belong to reserved address ranges such as 10.x.x.x and 192.168.x.x and are used within private or local networks. These addresses are not routable on the public Internet and typically require Network Address Translation (NAT) to access external networks.
3. Loopback Address: Represented as 127.0.0.1 in IPv4 or ::1 in IPv6, refers to the local host itself. It is commonly used for testing network applications and enabling inter-process communication without involving external network interfaces.
IP Address Structure
It divided into Network and Host portions, determined by the subnet mask. The subnet mask defines which part of the IP address is the network address and which part identifies the host.
Example:
For IP 192.168.1.100 with mask 255.255.255.0,
Network: 192.168.1.0
Host: 100
Common Networking Concepts
Networking is built upon foundational concepts that define how systems interact. The following list explains the most important ideas behind network communication.
1. Subnetting: Divides a large network into smaller logical segments to improve performance and security.
2. Default Gateway: The router through which devices send traffic destined for other networks.
3. DNS (Domain Name System): Translates human-readable domain names into IP addresses.
4. MAC Addresses: Unique hardware identifiers of network interfaces, different from IP addresses.
Configuring Networking in Linux
Network configuration in Linux is primarily handled through the ip command suite. The following examples show essential operations for interface and routing management.
1. View IP addresses and interfaces:
ip addr show2. Assign static IP address:
sudo ip addr add 192.168.1.100/24 dev eth03. Remove IP address:
sudo ip addr del 192.168.1.100/24 dev eth04. Bring network interface up or down:
sudo ip link set eth0 up
sudo ip link set eth0 down5. View routing table:
ip route show6. Add routing entry:
sudo ip route add default via 192.168.1.1Troubleshooting Network Connectivity
1. Ping: Test reachability of a host.
ping google.com
ping -c 4 192.168.1.12. Traceroute: Trace the network path packets take to a destination.
traceroute google.com3. Netstat / ss: Display active connections and listening services.
We have a sales campaign on our promoted courses and products. You can purchase 1 products at a discounted price up to 15% discount.