Setting IP Addresses on Linux Servers: A Beginner's Guide

The IP address of a Linux server is the foundation for device communication (like a "house number"). IPv4 consists of 4 groups of numbers ranging from 0 to 255 (e.g., 192.168.1.100) and is used to locate devices. IP configuration supports two methods: dynamic (via DHCP, automatic acquisition for temporary testing) and static (manual specification for production environments). To view the IP address: Use `ip addr` (recommended) or `ifconfig` (requires installation on some systems). Identify the network interface name (e.g., eth0/ens33) and the assigned IP address. For static configuration (CentOS example): Confirm the network interface name, modify `/etc/sysconfig/network-scripts/ifcfg-ens33`, set `BOOTPROTO=static`, specify `IPADDR`, `NETMASK`, `GATEWAY`, and `DNS`, then restart the network service with `systemctl restart network` and verify the IP. For dynamic configuration: Change the configuration file's `BOOTPROTO=dhcp`, restart the network, and verify. For Ubuntu, use Netplan; configuration files are located in `/etc/netplan/`, apply changes with `netplan apply`. Common issues: IP conflicts, incorrect gateway/DNS settings. Troubleshoot using tools like `ping`.

Read More