Linux Network Configuration: IP Address and Subnet Mask Setup

Configuring IP addresses and subnet masks on Linux servers is fundamental for network communication. An IP address (32-bit binary, dotted decimal format) identifies a device, while a subnet mask (32-bit, with 1s indicating network portions and 0s indicating host portions) distinguishes between network and host segments. To view current configurations, use `ip addr` (recommended for modern systems) or `ifconfig` (traditional, requiring `net-tools` installation on some systems). Temporary settings can be applied with `ip addr add <IP>/<mask_prefix> dev <interface>` or `ifconfig <interface> <IP> netmask <mask>`, which only persist during the current session. For permanent configuration, distributions vary: CentOS/RHEL 7+ requires editing `/etc/sysconfig/network-scripts/ifcfg-<interface>` and setting `BOOTPROTO=static` with IP/subnet parameters. Ubuntu 18.04+ uses `netplan`, editing `/etc/netplan/*.yaml` to disable DHCP and applying changes with `netplan apply`. Verification is done via `ip addr` to confirm the assigned IP, or by pinging local devices, same-subnet hosts, and the gateway. Key considerations: ensure unique IPs, correct subnet mask alignment, verify interface names (via `ip addr`), and use root/administrator privileges.

Read More