Skill 2 3 Solutions
Skill 2 3 Solutions
To install the httpd package from the Red Hat Network (or any other configured
repository) using the dnf package manager:
Install the package: Use the dnf command to install the httpd package.
Command:
$ sudo dnf install httpd
2. How would you update the httpd package to the latest version available in the
configured remote repository using dnf? Provide the command.
To update the httpd package to the latest version available in the configured
remote repository, you can use the following command:
Command:
This command checks for updates to the httpd package and installs the latest
version if available.
Solution:
Refer Book-2 RH-134 Chapter-8 page no: 251
Skill week 3
Securing a Linux system with firewalld involves configuring various firewall rules and
settings. firewalld is a dynamic firewall management tool that provides a front-end to
iptables and nftables. It uses the concept of zones to define the trust level of network
connections.
1. Checking Firewalld Status
To check whether firewalld is active and running:
$ sudo systemctl status firewalld
To start firewalld if it's not running:
$ sudo systemctl start firewalld
2. Listing Available Zones
Zones define the level of trust for network connections. To list all available zones:
$ sudo firewall-cmd --get-zones
3. Creating a Custom Zone
You can create a custom zone to define specific firewall rules:
$ sudo firewall-cmd --permanent --new-zone=myzone
Replace myzone with your desired zone name. The --permanent flag ensures the
changes persist across reboots.
4. Configuring the Custom Zone by Adding a Service
To allow a service, like httpd (web server), in the custom zone:
sudo firewall-cmd --zone=myzone --add-service=http --permanent
Replace myzone with the name of your custom zone. This command allows HTTP
traffic.
5. Opening a Port
To open a specific port, such as port 8080, in the custom zone:
$ sudo firewall-cmd --zone=myzone --add-port=8080/tcp --permanent
This command opens TCP port 8080.
6. Setting the Default Zone
To set the default zone, which applies to all network interfaces not explicitly
assigned to a different zone:
$ sudo firewall-cmd --set-default-zone=myzone
7. Assigning Interfaces to a Zone
To assign a specific network interface (e.g., eth0) to a custom zone:
sudo firewall-cmd --zone=myzone --change-interface=eth0 --permanent
This command moves the eth0 interface to the myzone zone.
8. Restricting Access by Blocking a Specific IP and Allowing Specific IPs Only
To block a specific IP address (e.g., 192.168.1.100):
$ sudo firewall-cmd --zone=myzone --add-rich-rule="rule family='ipv4' source
address='192.168.1.100' reject" --permanent
To allow only specific IP addresses (e.g., 192.168.1.101 and 192.168.1.102) and
block all others:
$ sudo firewall-cmd --zone=myzone --add-rich-rule="rule family='ipv4' source
address='192.168.1.101' accept" --permanent
$ sudo firewall-cmd --zone=myzone --add-rich-rule="rule family='ipv4' source
address='192.168.1.102' accept" --permanent
$ sudo firewall-cmd --zone=myzone --add-rich-rule="rule family='ipv4' reject" --
permanent
9. Listing All Active Rules and Zones
To list all active zones:
$ sudo firewall-cmd --get-active-zones
To list all rules in a specific zone:
$ sudo firewall-cmd --zone=myzone --list-all
Replace myzone with the name of your zone to see the rules and settings for that
zone.
Applying Changes
After making changes with the --permanent flag, reload firewalld to apply them:
$ sudo firewall-cmd --reload
This reloads the firewall configuration, making the permanent changes effective
immediately.
These commands and steps help secure your Linux system by managing network
traffic and restricting access based on your defined rules.