Fundamentals 17 min read

Configuring Linux Network, Routing, and IP Fundamentals

This article explains how to configure Linux network settings, describes the contents of key configuration files such as ifcfg, /etc/resolv.conf, and /etc/hosts, and introduces routing concepts, static and dynamic routes, gateways, IP/MAC headers, CIDR, and common virtual networking methods.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Configuring Linux Network, Routing, and IP Fundamentals

From Linux installation and basic commands to security policies and directory structures, this guide focuses on configuring Linux networking.

Since we need to configure the network, let’s first locate the network configuration files and understand what each line means.

Configuring Linux Network

Open the network configuration file (e.g., /etc/sysconfig/network-scripts/ifcfg-eth0 ).

Key parameters include:

BOOTPROTO=static – enables a static IP address.

NAME=eth0 – label matching the ifcfg file.

UUID – unique device identifier generated by the system.

DEVICE – physical device name.

IPADDR0 – IP address (multiple IPs can be set on CentOS 7+).

PREFIX0=24 – subnet mask (24 corresponds to 255.255.255.0).

GATEWAY – default gateway address.

After editing, restart the network (CentOS 7):
service network restart

Local Loopback Configuration

The /etc/hosts file defines the loopback interface:

Device – network device name.

Lines 2‑4 – IP address, subnet mask, network number for lo .

Line 7 – broadcast address.

Line 8 – enable lo at boot.

Line 9 – set lo as the loopback address.

DNS Configuration (/etc/resolv.conf)

The namespace field lists DNS servers used for domain name resolution.

Host‑IP Binding (/etc/hosts)

Each line contains three space‑separated fields: IP address, hostname (domain), and short host name.

Routing

Routing determines how data packets travel through multiple network nodes. Static routes are manually added, while dynamic routes are exchanged automatically between routers.

How to configure routes?

Static routes can be added with the route command:

route [-n|ee]

Common options include:

Destination – network number.

Gateway – next‑hop address.

Flag – route status flags (U, H, R, G, M, etc.).

What Is a Gateway?

A gateway connects a local network to external networks. Devices obtain IP addresses via DHCP, and the gateway address is required for external communication.

IP and MAC Headers

MAC addresses identify devices on the same link, while IP addresses are used for routing across networks. The IP header contains source and destination IPs, and the MAC header contains source and destination MACs.

CIDR and Subnet Masks

CIDR notation (e.g., 10.120.55.73/24) splits a 32‑bit IP address into network and host portions; the subnet mask (255.255.255.0) is applied with an AND operation to obtain the network number.

Private vs. Public IP Addresses

Private IPs are used within internal networks, while public IPs are globally routable and must be obtained from an ISP.

Common Virtual Network Connection Methods

Bridge : Connects a virtual NIC to a physical NIC, allowing the VM to appear as a regular host on the LAN.

NAT : Translates private IPs to a public IP on the host, enabling VMs to access the Internet while keeping internal addresses hidden.

Host‑Only : Provides communication only between the host and VM, without Internet access.

For each method, you can use dynamic (DHCP) or static IP configuration as needed.

Recommended reading:

A single space causing a "disaster"

LinuxRoutingSystem AdministrationIPMACnetwork configuration
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.