4.2.11 Lab: Configure Ip Addresses On Linux

Author playboxdownload
3 min read

In this lab guide you will learn howto configure IP addresses on Linux as part of the 4.2.11 lab, covering static and DHCP methods, troubleshooting tips, and persistent configuration steps. The tutorial walks you through verifying existing network settings, assigning a permanent IP address, setting subnet mask and gateway, testing connectivity, and making the changes survive reboots. By following the structured steps and understanding the underlying networking concepts, learners can confidently manage network interfaces on any Linux distribution.

## Overview of the Lab

The 4.2.11 lab focuses on practical Linux network administration. Participants will work with command‑line tools such as ip, nmcli, and netplan to configure IP addresses on Linux systems. The lab is designed for beginners and intermediate users who need a hands‑on experience with both temporary and permanent network configuration.

Prerequisites

  • A Linux machine (physical or virtual) with root or sudo privileges.
  • Basic familiarity with the terminal.
  • Access to a network interface (wired or wireless).
  • Understanding of IP addressing fundamentals (IP address, subnet mask, default gateway).

## Setting Up the Lab Environment

Before diving into the configuration, ensure the lab environment meets the following criteria:

  1. Network Isolation – Use a host‑only or internal network to avoid interfering with production systems.
  2. Access Method – Connect via SSH or directly through a console to issue commands.
  3. Backup – Record current network settings with ip addr show or nmcli device show in case a rollback is needed.

## Step‑by‑Step Configuration

1. Verify Current Network Settings

Run the following command to list all interfaces and their assigned addresses:

ip addr show

or, for a more readable output:

nmcli device show

Note the interface name (e.g., eth0, ens33, wlan0) and any existing IP configuration.

2. Assign a Static IP Address

a. Using ip Command (temporary)

sudo ip addr add 192.168.10.50/24 dev eth0
sudo ip route add default via 192.168.10.1
  • 192.168.10.50/24 represents the IP address and prefix length.
  • default via 192.168.10.1 sets the default gateway.

b. Using nmcli (persistent)

sudo nmcli con mod eth0 ip4 192.168.10.50/24 gw4 192.168.10.1
sudo nmcli con up eth0

3. Configure Subnet Mask and Gateway

The subnet mask is expressed as a CIDR prefix. For a /24 network, the mask is 255.255.255.0. When using nmcli, the prefix length (/24) directly defines the mask.

sudo nmcli con mod eth0 ip4 192.168.10.50/24 gw4 192.168.10.1

If you prefer the older ifconfig style, you can set the mask explicitly:

sudo ifconfig eth0 netmask 255.255.255.0 up

4. Test Connectivity

Verify that the new settings work by pinging the gateway and an external host:

ping -c 4 192.168.10.1
ping -c 4 8.8.8.8

Successful replies confirm that the IP address, subnet mask, and default gateway are correctly applied.

5. Make Settings Persistent Across Reboots

a. With Netplan (Ubuntu/Debian)

Create or edit /etc/netplan/01-netcfg.yaml:

network:
  version: 2
  renderer: networkd  ethernets:
    eth0:
      dhcp4: no
      addresses: [192.168.10.50/24]
      gateway4: 192.168.10.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

Apply the configuration:

sudo netplan apply

b. With NetworkManager (CentOS, Fedora)

Edit the connection profile:

sudo nmcli con mod eth0 ip4 192.168.10.50/24 gw4 192.1

1
sudo nmcli con up eth0

6. Troubleshooting Common Issues

  • No Connectivity After Reboot: Ensure the configuration file is correctly formatted and applied. Check sudo netplan try (Ubuntu) or sudo nmcli con show (CentOS) for errors.
  • IP Conflict: Verify the chosen IP is not already in use with nmap -sn 192.168.10.0/24.
  • Gateway Unreachable: Confirm the gateway IP is correct and that the network interface is physically connected.

## Conclusion

Assigning a static IP address, subnet mask, and default gateway in Linux is a straightforward process once you understand the tools available—ip, nmcli, and Netplan. By following these steps, you can ensure consistent network connectivity for servers, virtual machines, or any device requiring a fixed address. Always test your configuration and keep a backup of the original settings to quickly recover from misconfigurations. With practice, managing network settings becomes second nature, empowering you to maintain robust and reliable Linux environments.

More to Read

Latest Posts

You Might Like

Related Posts

Thank you for reading about 4.2.11 Lab: Configure Ip Addresses On Linux. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home