0% found this document useful (0 votes)
232 views108 pages

HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
232 views108 pages

HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 108

This page is not presented

to the public

Revision Record
Course Code Product Product Version Course Issue

FusionCompute V8.1.1 V5.0

Developed Course Type Update


Date Approved By
By (New/Update) Description

Jing Moran Ma Sisheng


2022.06.28 New New
wx454322 00490950

1
Huawei Cloud Certification Training

HCIA-Cloud Computing

Lab Guide (Basic Exercises)


ISSUE: 5.0

HUAWEI TECHNOLOGIES CO., LTD.

2
Copyright © Huawei Technologies Co., Ltd. 2022. All rights reserved.
No part of this document may be reproduced or transmitted in any form or by any
means without prior written consent of Huawei Technologies Co., Ltd.

Trademarks and Permissions

and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of
their respective holders.

Notice
The purchased products, services and features are stipulated by the contract made
between Huawei and the customer. All or part of the products, services and features
described in this document may not be within the purchase scope or the usage scope.
Unless otherwise specified in the contract, all statements, information, and
recommendations in this document are provided "AS IS" without warranties,
guarantees or representations of any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has
been made in the preparation of this document to ensure accuracy of the contents, but
all statements, information, and recommendations in this document do not constitute
a warranty of any kind, express or implied.

Huawei Technologies Co., Ltd.


Address: Huawei Industrial Base Bantian, Longgang Shenzhen 518129
People's Republic of China
Website: https://e.huawei.com

Huawei Proprietary and Confidential


Copyright © Huawei Technologies Co., Ltd
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 1

Huawei Certification System


The Huawei certification system is a platform for shared growth, part of a thriving
partner ecosystem. There are two types of certification: one for ICT architectures and
applications, and one for cloud services and platforms. There are three levels of
certification available:
Huawei Certified ICT Associate (HCIA)
Huawei Certified ICT Professional (HCIP)
Huawei Certified ICT Expert (HCIE)
Huawei certification courses cover the entire ICT domain, with a focus on how today's
architecture generates cloud-pipe-device synergy. The courses present the latest
developments of all essential ICT aspects to foster a thriving ICT talent ecosystem for
the digital age.
HCIA-Cloud Computing V5.0 is intended for beginners. Focusing on the virtualization
technologies and FusionAccess of Huawei, this course aims to help you learn the basics
of cloud computing and resource pooling, and to cultivate cloud computing engineers
that are capable of using FusionCompute for virtualization and managing FusionAccess.
The HCIA-Cloud Computing V5.0 certification includes the following courses: basics of
cloud computing (server, storage, network, and OS), overview of FusionCompute,
routine management and troubleshooting of virtualization resource pools, overview of
FusionAccess and related components, as well as their installation, deployment, service
management, and troubleshooting.
Passing the HCIA-Cloud Computing V5.0 certification means that you are capable of
designing, managing, and maintaining FusionCompute and FusionAccess.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 2
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 3

About This Document

Overview
This course is specific to HCIA-Cloud Computing certification. It is intended for those who
are preparing for HCIA-Cloud Computing certification or want to understand basic
configurations of storage, networks, Linux, and KVM virtualization.

About the Exercises


This document consists of four exercises:
 Exercise 1: Basic storage configuration. Simulate a storage service scenario. Use the
Huawei OceanStor eStor storage emulator to create volumes and map the volumes
to service hosts to mount LUNs. This exercise helps trainees master the basic
configuration logic of SAN storage.
 Exercise 2: Basic network configuration, including the switch view introduction, basic
switch configuration, as well as VLAN and routing principle implementation. This
exercise helps trainees master the basic usage of switches and basic principles of
Layer 2 and Layer 3 network communication from multiple perspectives.
 Exercise 3: Linux basics, including the bash commands, file viewing commands, basic
operations on the text editor, and Linux service management. This exercise helps
trainees master the basic usage of the Linux operating system.
 Exercise 4: KVM virtualization, including creating VMs using KVM virtualization,
managing networks, configuring bridging, and configuring NAT networks. This
exercise helps trainees deepen their understanding of KVM virtualization principles
and master the basic principles of communication between VMs and external
networks.

Account List
Product documentation: FusionCompute OceanStor eStor Installation Guide.

Table 1-1 Account list

Item Username Password

For details, see "Deploying eStor"


OceanStor eStor admin in FusionCompute OceanStor
eStor Installation Guide.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 4

Lab Environment Setup


Checking Devices
Make sure that all required software tools are ready before the exercises. The following
table lists the devices.

Table 1-2 Software and tools

Software Used For Description

FusionCompute_OceanStor_
Storage configuration
eStor_V1R1C00T32_single_c One for each group
exercise
ontroller.zip

Storage configuration
FusionCompute 8.1.1 Shared by all groups
exercise

Network configuration
eNSP V100R003C00SPC100 One for each person
exercise

Linux/KVM virtualization
VirtualBox 6.1.34 One for each person
exercise

openEuler-22.03-LTS- Linux/KVM virtualization


/
x86_64-dvd exercise
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 5

Contents

About This Document ............................................................................................................... 3


Overview ................................................................................................................................................................................... 3
About the Exercises ................................................................................................................................................................ 3
Account List .............................................................................................................................................................................. 3
Lab Environment Setup......................................................................................................................................................... 4
1 Storage Exercise...................................................................................................................... 7
1.1 Overview ............................................................................................................................................................................ 7
1.1.1 About This Exercise ...................................................................................................................................................... 7
1.1.2 Objectives ....................................................................................................................................................................... 7
1.1.3 IP Address Planning ..................................................................................................................................................... 7
1.1.4 Guideline ......................................................................................................................................................................... 7
1.2 Configuration Procedure ................................................................................................................................................ 8
1.2.1 Deploying OceanStor eStor ....................................................................................................................................... 8
1.2.2 Initializing OceanStor eStor ..................................................................................................................................... 11
1.2.3 Deploying a Service Host ......................................................................................................................................... 14
1.2.4 Creating a Host and a Host Group ........................................................................................................................ 17
1.2.5 Creating a LUN, LUN Group, and Mapping View .............................................................................................. 21
1.2.6 Lab Verification ........................................................................................................................................................... 22
1.3 Quiz ................................................................................................................................................................................... 23
2 Network Configuration Exercise .......................................................................................24
2.1 Introduction to the Switch View ................................................................................................................................ 24
2.1.1 Overview ....................................................................................................................................................................... 24
2.1.2 Configuration Procedure .......................................................................................................................................... 24
2.2 Basic Switch Configuration ......................................................................................................................................... 27
2.2.1 Overview ....................................................................................................................................................................... 27
2.2.2 Configuration Procedure .......................................................................................................................................... 28
2.3 VLAN Implementation Exercise ................................................................................................................................. 32
2.3.1 Overview ....................................................................................................................................................................... 32
2.3.2 Configuration Procedure .......................................................................................................................................... 33
2.4 Routing Implementation Exercise ............................................................................................................................. 39
2.4.1 Overview ....................................................................................................................................................................... 39
2.4.2 Configuration Procedure .......................................................................................................................................... 40
2.5 Quiz ................................................................................................................................................................................... 46
3 Linux Exercise ........................................................................................................................47
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 6

3.1 Overview .......................................................................................................................................................................... 47


3.1.1 About This Exercise .................................................................................................................................................... 47
3.1.2 Objectives ..................................................................................................................................................................... 47
3.2 Preparations .................................................................................................................................................................... 47
3.2.1 Creating a VM ............................................................................................................................................................. 47
3.2.2 Installing an OS on the VM ..................................................................................................................................... 50
3.3 Useful Commands ......................................................................................................................................................... 56
3.3.1 help................................................................................................................................................................................. 56
3.3.2 Other Common Commands .................................................................................................................................... 57
3.4 bash Commands ............................................................................................................................................................ 58
3.4.1 Power Supply Control and User Switching .......................................................................................................... 58
3.4.2 Basic Directory and File Operations ...................................................................................................................... 58
3.5 File Viewing Commands .............................................................................................................................................. 61
3.5.1 Viewing Files ................................................................................................................................................................ 61
3.5.2 (Optional) Searching for Files................................................................................................................................. 64
3.6 Basic Operations on the Vim Text Editor ................................................................................................................ 65
3.6.1 Normal Mode of Vim ................................................................................................................................................ 65
3.6.2 Insert Mode of Vim .................................................................................................................................................... 69
3.6.3 Command Line Mode of Vim .................................................................................................................................. 72
3.7 openEuler System and User Management ............................................................................................................. 74
3.7.1 Network Management.............................................................................................................................................. 74
3.7.2 Service Management ................................................................................................................................................. 78
3.7.3 User Management ..................................................................................................................................................... 80
3.8 Quiz ................................................................................................................................................................................... 81
4 KVM Installation and Resources Provisioning ...............................................................82
4.1 Overview .......................................................................................................................................................................... 82
4.1.1 About This Exercise .................................................................................................................................................... 82
4.1.2 Objectives ..................................................................................................................................................................... 82
4.1.3 Lab Networking .......................................................................................................................................................... 82
4.1.4 Exercise Planning ........................................................................................................................................................ 84
4.2 Exercise Configuration .................................................................................................................................................. 84
4.2.1 Guideline ....................................................................................................................................................................... 84
4.2.2 Procedure...................................................................................................................................................................... 85
4.3 Quiz ................................................................................................................................................................................. 105
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 7

1 Storage Exercise

1.1 Overview
1.1.1 About This Exercise
This exercise describes how to create and map Huawei SAN storage resources to help
trainees deepen their understanding of Huawei SAN storage concepts and service
processes.

1.1.2 Objectives
 Understand the concepts of disk domains and storage pools of Huawei storage
devices.
 Be familiar with the concepts and configurations of Huawei storage devices, such as
hosts, host groups, LUNs, LUN groups, and mapping views.
 Understand the process and method of configuring Huawei SAN storage services.

1.1.3 IP Address Planning


Table 1-1 IP address planning for the exercise

NE Interface IP Address

Service host Host interface 192.168.32.41/24

Management interface 192.168.32.40/24


OceanStor eStor
Service interface 192.168.32.42/24

1.1.4 Guideline
1. Deploy and initialize OceanStor eStor.
2. Deploy service hosts.
3. Configure hosts and host groups.
4. Configure LUNs and LUN groups.
5. Create a mapping view and log in to the host to verify mounting.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 8

1.2 Configuration Procedure


1.2.1 Deploying OceanStor eStor
Step 1 Log in to FusionCompute using the provided login information. Choose Resource
Pools > Create VM > Deploy VM Using Template.

Figure 1-1 Selecting a creation mode

Step 2 Set the VM name, select the estor template created by the trainer, and click Next.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 9

Figure 1-2 Basic settings

Step 3 Retain the default VM configuration and click Next.

Figure 1-3 VM configuration


Step 4 Deselect Generate Initial Password and click Next.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 10

Figure 1-4 Selecting VM specifications

Step 5 Select Start VM immediately after creation and click OK.

Figure 1-5 Confirming information and creating a VM

Step 6 Log in to the estor VM and configure basic information.


 Select the estor VM and click Log In Using VNC on the Summary page.

Figure 1-6 Summary page


 Enter the IP address, subnet mask, and gateway of the controller in sequence. Enter
the last two digits of the product SN, for example, 01, and enter yes.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 11

Figure 1-7 Initial configuration of OceanStor eStor


 After the configuration is complete, wait 5 to 8 minutes for OceanStor eStor to start.

1.2.2 Initializing OceanStor eStor


Step 1 Enter https://X.X.X.X:8088 (replace X.X.X.X with the controller address) to open the
OceanStor eStor login page. Enter the user name and password to log in.

#For details about the user name and password, see the Account List.

Figure 1-8 Logging in to OceanStor eStor


 Enter the user name and password, change the password as prompted, log in to the
device, and perform initial configuration.

Step 2 Perform initial configuration of OceanStor eStor.


 Configure basic information.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 12

Figure 1-9 Initial configuration of OceanStor eStor


 On the License Management page, click Import License if you have not imported a
license before. Otherwise, click Update License.

Figure 1-10 Updating a license


 On the page that is displayed, click ... next to License File, select the local license file
prepared by the trainer, and click Upload.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 13

Figure 1-11 Updating a license


 Click Next.

Figure 1-12 License management


 Create a storage pool and set the number of disks and RAID policy (retain the
default settings in this example). Then click Next.

Figure 1-13 Storage pool configuration


 Retain the default settings on the Provision page and click Finish.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 14

Figure 1-14 Resource provisioning


 Configure an IP address for the OceanStor eStor service interface.
On the System page, choose Hardware > Ports. Click the corresponding Ethernet port
and configure the IP address according to the trainer's IP address plan. In this example,
the IP address of the service interface is 192.168.32.42/24.

Figure 1-15 System hardware overview

1.2.3 Deploying a Service Host


Step 1 Create a service host.
 Log in to FusionCompute, click Create VM, and select Import Template. Select the
CentOS 7.6 template file (prepared by the trainer) on the jump server and click Next.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 15

Figure 1-16 Creating a VM using a template


 On the Basic Information page, enter the name and select the compute resource.

Figure 1-17 Basic information


 Ensure that the port group of the VM is the same as that of the eStor VM. For the
configuration of other steps, see the eStor VM creation process. Click OK.

Step 2 Configure the IP address and iSCSI information of the service host.
 Log in to the VM using VNC and configure the IP address of the service host based
on the IP address plan.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 16

Figure 1-18 Configuration of the VM IP address


 After the configuration is complete, restart the network service and check the port IP
address again.

Figure 1-19 Restarting the network service


 Test the connectivity with the OceanStor eStor management or service interface.

Figure 1-20 Testing connectivity with the management interface


 Change the iSCSI initiator name and connect to the storage device.
# Run the following command to change the iSCSI initiator name:

[root@localhost ~]# vi /etc/iscsi/initiatorname.iscsi


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 17

Figure 1-21 Changing the iSCSI initiator name


# Run the following commands to check the initiator name and restart the service:

[root@localhost iscsi]# cat initiatorname.iscsi


[root@localhost iscsi]# systemctl restart iscsi

Figure 1-22 Modifying the iSCSI initiator and restarting the service
# Run the following commands to connect to the storage device:

[root@localhost iscsi]# iscsiadm –m discovery –t st –p 192.168.32.42


[root@localhost iscsi]# iscsiadm –m node –l

Figure 1-23 Connecting to the storage device

1.2.4 Creating a Host and a Host Group


Step 1 Enter https://X.X.X.X:8088 (replace X.X.X.X with the controller address) to open the
OceanStor eStor login page. Enter the user name and password to log in.

Step 2 In the service list, select Host Groups, click Hosts on the right, and choose Create.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 18

Figure 1-24 Creating a host


Step 3 Set the host name to test, set the initiator type to iSCSI, select the configured iSCSI
initiator name, and click OK.
 If there is no initiator, ask the trainer to configure one.

Figure 1-25 Add an iSCSI initiator.


Step 4 In the displayed dialog box, select I have read and understand the consequences
associated with performing this operation and click OK.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 19

Figure 1-26 Confirming initiator adding and creating a host

Step 5 In the Execution Result dialog box that is displayed, click Close.

Figure 1-27
Step 6 In the service list, select Host Groups, click Host Groups on the right, and choose
Create.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 20

Figure 1-28 Creating a host group


Step 7 Set the host group name to HostGroup001, select the created host test, and click
OK.

Figure 1-29 Adding a host


Step 8 In the Execution Result dialog box that is displayed, click Close.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 21

Figure 1-30 Execution result

1.2.5 Creating a LUN, LUN Group, and Mapping View


Step 1 In the service list, select LUN Groups, click LUN Groups on the right, and choose
Create.

Figure 1-31 Creating a LUN group


Step 2 Set parameters according to the following figure and click OK to create a LUN, LUN
group, and mapping.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 22

Figure 1-32 Creating a LUN and a LUN group and mapping the LUN to a
host group

1.2.6 Lab Verification


Step 1 Log in to the service host using VNC and run the following commands to rescan for
and view disks:

[root@localhost ~]# iscsiadm –m session –R


[root@localhost ~]# fdisk –l

Figure 1-33 Viewing the mounted disk


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 23

1.3 Quiz
After a host uses an iSCSI initiator to connect to a storage device, if the iSCSI initiator
name changes, will the initiator name be updated on the storage device? If the host
initiator name will not be updated, what should I do?
Answer:
The initiator name will not be updated on the storage device. You need to remove the
iSCSI connection from the host, restart the iSCSI service, and reconnect the host to the
storage device.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 24

2 Network Configuration Exercise

2.1 Introduction to the Switch View


2.1.1 Overview
2.1.1.1 About This Exercise
This exercise describes the basic switch operation views.

2.1.1.2 Objectives
 Understand the basic operations on the eNSP simulator.
 Understand the basic operation views of Huawei switches.

2.1.1.3 Guideline
1. Start a switch on eNSP.
2. Enter the user view.
3. Enter the system view.
4. Enter the interface view.
5. Exit the interface view and system view.

2.1.2 Configuration Procedure


2.1.2.1 Starting a Switch
Step 1 Run the eNSP software, click the switch icon, and drag it to the topology on the
right.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 25

Figure 2-1 Clicking the switch icon

Step 2 Right-click the switch, choose Start, and wait for 2 to 5 minutes.

Figure 2-2 Starting a switch

2.1.2.2 Entering the User View


Step 1 Double-click the switch to enter the CLI. <> indicates the user view.

Figure 2-3 User view


Step 2 In the user view, you can run display commands to query information or
configuration. Run the following commands:

<Huawei>display interface brief


<Huawei>display version
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 26

Figure 2-4 Viewing the interface and version information

2.1.2.3 Entering the System View


Step 1 Run the following command to enter the system view of the switch:

<Huawei>system-view

Figure 2-5 System view


Step 2 Run the following command in the system view to change the system name:

[Huawei]sysname SW1

Figure 2-6 Changing the system name

2.1.2.4 Entering the Interface View


In the interface view, you can configure information such as the link type (Layer 2) and
IP address (Layer 3) for the interface.

Step 1 Check brief information about interfaces in the system view.

[SW1]display interface brief


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 27

Figure 2-7 Checking interface information


Step 2 Run the following command to enter the GigabitEthernet0/0/1 interface view:

[SW1]interface GigabitEthernet 0/0/1


[SW1-GigabitEthernet0/0/1]

Figure 2-8 Interface view

2.1.2.5 Exiting the Interface View and System View


Step 1 Run the following command to exit the GigabitEthernet0/0/1 interface view:

[SW1-GigabitEthernet0/0/1]quit
[SW1]

Step 2 Run the following command to exit the SW1 system view and return to the user
view:

[SW1]quit
<SW1>

2.2 Basic Switch Configuration


2.2.1 Overview
2.2.1.1 About This Exercise
This exercise describes how to perform basic configurations on Huawei switches.

2.2.1.2 Objectives
 Understand how to change the system name of a Huawei switch.
 Understand how to use the ? key on Huawei switches.
 Understand how to use the display command on Huawei switches.
 Understand how to use the undo command on Huawei switches.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 28

2.2.1.3 Guideline
1. Change the system name.
2. Use the ? key.
3. Run the display command.
4. Run the undo command.

2.2.2 Configuration Procedure


2.2.2.1 Changing the System Name
Step 1 Log in to the switch and enter the system view.

<Huawei>system-view

Step 2 Change the system name to SW1 and then change it back to Huawei.

[Huawei]sysname SW1
[SW1]sysname Huawei
[Huawei]

2.2.2.2 Using the ? Key


? is used to display available commands.

Step 1 Check the available parameters of the interface command.

[Huawei]interface ?

Figure 2-9 Available parameters of the interface command

Step 2 Check the available parameters of the port command in the interface view.

[Huawei]interface GigabitEthernet 0/0/1


[Huawei-GigabitEthernet0/0/1]port ?
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 29

Figure 2-10 Available parameters of the port command

2.2.2.3 Running the display Command


Step 1 Run the following command in the system view to check interface information:

<Huawei>display interface brief

Figure 2-11 Checking brief interface information


Step 2 Run the following command to check the current device version:

<Huawei>display version

Figure 2-12 Checking the current version


Step 3 Run the following command in the system view to check the routing table:

[Huawei]display ip routing-table
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 30

Figure 2-13 Checking the routing table


Step 4 Run the following command to check the current device configuration:

[Huawei]display current-configuration

Figure 2-14 Checking the current configuration


Step 5 Run the following commands to enter the interface view and check the
configuration in the current view:

[Huawei]interface GigabitEthernet 0/0/1


[Huawei-GigabitEthernet0/0/1]display this
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 31

Figure 2-15 Checking the configuration in the current view

2.2.2.4 Running the undo Command


Step 1 Enter the interface view and set interface parameters.

[Huawei]interface GigabitEthernet 0/0/1


[Huawei-GigabitEthernet0/0/1]port link-type access

Step 2 Check the configuration of the current interface.

[Huawei-GigabitEthernet0/0/1]display this

Figure 2-16 Configuration of the current interface


Step 3 Delete the configuration of the current interface.

[Huawei-GigabitEthernet0/0/1]undo port link-type

Figure 2-17 Deleting the configuration


Step 4 Check the configuration of the current interface again.

[Huawei-GigabitEthernet0/0/1]display this
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 32

Figure 2-18 Configuration of the current interface

2.3 VLAN Implementation Exercise


2.3.1 Overview
2.3.1.1 About This Exercise
This exercise configures virtual local area networks (VLANs) on switches, so that users in
the same VLAN can communicate only with each other.

2.3.1.2 Objectives
 Understand the implementation of VLAN.
 Understand the link types of VLAN.
 Understand how to configure different types of VLAN interfaces.
 Understand how to assign VLANs based on interfaces.
 Understand the functions of different interface types.

2.3.1.3 Networking Topology

Figure 2-19 Networking diagram

2.3.1.4 Exercise Planning


 PC1, PC2, PC3, and PC4 are connected to a campus network through access switches
SW1 and SW2. Create VLAN 10 and VLAN 20, assign PC1 and PC2 to VLAN 10, and
assign PC3 and PC4 to VLAN 20.
 Configure the type of interfaces interconnecting the access switches to trunk and
configure the trunk interfaces to allow packets from corresponding VLANs to pass
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 33

through. Configure the type of interfaces connecting the access switches to the PCs
to access and change the PVIDs of the access interfaces to the VLAN IDs to be
assigned to the PCs.
 After the configuration, users in the same VLAN can communicate only with each
other, while users in different VLANs are isolated at Layer 2.

Table 2-1 VLAN interface type and parameter plan

Device Interface Interface Type VLAN Parameter

PVID: 1
GE0/0/1 Trunk
Allowed VLANs: VLAN 10 and VLAN 20
SW1
(LSW1) GE0/0/2 Access PVID: 10

GE0/0/3 Access PVID: 20

PVID: 1
GE0/0/1 Trunk
Allowed VLANs: VLAN 10 and VLAN 20
SW2
(LSW2) GE0/0/2 Access PVID: 10

GE0/0/3 Access PVID: 20

2.3.1.5 Guideline
1. Set up a topology.
2. Configure IP addresses for the hosts.
3. Create VLANs on the switches.
4. Configure access and trunk interfaces on the switches.
5. Verify the configuration.

2.3.2 Configuration Procedure


2.3.2.1 Setting Up a Topology
Step 1 Run eNSP and set up a topology according to the following figure using switch and
PC icons.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 34

Figure 2-20 Setting up a topology


Step 2 Select all devices and click the button in the red box in the following figure to start
the devices.

Figure 2-21 Starting devices


Step 3 Check that link indicator turns green after the devices are started.

Figure 2-22 Started devices


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 35

2.3.2.2 Configuring Hosts


Step 1 Double-click PC1 and PC2, set the IP addresses of PC1 and PC2 respectively
according to the following figure, and click Apply.

Figure 2-23 Configuring IP addresses

Step 2 Double-click PC3 and PC4, set the IP addresses of PC3 and PC4 respectively
according to the following figure, and click Apply.

Figure 2-24 Configuring IP addresses

2.3.2.3 Configuring Switches


Step 1 Configure LSW1.

Double-click LSW1 to enter the CLI. Run the following commands to enter the system
view and change the system name:

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW1

Figure 2-25 Changing the system name


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 36

Step 2 Create VLAN 10 and VLAN 20.

[Huawei]vlan batch 10 20

Figure 2-26 Creating VLANs


Step 3 Set the interface type of GE0/0/2 and GE0/0/3 to access and set their default VLAN
IDs to 10 and 20, respectively.

[SW1]interface GigabitEthernet 0/0/2


[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 10
[SW1]interface GigabitEthernet 0/0/3
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 20

# Run the dis this command on the two interfaces and verify the configurations.

Figure 2-27 Checking the interface configuration

Step 4 Configure GE0/0/1 as a trunk interface and configure it to allow packets from VLAN
10 and VLAN 20 to pass through.

[SW1]int GigabitEthernet 0/0/1


[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20

# Run the dis this command and verify the configuration.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 37

Figure 2-28 Checking the interface configuration


Step 5 Configure LSW2. You can configure LSW2 by referring to the configuration on
LSW1.
 Change the system name to SW2 and create VLAN 10 and VLAN 20.
 Set the interface type of GE0/0/2 and GE0/0/3 to access and set their default VLAN
IDs to 10 and 20, respectively.
 Configure GE0/0/1 as a trunk interface and configure it to allow packets from VLAN
10 and VLAN 20 to pass through.
# After the configuration is complete, run the following command to check the
configuration.

[SW2]dis current-configuration interface

Figure 2-29 Checking the interface configuration

2.3.2.4 Exercise Verification


 Testing the Connectivity in VLAN 10

Step 1 Double-click PC1 and click the CLI tab to enter the CLI. Ping the IP address of PC2
in the same VLAN.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 38

Figure 2-30 Verifying connectivity


 Testing the Connectivity in VLAN 20

Step 2 Double-click PC3 and click the CLI tab to enter the CLI. Ping the IP address of PC4
in the same VLAN.

Figure 2-31 Verifying connectivity


 Verifying that Users in VLAN 10 Cannot Communicate with Users in VLAN 20

Step 3 Change the default VLAN of the interface connecting LSW2 to PC2 to VLAN 20.

[SW2]interface GigabitEthernet 0/0/2


[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 20

Step 4 Double-click PC1 and click the CLI tab to enter the CLI. Ping the IP address of PC2
again.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 39

Figure 2-32 Verifying connectivity

2.4 Routing Implementation Exercise


2.4.1 Overview
2.4.1.1 About This Exercise
This exercise configures static routes to allow users on different network segments to
communicate with each other.

2.4.1.2 Objectives
 Understand basic operations on Huawei Layer 3 switches.
 Understand basic information in routing tables of Huawei Layer 3 switches.
 Understand how to configure VLANIF interfaces on Huawei Layer 3 switches.
 Understand how to configure static routes on Huawei Layer 3 switches.

2.4.1.3 Networking Topology

Figure 2-33 Networking diagram

2.4.1.4 Exercise Planning


 PC1, PC2, and PC3 belong to different departments and are connected to a campus
network through access switches SW1 and SW2.
 The interconnection network segment of SW1 and SW2 is 10.1.40.0/24. PC1 resides
on 10.1.10.0/24, PC2 resides on 10.1.20.0/24, and PC3 resides on 10.1.30.0/24.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 40

 Configure static routes on SW1 and SW2 so that users in different departments can
communicate with each other.

Table 2-2 Interface and address plan

Interface
Device Interface VLAN VLANIF Interface
Type

GE0/0/1 Access PVID: 10 VLANIF 10: 10.1.10.254/24


SW1
GE0/0/2 Access PVID: 20 VLANIF 20: 10.1.20.254/24
(LSW1)
VLANIF 40: 10.1.40.1/24
GE0/0/3 Access PVID: 40

SW2 GE0/0/1 Access PVID: 30 VLANIF 30: 10.1.30.254/24


(LSW2) VLANIF 40: 10.1.40.2/24
GE0/0/3 Access PVID: 40

Table 2-3 Static route plan

Device Static Route

SW1 (LSW1) ip route-static 10.1.30.0 24 10.1.40.2

ip route-static 10.1.10.0 24 10.1.40.1


SW2 (LSW2)
ip route-static 10.1.20.0 24 10.1.40.1

2.4.1.5 Guideline
1. Set up a topology.
2. Configure IP addresses for the hosts.
3. Configure interfaces on the switches and configure IP addresses for the interfaces.
4. Configure static routes on the switches.
5. Verify the configuration on the hosts.

2.4.2 Configuration Procedure


2.4.2.1 Setting Up a Topology
Step 1 Run eNSP and set up a topology according to the following figure using switch and
PC icons. Start the devices and mark the planned IP addresses.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 41

Figure 2-34 Setting up a topology and planning IP addresses

2.4.2.2 Configuring Hosts


Step 1 Double-click PC1, PC2, and PC3 and set the IP addresses of PC1, PC2, and PC3
respectively according to the following figure.

Figure 2-35 Configuring IP addresses

2.4.2.3 Configuring Switches


Step 1 Configure LSW1.
 Double-click LSW1 to enter the CLI. Run the following command to change the
system name to SW1.

[Huawei]sysname SW1
[SW1]

Figure 2-36 Changing the system name


 Create VLANs.

[SW1]vlan batch 10 20 40
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 42

Info: This operation may take a few seconds. Please wait for a moment...done.

Figure 2-37 Creating VLANs


 Configure interfaces as planned.

[SW1]interface GigabitEthernet 0/0/1


[SW1-GigabitEthernet0/0/1]port link-type access
[SW1-GigabitEthernet0/0/1]port default vlan 10
[SW1-GigabitEthernet0/0/1] interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 20
[SW1-GigabitEthernet0/0/2] interface GigabitEthernet 0/0/3
[SW1-GigabitEthernet0/0/3] port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 40
[SW1-GigabitEthernet0/0/3]quit
[SW1]interface Vlanif 10
[SW1-Vlanif10]ip address 10.1.10.254 24
[SW1-Vlanif10]quit
[SW1]interface Vlanif 20
[SW1-Vlanif20]ip address 10.1.20.254 24
[SW1]interface Vlanif 40
[SW1-Vlanif40]ip address 10.1.40.1 24

Figure 2-38 Configuring interfaces


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 43

 Configure a static route as planned.

[SW1]ip route-static 10.1.30.0 24 10.1.40.2

Figure 2-39 Configuring a static route


 Check the routing table.

[SW1]display ip routing-table

Figure 2-40 Routing table on SW1


Step 2 Configure LSW2.
 Double-click LSW2 to enter the CLI and change the system name to SW2.

[Huawei]sysname SW2
[SW2]

 Create VLANs.

[SW2]vlan batch 30 40
Info: This operation may take a few seconds. Please wait for a moment...done.

 Configure interfaces as planned.

[SW2]interface GigabitEthernet 0/0/1


[SW2-GigabitEthernet0/0/1]port link-type access
[SW2-GigabitEthernet0/0/1]port default vlan 30
[SW2-GigabitEthernet0/0/1]interface GigabitEthernet 0/0/3
[SW2-GigabitEthernet0/0/3]port link-type access
[SW2-GigabitEthernet0/0/3]port default vlan 40
[SW2-GigabitEthernet0/0/3]quit
[SW2]interface Vlanif 30
[SW2-Vlanif20]ip address 10.1.30.254 24
[SW2]interface Vlanif 40
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 44

[SW2-Vlanif40]ip address 10.1.40.2 24

Figure 2-41 Configuring interfaces


 Configure static routes as planned.

[SW2]ip route-static 10.1.10.0 24 10.1.40.1


[SW2]ip route-static 10.1.20.0 24 10.1.40.1

Figure 2-42 Configuring static routes


 Check the routing table.

[SW2]display ip routing-table
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 45

Figure 2-43 Routing table on SW2

2.4.2.4 Testing Connectivity


 Ping the IP address of PC2 (10.1.20.1) from PC1.

Figure 2-44 Testing connectivity


 Ping the IP address of PC3 (10.1.30.1) from PC1.

Figure 2-45 Testing connectivity


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 46

 Ping the IP address of PC2 (10.1.20.1) from PC3.

Figure 2-46 Testing connectivity

2.5 Quiz
After you run the display ip interface brief on an existing VLANIF interface on a switch,
the command output shows that the physical status and protocol status of the VLANIF
interface are both Down. Why does this occur?
Reference answer:
No physical interface assigned to the VLAN corresponding to the VLANIF interface is in
Up state.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 47

3 Linux Exercise

3.1 Overview
3.1.1 About This Exercise
This section introduces the bash commands, file management commands, and network
configuration commands on the openEuler OS.

3.1.2 Objectives
 Master bash commands.
 Master file management commands.
 Master the basic operations on the text editor.
 Master the basic operations of openEuler system and network configurations.

3.2 Preparations
3.2.1 Creating a VM
Step 1 Open VirtualBox 6.1.34 and click New to create a VM.

Figure 3-1 Creating a VM


Step 2 Enter the VM name, select the OS type and version, and click Next.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 48

Figure 3-2 VM name and OS type


Step 3 Select the memory size and click Next. (You are advised to select 4096 MB.)

Figure 3-3 Setting the memory


Step 4 Select Create a virtual hard disk now and click Create.

Figure 3-4 Setting the virtual hard disk


Step 5 Select VHD (Virtual Hard Disk) and click Next.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 49

Figure 3-5 Setting the virtual hard disk


Step 6 Select the size of the disk and click Create. (You are advised to select 30 GB.)

Figure 3-6 Setting the file location and size


Step 7 Click Settings on the main page.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 50

Figure 3-7 Main page

Step 8 On the System > Motherboard tab page, change the boot order to boot from the
hard disk first.

Figure 3-8 Setting the boot order

3.2.2 Installing an OS on the VM


Step 1 Start the VM.

Figure 3-9 Starting the VM

Step 2 Select a local openEuler image file and click Start.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 51

Figure 3-10 Starting the VM

Step 3 Select Install openEuler.

Figure 3-11 Installing the OS

Step 4 Select English and click Continue.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 52

Figure 3-12 Selecting the OS language

Step 5 Click Installation Destination and select a disk for installation.

Figure 3-13 Selecting the disk for installation


Step 6 Use the default settings and click Done. The main page is displayed.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 53

Figure 3-14 Selecting the installation destination


Step 7 Select Network & Hostname to configure the network.

Figure 3-15 Configuring the network


Step 8 Enable the enp0s3 network adapter and click Done. The main page is displayed.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 54

Figure 3-16 Configuring the network


Step 9 Select Root Password to configure the root password.

Figure 3-17 Configuring the root password


Step 10 Enter the root password, confirm the password, and click Done. The main page is
displayed.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 55

Figure 3-18 Configuring the root password


Step 11 Click Begin Installation.

Figure 3-19 Beginning installation


Step 12 Click Reboot System.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 56

Figure 3-20 Completing installation


Step 13 Log in to the VM as user root.

Figure 3-21 Logging in to the VM

3.3 Useful Commands


3.3.1 help
Step 1 Run the help command.

[root@localhost ~]# help pwd


pwd: pwd [-LP]
Print the name of the current working directory.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 57

Options:
-L print the value of $PWD if it names the current working
directory
-P print the physical directory, without any symbolic links

By default, `pwd' behaves as if `-L' were specified.

Exit Status:
Returns 0 unless an invalid option is given or the current directory
cannot be read.
[root@localhost ~]# help -d pwd
pwd - Print the name of the current working directory.
[root@localhost ~]# help -s pwd
pwd: pwd [-LP]

3.3.2 Other Common Commands


Step 1 Run the last command to display the latest login information about the users.

[root@localhost ~]# last


root pts/1 192.168.3.127 Thu May 5 10:41 still logged in
root pts/0 192.168.3.113 Thu May 5 08:20 still logged in
root tty1 Thu May 5 08:19 still logged in
reboot system boot 5.10.0-60.18.0.5 Thu May 5 08:13 still running

Step 2 Run the history command to view historical commands.

[root@localhost ~]# history


1 ls -l

Step 3 Press Tab to complete the command.

When entering a command, you can press Tab to automatically complete the command
or file path. For example, after you enter wh and press Tab, the following information is
displayed:

[root@localhost ~]# wh
whatis whereis which while whiptail who whoami

Step 4 Run the wget command to download a file from a specified URL.

Note that the host on which you run the wget command must be able to access the
Internet.

[root@localhost ~]# wget https://wordpress.org/latest.zip


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 58

3.4 bash Commands


3.4.1 Power Supply Control and User Switching
Step 1 Start the openEuler VM and log in to the VM as user root.

Step 2 Practice using the basic bash commands.

Run the reboot command to reboot openEuler.

[root@localhost ~]# reboot

After the reboot, log in to openEuler as user root.


Run the logout or exit command to log out.

[root@localhost ~]# logout

3.4.2 Basic Directory and File Operations


Step 1 Run the pwd command to view the current directory.

[root@localhost ~]# pwd


/root
[root@localhost ~]#
# The command output indicates that the current directory is the /root directory.

Step 2 Run the ls commands.


 View the files and directories in the current directory.

[root@localhost ~]# ls
anaconda-ks.cfg
[root@localhost ~]# ls .
anaconda-ks.cfg
# The command output indicates that the anaconda-ks.cfg file exists in the current directory.

 View the files and directories in the upper-level directory.

[root@localhost ~]# ls ..
afs boot etc lib lost+found mnt proc run srv tmp var
bin dev home lib64 media opt root sbin sys usr

 View the files and directories in the /tmp directory.

[root@localhost ~]# ls /tmp


systemd-private-6b5ec1dcc15141d0bf3edecae5a0c8ca-chronyd.service-ae8LHA
systemd-private-6b5ec1dcc15141d0bf3edecae5a0c8ca-systemd-logind.service-K97Nbh

 View all files and directories in the current directory.

[root@localhost ~]# ls -a
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 59

. anaconda-ks.cfg .bash_logout .bashrc .tcshrc


……
# The command output indicates that the current directory contains hidden files and directories.

 View detailed information about non-hidden files and directories in the current
directory.

[root@localhost ~]#ls -l
total 4
-rw-------. 1 root root 1139 Jul 8 11:07 anaconda-ks.cfg

 View detailed information about all files and directories in the current directory.

[root@localhost ~]#ls -al


total 36
dr-xr-x---. 2 root root 4096 Jul 8 11:38 .
dr-xr-xr-x. 18 root root 4096 Jul 8 11:00 ..
-rw-------. 1 root root 1139 Jul 8 11:07 anaconda-ks.cfg
-rw-------. 1 root root 236 Jul 8 11:45 .bash_history

Step 3 Run the cd commands to switch to directories.


 Switch to the root directory of the system.

[root@localhost ~]# cd /
[root@localhost /]#
# Note that ~ changes to /.

 Switch to the /etc/ directory.

[root@localhost /]# cd /etc


[root@localhost etc]#

 Use the relative path to switch to the /etc/sysconfig/ directory.

[root@localhost etc]# cd sysconfig


[root@localhost sysconfig]#

 Use the absolute path to switch to the /etc/sysconfig/ directory.

[root@localhost etc]# cd /etc/sysconfig


[root@localhost sysconfig]#

 Switch to the upper-level directory.

[root@localhost sysconfig]# cd ..
[root@localhost etc]#

 Switch to the home directory of the current user.

[root@localhost sysconfig]#cd
[root@localhost ~]#
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 60

 Switch to the previous directory.

[root@localhost sysconfig]# cd -
/etc
[root@localhost etc]#

 Switch to the home directory of the current user.

[root@localhost etc]#cd /etc/sysconfig


[root@localhost sysconfig]#cd ~
[root@localhost ~]#

Step 4 Run the mkdir commands to create directories.


 Create the test1 directory in the current directory.

[root@localhost ~]# mkdir test1


[root@localhost ~]# ls
anaconda-ks.cfg test1

 Create the test2 directory using a relative path.

[root@localhost ~]# mkdir ./test2


[root@localhost ~]# ls
anaconda-ks.cfg test1 test2

 Create the test3 directory using an absolute path.

[root@localhost ~]# mkdir /root/test3


[root@localhost ~]# ls
anaconda-ks.cfg test1 test2 test3

Step 5 Run the touch commands to create files.

Create the huawei.txt and huawei1.txt files.

[root@localhost ~]# cd test1


[root@localhost test1]# touch /root/test1/huawei.txt
[root@localhost test1]# touch huawei1.txt
[root@localhost test1]# ls
huawei.txt huawei1.txt

Step 6 Run the cp commands to copy files.


 Copy huawei.txt to the /root/test2 directory and name it huawei.txt.bak.

[root@localhost test1]# cp huawei.txt /root/test2/huawei.txt.bak


[root@localhost test1]# ls /root/test2
huawei.txt.bak

 Copy the test1 directory to the /root/test2 directory.

[root@localhost test1]# cp -r /root/test1 /root/test2/


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 61

[root@localhost test1]# ls /root/test2/


huawei.txt.bak test1

Step 7 Run the rm commands to delete files.


 Delete the huawei.txt file from the /root/test1 directory.

[root@localhost test1]# rm huawei.txt


rm: Are you sure you want to delete the common empty file huawei.txt? y # Enter y to confirm
the deletion.
[root@localhost test1]# rm -f huawei1.txt # -f forcibly deletes the file and does not
display any message.
[root@localhost test1]# ls
[root@localhost test1]#

 Delete the test1 directory from the /root directory.

[root@localhost test1]# cd
[root@localhost ~]# ls
anaconda-ks.cfg test1 test2 test3
[root@localhost ~]# rmdir /root/test1 # Deletes an empty directory.
[root@localhost ~]# ls
anaconda-ks.cfg test2 test3
[root@localhost ~]# mkdir /root/test1
[root@localhost ~]# touch /root/test1/huawei3.txt
[root@localhost ~]# rm -r /root/test1 # -r recursively deletes the directory and all files in the
directory.

Figure 3-22 Deleting files


Step 8 Run the mv command to move and rename a file.

Move the huawei.txt.bak file from the /root/test2 directory to the /root directory and
rename the file as huawei.txt.

[root@localhost ~]# mv /root/test2/huawei.txt.bak ~/huawei.txt


[root@localhost ~]# ls
anaconda-ks.cfg huawei.txt test2 test3

3.5 File Viewing Commands


3.5.1 Viewing Files
Step 1 Copy the /etc/passwd file to the /root directory.

[root@localhost test3]# cd
[root@localhost ~]# cp /etc/passwd ~
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 62

Step 2 Run the cat command to view the content of a small text file.

View the content of the passwd file.

[root@localhost ~]# cat passwd


root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
systemd-timesync:x:998:995:systemd Time Synchronization:/:/sbin/nologin
unbound:x:997:994:Unbound DNS resolver:/etc/unbound:/sbin/nologin
……

Step 3 Run the head commands to view the first several lines of a file.
 View the first 10 lines of the file by default.

[root@localhost ~]# head passwd # If no option is added to the head command, the
first 10 lines of the file are displayed by default.
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin

 View the first five lines of the file.

[root@localhost ~]# head -n 5 passwd


root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin

 View all content except the last 20 lines of the file.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 63

[root@localhost etc]# head -n -20 passwd


root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin

 View the first 10 bytes of the file.

[root@localhost ~]# head -c 10 passwd


root:x:0:0[root@localhost ~]#

Step 4 Run the tail commands to view the last several lines of a file.
 View the last 10 lines of the file by default.

[root@localhost etc]# tail passwd # Similar to head, if no option is added to the head command,
the last 10 lines of the file are displayed by default.
tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
chrony:x:995:992::/var/lib/chrony:/sbin/nologin
systemd-network:x:990:990:systemd Network Management:/:/usr/sbin/nologin
systemd-resolve:x:989:989:systemd Resolver:/:/usr/sbin/nologin
systemd-timesync:x:988:988:systemd Time Synchronization:/:/usr/sbin/nologin
gluster:x:987:987:GlusterFS daemons:/run/gluster:/sbin/nologin
radvd:x:75:75:radvd user:/:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
dnsmasq:x:985:985:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/usr/sbin/nologin h

 View the last five lines of the file.

[root@localhost ~]# tail -n 5 passwd

 View the updated data in of a log file dynamically.

[root@localhost ~]# tail -f /var/log/messages

Step 5 Run the less command to view (and search) the file content of a large file.

View the file. Press the up and down arrow keys to navigate the lines; press the space bar
to scroll one page forward; enter a slash (/) and a keyword to search for the keyword;
and press q to exit.

[root@localhost ~]# less passwd


root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 64

adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync

Step 6 Run the more command to view (and search) the file content of a large file.

View the file. Press the space bar to scroll one page forward or exit when you reach the
end of the file; enter a slash (/) and a keyword to search for the keyword; and press q to
exit.

[root@localhost ~]# more passwd


root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync

3.5.2 (Optional) Searching for Files


Step 1 Run the find commands.
 Search for the file named passwd in the /etc directory.

[root@localhost etc]# find /etc -name passwd


/etc/pam.d/passwd
/etc/passwd

 Search for files that belong to user root in the /root directory.

[root@localhost etc]# find /root -user root


/root
/root/bzip2-1.0.6.tar.gz
/root/bzip2-1.0.6
/root/bzip2-1.0.6/compress.o
/root/bzip2-1.0.6/libbz2.a
……

 Search for files larger than 512 KB in the /etc directory.

[root@localhost etc]# find /etc -size +512k


/etc/ima/digest_lists/0-metadata_list-rpm-python3-perf-5.10.0-60.18.0.50.oe2203.x86_64
/etc/ima/digest_lists/0-metadata_list-rpm-kernel-5.10.0-60.18.0.50.oe2203.x86_64
/etc/ima/digest_lists/0-metadata_list-rpm-kernel-tools-5.10.0-60.18.0.50.oe2203.x86_64

Step 2 Run the whereis command.

This command can only be used to find binary files, source code files, and man pages.
View the location of the bash command.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 65

[root@localhost ~]# whereis bash


bash: /usr/bin/bash

3.6 Basic Operations on the Vim Text Editor


3.6.1 Normal Mode of Vim
3.6.1.1 Cursor Control
Step 1 Run the following command to verify that the VM can access the Internet. (Prepare
the VM by referring to section 3.2 and ensure that the VM can access the Internet.)

[root@openEuler ~]# ping www.huawei.com

Step 2 Download the tutorial file.

[root@openEuler ~]# wget -c http://www.silecs.info/formations/Linux-TP-export/vimtutor-en.txt -O


vimtutor

Step 3 Run the following vim command to open the vimtutor file.

[root@openEuler ~]# vim vimtutor # Open the vimtutor file with vim. The tutorial home page is
displayed.
===============================================================================
= Welcome to the VIM Tutor - Version 1.7 =
===============================================================================
Vim is a very powerful editor that has many commands, too many to
explain in a tutor such as this. This tutor is designed to describe
enough of the commands that you will be able to easily use Vim as
an all-purpose editor.
The approximate time required to complete the tutor is 25-30 minutes,
depending upon how much time is spent with experimentation.
ATTENTION:
The commands in the lessons will modify the text. Make a copy of this
file to practise on (if you started "vimtutor" this is already a copy).

It is important to remember that this tutor is set up to teach by


use. That means that you need to execute the commands to learn them
properly. If you only read the text, you will forget the commands!
Now, make sure that your Shift-Lock key is NOT depressed and press
the j key enough times to move the cursor so that Lesson 1.1
completely fills the screen.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~

Step 4 Press j a few times to move the cursor down until you can see the full content of
section 1.1. Press k, j, h, and l keys to move the cursor up, down, left, and right,
respectively.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 66

Figure 3-23 Moving the cursor to view the document


Step 5 Press Ctrl+D to scroll one page forward; press Ctrl+U to scroll one page backward;
press k, j, h, and l keys to move the cursor up, down, left, and right, respectively.

Step 6 Enter gg to move the cursor to the first line of the document; enter G to move the
cursor to the last line of the document.

Figure 3-24 Moving the cursor to view the document

Figure 3-25 Moving the cursor to view the document

Step 7 Enter ngg to move the cursor to line n of the document, for example, 10gg.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 67

Figure 3-26 Moving the cursor to view the document


Step 8 Scroll down until you can see the full content of section 2.6, and then move the
cursor to the second line starting with --->.

Figure 3-27 Moving the cursor to view the document

3.6.1.2 Quick Deletion


Step 1 Enter dd to delete the line.

Figure 3-28 Deleting a line


Step 2 Move the cursor to line 4 and enter 2dd to delete lines 4 and 5.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 68

3.6.1.3 Copying and Pasting


Step 1 Move the cursor down to the third line of section 2.7, and then enter yy to copy the
line.

Figure 3-29 Copying a line


Step 2 Enter p to paste the copied content to the current line.

Figure 3-30 Pasting the copied content

Step 3 Move the cursor to 5, and then enter P to paste the copied content above the
current line.

Figure 3-31 Pasting the copied content

3.6.1.4 Undoing
Step 1 Enter u twice to undo the paste operations.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 69

Figure 3-32 Undoing

3.6.2 Insert Mode of Vim


3.6.2.1 Deleting Text
Step 1 Run the following command to open vimtutor again.

[root@openEuler ~]# vimtutor

Step 2 Move the cursor down until you can see the full content of section 1.3.

Figure 3-33 Moving the cursor to view the content


Step 3 Move the cursor to the unwanted c in the line starting with --->, and then press x
to delete the character.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 70

Figure 3-34 Deleting a character


Step 4 Delete other unwanted characters in the line by referring to the preceding step.

Figure 3-35 Deleting characters

3.6.2.2 Inserting Text


Step 1 Move the cursor up until you can see the full content of section 1.4.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 71

Figure 3-36 Moving the cursor to view the content

Step 2 Move the cursor to text in the first line starting with --->, and then press i to enter
the insert mode.

Figure 3-37 Insert mode


Step 3 Enter the missing word some by referring to the line below.

Figure 3-38 Inserting content

Step 4 Move the cursor and enter other missing characters to make the first line the same
as the second. Press Esc to exit the insert mode and return to the normal mode.

Figure 3-39 Returning to the normal mode


Step 5 Move the cursor to the end of the first line starting with --->, enter o to insert a line
below the current line, and enter Add the first line here..

Figure 3-40 Inserting a line


Step 6 Move the cursor to the end of the second line starting with --->, enter O to insert a
line above the current line, and enter Add the second line here..
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 72

Figure 3-41 Inserting a line

3.6.3 Command Line Mode of Vim


Step 1 Move the cursor down until you can see the full content of section 1.2.

Figure 3-42 Moving the cursor to view the content


Step 2 Enter :q! and press Enter to forcibly exit the tutorial without saving any changes.

:q!
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 73

Figure 3-43 Forcible exit

Step 3 Enter :wq and press Enter to save and exit the tutorial.

:wq

Figure 3-44 Save and exit


Step 4 Run the %s/Lesson/Class/g command to replace all occurrences of Lesson in the
file with Class.

:%s/Lesson/Class/g

Figure 3-45 Replacing characters


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 74

3.7 openEuler System and User Management


3.7.1 Network Management
3.7.1.1 Host Name Management
Step 1 View the host name.

[root@localhost ~]# hostname


localhost.localdomain
[root@localhost ~]# cat /etc/hostname # View the host name configuration file.
localhost.localdomain

Step 2 Change the host name temporarily.

[root@localhost ~]# hostname huawei # Change the host name temporarily. The change becomes
invalid after a restart.
[root@localhost ~]# hostname
huawei
[root@localhost ~]# bash # Start a new session.
Welcome to 5.10.0-60.18.0.50.oe2203.x86_64
System information as of time: system_time
System load: 0.16
Processes: 129
Memory used: 3.7%
Swap used: 0%
Usage On: 23%
IP address: 10.0.2.15
Users online: 3
[root@huawei ~]# # In the command prompt, the host name is changed to
huawei.
[root@huawei ~]# exit
exit
[root@localhost ~]#

Step 3 Change the host name permanently.

Method 1:
[root@localhost ~]# hostnamectl set-hostname openEuler # This method requires a re-login
instead of a restart.
Method 2:
[root@localhost ~]# vim /etc/hostname
#Change the host name in the file, save the change, and exit. The host name is changed after the
system is restarted.
[root@localhost ~]# reboot

3.7.1.2 Network Management


Step 1 Run the ip command to add a temporary IP address to the network adapter.

[root@openEuler ~]# ip addr show


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 75

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default
qlen 1000
link/ether 08:00:27:a5:05:8a brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
valid_lft 83814sec preferred_lft 83814sec
inet6 fe80::e2e1:a18b:f73a:d89e/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@openEuler ~]# ip addr add 192.168.110.100/24 dev enp0s3
[root@openEuler ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default
qlen 1000
link/ether 08:00:27:a5:05:8a brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
valid_lft 83599sec preferred_lft 83599sec
inet 192.168.110.100/24 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::e2e1:a18b:f73a:d89e/64 scope link noprefixroute

Step 2 Run the ip command to delete the temporary IP address of the network adapter.

[root@openEuler ~]# ip addr del 192.168.110.100/24 dev enp0s3


[root@openEuler ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen
1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default
qlen 1000
link/ether 08:00:27:a5:05:8a brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute enp0s3
valid_lft 83814sec preferred_lft 83814sec
inet6 fe80::e2e1:a18b:f73a:d89e/64 scope link noprefixroute
valid_lft forever preferred_lft forever

Step 3 Configure a static route.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 76

# Set a static route to network range 192.168.2.0/24, with the next hop being the
gateway.

[root@openEuler ~]# ip route


default via 10.0.2.2 dev enp0s3 proto dhcp metric 100
default via 192.168.3.1 dev enp0s8 proto dhcp metric 101
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100
[root@openEuler ~]# ip route add 192.168.2.0/24 via 10.0.2.254 dev enp0s3
[root@openEuler ~]# ip route
default via 10.0.2.2 dev enp0s3 proto dhcp metric 100
default via 192.168.3.1 dev enp0s8 proto dhcp metric 101
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100
192.168.2.0/24 via 10.0.2.15 dev enp0s3

Step 4 Use the nmcli command to create a network connection and apply it to an
interface of the host:
 View the current NetworkManager status.

[root@openEuler ~]# nmcli general status


STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN
connected full enabled enabled enabled enabled

Figure 3-46 Viewing network connections


 View the current connections.

[root@openEuler ~]# nmcli connection show


NAME UUID TYPE DEVICE
enp0s3 2c2c3fe1-67e0-417d-be50-c7f2ef1d890b ethernet enp0s3
enp0s8 233d807e-9a81-4f5d-bce4-837fd69ea526 ethernet enp0s8
virbr0 37fb512e-e88d-4f19-a6a1-fdb02c633ea2 bridge virbr0
net-static e4c1c576-7a43-4838-96da-321fc76e91b2 ethernet --

Figure 3-47 Viewing connections


 View the status of the network devices.

[root@openEuler ~]# nmcli device status


DEVICE TYPE STATE CONNECTION
enp0s3 ethernet connected enp0s3
……
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 77

Figure 3-48 Viewing network devices


 Create a new network connection net-static and apply it to an interface of the host.

[root@openEuler ~]# nmcli con add type ethernet con-name net-static ifname enp0s3 ip4
192.168.110.10/24 gw4 192.168.110.254
# conn indicates that the operation is performed on a connection.
# add adds (a connection).
# type indicates the type of the connection.
# con-name indicates the connection name.
# ifname indicates the name of the network adapter.
[root@openEuler ~]# nmcli connection show

Figure 3-49 Viewing network connections


 Enable the created network connection net-static.

[root@openEuler ~]# nmcli con up net-static ifname enp0s3


[root@openEuler ~]# nmcli connection show

Figure 3-50 Viewing network connections

[root@openEuler ~]# nmcli con down net-static # Disable the connection.

Step 5 Use the nmcli command to configure a static route.

[root@openEuler ~]# nmcli connection modify enp0s3 +ipv4.routes "192.168.100.0/24


10.0.15.254"

Step 6 Change the host IP address using the configuration file of the ifcfg-enp0s3 network
adapter.

[root@openEuler ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3


TYPE=Ethernet # Interface type
PROXY_METHOD=none # Method for proxy configuration
BROWSER_ONLY=no # Whether the proxy configuration is for browser only
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 78

BOOTPROTO=dhcp # Boot-time protocol


DEFROUTE=yes # Whether to assign the default route to this interface
IPV4_FAILURE_FATAL=no # Whether to disable this interface if the IPv4 configuration fails
IPV6INIT=yes # Whether to initialize IPv6
IPV6_AUTOCONF=yes # Whether to configure IPv6 automatically
IPV6_DEFROUTE=yes # Whether to assign the default IPv6 route to this interface
IPV6_FAILURE_FATAL=no # Whether to disable this interface if the IPv6 configuration fails
IPV6_ADDR_GEN_MODE=stable-privacy # IPv6 address generation mode
NAME=enp0s3 # Name of the network connection
UUID=2c2c3fe1-67e0-417d-be50-c7f2ef1d890b # UUID of the devcie
ONBOOT=yes # Whether to start this interface with the system
DEVICE=enp0s3 # Name of the physical device

 When configuring the network, change dhcp to static or none and add the following
information:

IPADDR=192.168.110.11
NETMASK=255.255.255.0
GATEWAY=192.168.110.254

 Run the following commands for the configuration to take effect.

[root@openEuler ~]# ifdown enp0s3


[root@openEuler ~]# ifup enp0s3

Step 7 Edit /etc/hosts.

[root@openEuler ~]# vim /etc/hosts # The hosts file records the mapping between host names
and IP addresses for quick domain name resolution. Add the following information to the end of the
file:
192.168.110.11 server # After adding this line, save the file and exit.
[root@openEuler ~]# ping server -c 3
PING server (192.168.110.11) 56(84) bytes of data.
64 bytes from server (192.168.110.11): icmp_seq=1 ttl=40 time=53.3 ms
64 bytes from server (192.168.110.11): icmp_seq=2 ttl=40 time=51.3 ms

--- server ping statistics ---


3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 51.288/52.351/53.338/0.838 ms

3.7.2 Service Management


Step 1 View the current services.

[root@openEuler ~]# systemctl list-units --type service


UNIT LOAD ACTIVE SUB DESCRIPTION
atd.service loaded active running Deferred execution scheduler
auditd.service loaded active running Security Auditing Service
chronyd.service loaded active running NTP client/server
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message Bus
dkms.service loaded active exited Builds and install new kernel modules throug
dracut-shutdown.service loaded active exited ROceanstor eStore /run/initramfs on shutdown
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 79

firewalld.service loaded active running firewalld - dynamic firewall daemon


[email protected] loaded active running Getty on tty1
gssproxy.service loaded active running GSSAPI Proxy Daemon
hwclock-save.service loaded active exited Update RTC With System Clock

Step 2 View the status of a service, for example, the firewall service.

[root@openEuler ~]# systemctl status firewalld.service # View the service status.


○ firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
[root@openEuler ~]# systemctl is-active firewalld.service # Check whether the service is
running.
active
[root@openEuler ~]# systemctl is-enabled firewalld.service # Check whether the service is
enabled.
enabled

Step 3 Terminate a service, such as the firewall service.

[root@openEuler ~]# systemctl stop firewalld.service


[root@openEuler ~]# systemctl is-active firewalld.service
inactive

Step 4 Restart a service, for example, the firewall service.

[root@openEuler ~]# systemctl restart firewalld.service


[root@openEuler ~]# systemctl is-active firewalld.service
active

Step 5 Disable a service, for example, the firewall service.

[root@openEuler ~]# systemctl disable firewalld.service


Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@openEuler ~]# systemctl is-enabled firewalld.service
disabled

Step 6 Enable a service, for example, the firewall service.

[root@openEuler ~]# systemctl enable firewalld.service


Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service →
/usr/lib/systemd/system/firewalld.service.
Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service →
/usr/lib/systemd/system/firewalld.service.
[root@openEuler ~]# systemctl is-enabled firewalld.service
enabled
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 80

3.7.3 User Management


Step 1 Use the id command to view the ID of a user and the ID of the group to which the
user belongs.

[root@localhost ~]# id
uid=0(root) gid=0(root) groups=0(root)

Step 2 Log in to the system as user root, create users tom, bob, and jack, and set the UID
of jack to 1024.

[root@localhost ~]# useradd tom


[root@localhost ~]# useradd bob
[root@localhost ~]# useradd -u 1024 jack
[root@localhost ~]# tail -3 /etc/passwd
tom:x:1001:1001::/home/tom:/bin/bash
bob:x:1002:1002::/home/bob:/bin/bash
jack:x:1024:1024::/home/jack:/bin/bash
[root@localhost ~]# useradd -d /home/myd bob1 # Use the -d parameter to specify the home
directory for the new user.

Step 3 Change the home directory of tom to /home/tony.

[root@localhost ~]# usermod -md /home/tony/ tom


# m and d are often used together to specify the home directory of a user.
[root@openEuler ~]# tail -4 /etc/passwd
tom:x:1000:1000::/home/tony/:/bin/bash
bob:x:1001:1001::/home/bob:/bin/bash
jack:x:1024:1024::/home/jack:/bin/bash
bob1:x:1025:1025::/home/myd:/bin/bash

Step 4 Delete user bob and its home directory.

[root@localhost ~]# userdel -r bob # Use the -r parameter to delete the user's
home directory.
[root@openEuler ~]# tail -3 /etc/passwd
tom:x:1000:1000::/home/tony/:/bin/bash
jack:x:1024:1024::/home/jack:/bin/bash
bob1:x:1025:1025::/home/myd:/bin/bash

Note: The command output shows the last three lines of the user configuration file. You
can see that user bob does not exist.
The bob directory does not exist in the /home directory.

[root@openEuler ~]# ls /home/


jack myd tony

Step 5 Use the su command to switch users.

Switch from the current user (root) to jack on the terminal.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 81

[root@openEuler ~]# su jack


[root@openEuler root]$ pwd
/root
[root@openEuler root]$ exit
exit
[root@openEuler ~]# su - jack
[root@openEuler ~]$ pwd
/home/jack
[root@openEuler ~]$ exit

3.8 Quiz
On Linux, how do we view the updated contents of a log file in real time?
Answer:
Run the tail -f /var/log/XX/file.log command to view the updated data of the log file.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 82

4 KVM Installation and Resources


Provisioning

4.1 Overview
4.1.1 About This Exercise
In this lab, bridged networks and NAT networks are configured to enable the
communication between VMs and external networks. This lab introduces two network
modes (NAT and bridge) in KVM virtualization to help trainees understand the basic
principles of communication between VMs and external networks. A computer with at
least 4 cores and 8 GB memory is recommended.

4.1.2 Objectives
 Understand the basic principles of KVM virtualization.
 Grasp the creation and process of KVM.
 Grasp the features and configuration method of bridged networks and NAT
networks.

4.1.3 Lab Networking


4.1.3.1 Lab Environment Overview
 In this lab, the host VM is created using Oracle VM VirtualBox Manager (VirtualBox),
and the lab VM is created using KVM virtualization on the host VM.
 In this lab, two physical interfaces are planned for the host VM: management
interface (enp0s8) and service interface (enp0s3). The service interface is configured
to NAT networks and the management interface is configured to bridged network
and is used for remote access using virtual network console (VNC) or Secure Shell
(SSH).
 In this lab, the type of the default network and the test network are NAT.
 In this lab, virbr0 is the default bridge, and virbr1 and virbr2 are new bridges.
 In this lab, VMs access the Internet through NAT and bridged networks.

4.1.3.2 NAT Networks


 VM 01 is the lab VM.
 You need to create VM 01 and modify its network in this lab.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 83

Figure 4-1 Lab Networking of NAT networks

4.1.3.3 Bridged Networks


 VM 02 is the lab VM.
 You need to create VM 02 using bridges in this lab.

Figure 4-2 Lab networking of bridged networks


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 84

4.1.4 Exercise Planning


Table 4-1 Host VM port and parameter design

Connection
Device Port IP Address
Method

NIC 1
NAT 10.0.2.0/24 (service)
(enp0s3)
Host VM
NIC 2
Bridge 192.168.3.0/24 (management)
(enp0s8)

Table 4-2 Host VM bridge and parameter design

Network
Device IP Address Physical Interface
Bridge

virbr0 192.168.122.1/24 None

Host VM virbr1 192.168.100.1/24 None

virbr2 10.0.2.15/24 enp0s3

4.2 Exercise Configuration


4.2.1 Guideline
 Creating a host VM
1. Select the connection methods of ports, compute and storage resources, and
enable the corresponding virtualization features as planned.
2. Import the image file and install the operating system (OS).
 Preparing the lab
1. Use a terminal tool to log in to the host VM and disable services such as the
firewall service.
2. Install virtualization components and check their statuses.
3. Download the OS image file to the local host VM for backup.
 Creating a VM using NAT
1. Specify default to create VM 01 and install the OS on VM 01.
2. Log in to VM 01, view its IP address, test its connectivity with external networks,
and verify the NAT network.
 Changing the network information of VM 01.
1. Create test using NAT, change the network of VM 01 to test, and reboot VM 01.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 85

2. Log in to VM 01, view the new IP address allocated by test, and verify its
connectivity with external networks.
 Create a VM using bridges
1. Create virbr2, bind the planned physical service port enp0s3, and assign the IP
address of the original physical port to virbr2.
2. Specify virbr2 to create VM 02 and install the operating system on VM 02. Log
in to VM 02, view its IP address, test the connectivity between VM 02 and the
host VM or external networks, and verify the bridged network.

4.2.2 Procedure
4.2.2.1 Creating a Host VM
Step 1 Run Oracle VM VirtualBox Manager and click New to create a VM.

Figure 4-3 Creating a VM


Step 2 Enter the VM name, select the OS type and version, and click Next.

Figure 4-4 Configuring the VM name and OS type


Step 3 Select the memory size and click Next. (You are advised to select 4,096 MB.)
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 86

Figure 4-5 Configuring memory

Step 4 Select Create a virtual hard disk now and click Create.

Figure 4-6 Creating a virtual hard disk


Step 5 Select VHD (Virtual Hard Disk) and click Next.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 87

Figure 4-7 Configuring the virtual hard disk


Step 6 Select the size of the disk and click Next. (You are advised to select 30 GB.)

Figure 4-8 Selecting the location and size of the virtual hard disk
Step 7 On the main page of the software, click the created VM (openEuler) and Settings.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 88

Figure 4-9 Configuring the VM

Step 8 On the openEuler – Settings page, choose System, click Motherboard, and adjust
the boot order to boot from the hard disk first.

Figure 4-10 Changing the boot order


Step 9 Choose System, click Acceleration, and select KVM for Paravirtualization
Interface.

Figure 4-11 Selecting the paravirtualization interface


Step 10 Choose Network, click Adapter 2, and select Enable Network Adapter. Select
Bridged Adapter for Attached to.

Step 11 This adapter is used as the planned management adapter.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 89

Figure 4-12 Changing the connection method of NIC 2


Step 12 Choose System, click Processor, set Processor(s) to 4, and select Enbale Nested
VT-x/AMD-V for Extended Features.

Figure 4-13 Configuring Processors


If Nested VT-x/AMD-V cannot be enabled, you can perform the following steps:
1. Click OK to save the configuration.
2. Press Win+X to go to the Windows PowerShell (administrator) page.
3. Run the following command to enable nested VT-x/AMD-V.

PS C:\WINDOWS\system32> cd "d:\Download\virtualbox" # VirtualBox installation path


In PS D:\Download> .\VBoxManage.exe modifyvm "openEuler" --nested-hw-virt on # the text with
double quotation marks is the VM name.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 90

Figure 4-14 Run the command


Note: After running commands, you need to recheck whether these two options are
selected. If yes, click OK.

Figure 4-15 Enabling nested VT-x/AMD-V

4.2.2.2 Installing an OS on the VM


Step 1 Choose openEuler and click Start to start the VM.

Figure 4-16 Starting the VM


Step 2 Select a local openEuler image file and click Start.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 91

Figure 4-17 Selecting start-up disk and starting the VM


Step 3 Select Install openEuler 22.03-LTS.

Figure 4-18 Installing the OS


Step 4 Select English and click Continue.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 92

Figure 4-19 Selecting the OS language


Step 5 Click Installation Destination to select a disk where to install the OS.

Figure 4-20 Selecting the installation destination


Step 6 Use the default settings and click Done.

Step 7 The main page is displayed.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 93

Figure 4-21 Selecting the installation destination


Step 8 Click Network & Host Name to configure the network.

Figure 4-22 Configuring the network and host name


Step 9 Enable the NIC 1 (enp0s3) and the NIC 2 (enp0s8). Click Done.

Step 10 The main page is displayed.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 94

Figure 4-23 Enabling the NIC 1 (enp0s3)

Figure 4-24 Enabling the NIC 2 (enp0s8)

Step 11 Select Root Password to configure it.


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 95

Figure 4-25 Configuring the root password

Step 12 Enter the root password, confirm it, and click Done. Click Done.

Step 13 The main page is displayed.

Figure 4-26 Configuring the root password


Step 14 Click Begin Installation.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 96

Figure 4-27 Installing the OS on the VM


Step 15 Click Reboot System.

Figure 4-28 Rebooting the OS


Step 16 Enter root and the password to log in to the VM.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 97

Figure 4-29 Logging in to the VM


Step 17 Run the following command to view the current IP address.

10.0.2.15/24 is the service address, and 192.168.3.117/24 is the management address.

[root@localhost ~]# ip addr

Figure 4-30 Viewing the current IP address

4.2.2.3 Preparing the Lab


Step 1 Start a terminal tool and enter the management IP address to log in to the VM.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 98

Figure 4-31 Logging in to the VM

Step 2 Run the following commands to disable the corresponding service.

[root@localhost ~]# systemctl disable firewalld.service # Disabling the firewall service


for [root@localhost ~]# vi /etc/selinux/config # Changing SELINUX=disabled
[root@localhost ~]# reboot # Rebooting the VM

Figure 4-32 Disabling the firewall service

[root@localhost ~]# systemctl status firewalld # Checking the status


of the firewall service
○ firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 99

Docs: man:firewalld(1)
[root@localhost ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.


# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

Step 3 Install virtualization components and start libvirtd.

[root@localhost ~]# yum -y install libvirt qemu virt-install wget net-tools bridge-utils
[root@localhost ~]# systemctl start libvirtd
[root@localhost ~]# systemctl enable libvirtd

 libvirt is an open-source API, daemon and management tool for managing


virtualization platforms.
 QEMU is open-source (emulation) software. It can emulate all resources required by
VMs, including the CPU, memory, I/O device, USB, and NICs.
 virt-install is a command line tool for creating VMs and installing OSs for KVM, Xen,
or other hypervisors supporting libvirt.
 wget is a free tool for automatically downloading files from Internet.
 net-tools is a network configuration tool.
 bridge-utils is used to configure Linux bridges.

Step 4 Check the status of components and libvirtd.


 The status of the QEMU component

[root@localhost ~]# rpm -qi qemu


Name : qemu
Epoch :2
Version : 6.2.0
Release : 29.oe2203
Architecture: x86_64
...

 The status of the libvirt component

[root@localhost ~]# rpm -qi libvirt


Name : libvirt
Version : 6.2.0
Release : 36.oe2203
Architecture: x86_64
...
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 100

 The service status of libvirtd

[root@localhost ~]# systemctl status libvirtd


○ libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
......

Step 5 Download the image to the /opt directory.

[root@localhost ~]# cd /opt


[root@localhost opt]# wget https://mirrors.tuna.tsinghua.edu.cn/openeuler/openEuler-22.03-
LTS/ISO/x86_64/openEuler-22.03-LTS-x86_64-dvd.iso

4.2.2.4 Creating a VM Using default and Communicating with External


Networks Using NAT
Step 1 Create VM 01 using default.

[root@localhost opt]# virt-install --name vm01 --virt-type kvm --video vga --memory 1024 --vcpu 1 -
-disk size=8 --cdrom /opt/openEuler-22.03-LTS-x86_64-dvd.iso --network network=default --graphics
vnc,listen=0.0.0.0,port=5900,password=123456 --noautoconsole

Parameters

--virt-type Specifies the name of the management program.


--cdrom CDROM Specifies the optical disc drive installation media.
--memory MEMORY Specifies the memory.
--vcpus VCPUS Specifies the number of virtual CPUs.
--noautoconsole Do not automatically try to connect to the guest console.
--disk DISK Specifies storage with various options. For example, the disk size is 10
GB.
--network NETWORK Specifies network interfaces. For example:
--network bridge=mybr0
--network network=my_libvirt_virtual_net
--graphics GRAPHICS Configures the display settings of guest machines.

1. View the ID of virtual network console (VNC).

[root@localhost opt]# virsh vncdisplay vm01


:0

2. Run a VNC login tool, enter the management IP address (192.168.3.117), and the
port number (5900), and click OK.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 101

Figure 4-33 Logging in to VNC


3. Install the operating system as described in section 4.2.2.2.
Note: If VM 01 is shut off after being rebooted, run the virsh start vm01 command to
manually start it.

Step 2 Verify the connectivity of VM 01.

1. Log in to VM 01 using VNC, view the current IP address, and test the connectivity
with external networks.
Alternatively, run the following commands to view the IP address of VM 01 on the host
VM and log in to VM 01 using SSH.

[root@server ~]# virsh domifaddr vm01


name MAC address Protocol Address
-------------------------------------------------------------------------------
vnet0 52:54:00:a2:f0:37 ipv4 192.168.122.39/24
[root@server ~]# ssh 192.168.122.39

2. After logging in to the VM using VNC, run the ip addr command to view the current
IP address.

Figure 4-34 Viewing the current IP address


HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 102

Note: The default network is in NAT mode, the specified bridge is virbr0, and the IP
address obtained by the VM is the one configured in the address pool for default.
3. Test the connectivity with external networks.

Figure 4-35 Testing the connectivity with external networks

4.2.2.5 Changing default to test and Enabling the VM to Communicate


with External Networks Using NAT
Step 1 Create test and specify the new bridge virbr1.

1. Change default and generate an XML file for test.


Before change

[root@localhost opt]# virsh net-edit default


<network>
<name>default</name> #Changing the value to test
<uuid>504fd670-7a5c-45e9-8034-2a78959734ef</uuid> #Changing two digits
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/> #Changing virbr0 to virbr1
<mac address='52:54:00:1b:53:3b'/>
<ip address='192.168.122.1' netmask='255.255.255.0'> #Changing it to the new IP address
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/> #Changing it to the new address pool
</dhcp>
</ip>
</network>

After change

<network>
<name>test</name> #The name has been changed to test.
<uuid>504fd670-7a5e-75e9-805e-2a78959734ef</uuid> #The UUID has been changed.
<forward mode='nat'/>
<bridge name='virbr1' stp='on' delay='0'/> #The designated bridge has been changed to
virbr1.
<mac address='52:54:00:1b:53:3b'/>
The <ip address='192.168.100.1' netmask='255.255.255.0'> #IP address has been changed.
<dhcp>
<range start='192.168.100.2' end='192.168.100.254'/> #The address pool has been modified.
</dhcp>
</ip>
</network>
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 103

After change, the test.xml file is generated in /etc/libvirt/qemu/networks/. You can run
the following command to define and start test.

The [root@localhost ~]# virsh net-define /etc/libvirt/qemu/networks/test.xml # Defining the


network from the test.xml file
The [root@localhost ~]# virsh net-start test # starting test
[root@localhost ~]# virsh net-list # Viewing the network list

2. Start the network to check whether virbr1 is automatically generated.


The configuration file is stored in /run/NetworkManager/system-connections.
In this case, you can run the ifconfig command to view the API address of the generated
virbr1 and run the brctl show command to view the generated bridge virbr1.

[root@localhost ~]# brctl show


[root@localhost ~]# ifconfig

Step 2 Change the network of VM 01 to test.

[root@localhost ~]# virsh edit vm01


<interface type='network'>
<mac address='52:54:00:a2:f0:37'/>
<source network='test'/> #Changing default to test
<model type='e1000'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>

 Reboot VM 01.

[root@localhost ~]# virsh destroy vm01


[root@localhost ~]# virsh start vm01

 On the VM 01, run the ip addr command to view the current IP address.
Check whether the IP address is the IP address range of test.

Figure 4-36 Viewing the current IP address


 Test the communication with external networks.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 104

Figure 4-37 Testing the connectivity with external networks

4.2.2.6 Specifying a Bridge to create a VM and Communicate with External


Networks Using Bridges
Step 1 Create virbr2 and specify it to create VM 02 using bridges.

1. Create virbr2, assign the IP address of the original physical interface to it, and bind it
to the physical service interface.

[root@localhost ~]# brctl addbr virbr2


[root@localhost ~]# brctl addif virbr2 enp0s3
[root@localhost ~]# ifconfig enp0s3 0.0.0.0
#After the enp0s3 interface is bound to the bridge, no IP address is required. Set the IP address of
enp0s3 to 0.0.0.0.
[root@localhost ~]# ifconfig virbr2 10.0.2.15 netmask 255.255.255.0
# Assigning the IP address of the original physical interface to virbr2.

2. Specify virbr2 to create VM 02.

[root@localhost ~]# virt-install --name vm02 --virt-type kvm --video vga --memory 1024 --vcpu 1 --
disk size=10 --cdrom /opt/openEuler-22.03-LTS-x86_64-dvd.iso --network bridge=virbr2 --graphics
vnc,listen=0.0.0.0,port=5901,password=123456 --noautoconsole
[root@localhost ~]# virsh vncdisplay vm02
1

3. Log in to the VM using VNC referring to step 1 in Section 4.2.2.4, change the port
number to 5901, and install the OS.

Figure 4-38 Logging in to the VM using VNC


4. View the IP address of VM 02.

Figure 4-39 Viewing the IP address of VM 02


5. Test the connectivity between VM 02 and external networks.
HCIA-Cloud Computing V5.0 Lab Guide (Basic Exercises) Page 105

Figure 4-40 Testing the connectivity with external networks


 Test the connectivity between VM 02 and the host VM.

Figure 4-41 Testing the connectivity with the host VM

4.3 Quiz
In KVM virtualization, what are the differences between NAT networks and bridged
networks in assigning IP addresses to VMs?
Answer:
NAT networks use the address pool configured on the corresponding network to assign IP
addresses to VMs. Bridged networks use the address segment of the physical interface or
bridge interface to allocate addresses to VMs.

You might also like