Configure IPv4 and IPv6 Addresses

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to configure IPv4 and IPv6 addresses on a Linux system. You will be tasked with setting up network interfaces with specific IP addresses, subnet masks, and default gateways. This challenge will help you develop the skills required to manage basic networking in a Linux environment.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389437{{"`Configure IPv4 and IPv6 Addresses`"}} end

Configure IPv4 Addresses

Tasks

  • Configure the eth0 interface with the IPv4 address 192.168.1.100/24.
  • Set the default gateway for the eth0 interface to 192.168.1.1.

Requirements

  • All network configuration must be done in the ~/project directory.
  • The IPv4 address and default gateway must be set using the appropriate Linux networking commands.
  • The network configuration must persist after a system reboot.

Example

After completing this step, the output of the ip addr show command should include the following:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:f4:25:e4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fef4:25e4/64 scope link
       valid_lft forever preferred_lft forever

And the output of the ip route show command should include the following:

default via 192.168.1.1 dev eth0 proto static metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100 metric 100

Configure IPv6 Addresses

Tasks

  • Configure the eth0 interface with the IPv6 address 2001:db8:1234:5678::100/64.
  • Set the IPv6 default gateway for the eth0 interface to 2001:db8:1234:5678::1.

Requirements

  • All network configuration must be done in the ~/project directory.
  • The IPv6 address and default gateway must be set using the appropriate Linux networking commands.
  • The network configuration must persist after a system reboot.

Example

After completing this step, the output of the ip addr show command should include the following:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:f4:25:e4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2001:db8:1234:5678::100/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fef4:25e4/64 scope link
       valid_lft forever preferred_lft forever

And the output of the ip -6 route show command should include the following:

default via 2001:db8:1234:5678::1 dev eth0 proto static metric 100
2001:db8:1234:5678::/64 dev eth0 proto kernel metric 100

Summary

In this challenge, you learned how to configure IPv4 and IPv6 addresses on a Linux system. You practiced setting up network interfaces with specific IP addresses, subnet masks, and default gateways. This challenge helped you develop the skills required to manage basic networking in a Linux environment, which is an important skill for the RHCSA exam.

To initialize the challenge environment, you can use the following setup.sh script:

#!/bin/bash

## Create the project directory
mkdir -p ~/project

## Set the default user to labex
echo "export PS1='\u@\h:\w\$ '" >> /home/labex/.bashrc
chown -R labex:labex ~/project

This script creates the ~/project directory and sets the default user to labex with the appropriate permissions. You can run this script as the labex user to set up the challenge environment.

Other Linux Tutorials you may like