4.2.11 Lab: Configure Ip Addresses On Linux
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:
- Network Isolation – Use a host‑only or internal network to avoid interfering with production systems.
- Access Method – Connect via SSH or directly through a console to issue commands.
- Backup – Record current network settings with
ip addr showornmcli device showin 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/24represents the IP address and prefix length.default via 192.168.10.1sets 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) orsudo 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.
Latest Posts
Latest Posts
-
What Type Of Current Is Illustrated In The Diagram Below
Mar 21, 2026
-
Pal Cadaver Endocrine System Lab Practical Question 1
Mar 21, 2026
-
Chapter 4 Personal Qualities Of A Healthcare Worker Crossword Answers
Mar 21, 2026
-
All Things Algebra Unit 3 Homework 2
Mar 21, 2026
-
Less Calories Than The Leading Brand
Mar 21, 2026