Skip to main content

UFW Quiz

Q1 (Easy)

  1. What is the main purpose of UFW in Linux?

A. Manage users and groups

B. Manage firewall rules

C. Monitor system logs

D. Compress and extract files

Your answer?

You:

B

ChatGPT:

Correct!

Explanation:

UFW stands for Uncomplicated Firewall. It is used to manage firewall rules in Ubuntu/Linux, controlling incoming and outgoing network connections for security. Therefore, B is the correct answer.

Q2 (Easy)

  1. Which command is used to check whether UFW is active or not?

A. ufw -v

B. ufw enable

C. ufw status

D. ufw allow

Your answer?

You:

C

ChatGPT:

Correct!

Explanation:

ufw status shows whether the UFW firewall is active or inactive and displays the current firewall rules. So C is correct.

Q3 (Easy)

  1. Which command will enable UFW on a WordPress VPS for the first time?

A. sudo ufw start

B. sudo ufw running

C. sudo ufw load

D. sudo ufw enable

Your answer?

You:

B

ChatGPT:

Incorrect.

Correct Answer: D. sudo ufw enable

Explanation:

  • sudo ufw enable is the correct command to activate UFW on a Linux server.
  • Option B (sudo ufw running) doesn’t exist in UFW.
  • Option A (ufw start) is wrong because UFW does not use “start” like system services.
  • Option C (ufw load) is also invalid.

So the correct answer is D.

Q4 (Medium)

  1. When you enable UFW on a fresh WordPress VPS, what is the default behavior?

A. All incoming connections allowed, outgoing blocked

B. All incoming connections blocked, outgoing allowed

C. All connections allowed

D. UFW deletes all network access

Your answer?

You:

D

ChatGPT:

Incorrect.

Correct Answer: B. All incoming connections blocked, outgoing allowed

Explanation:

By default, UFW is set to:

  • Deny all incoming traffic (to protect the server)
  • Allow all outgoing traffic (so the server can update packages, connect out, etc.)

So the default policy is:

Default: deny (incoming), allow (outgoing)

This is why UFW is safe to enable, because you can later open needed ports (like SSH, HTTP, HTTPS).

Q5 (Medium – WordPress VPS)

  1. Before enabling UFW on a VPS that uses SSH, what rule must you add first to avoid being locked out?

A. ufw allow ftp

B. ufw allow ssh

C. ufw allow 22/tcp

D. Both B and C are correct

Your answer?

You:

D

ChatGPT:

Correct!

Explanation:

To prevent locking yourself out of the server when enabling UFW, you must allow SSH first. Both commands work:

ufw allow ssh # Uses service name (port 22 by default)ufw allow 22/tcp # Uses port number directly

So the correct answer is D. Both B and C are correct

Q6 (Medium)

  1. Which command is used to allow HTTP (port 80) traffic for a WordPress website?

A. ufw allow http

B. ufw allow 8080

C. ufw allow 80/tcp

D. Both A and C are correct

Your answer?

You:

D. Please explain what is tcp

ChatGPT:

Correct again!

Explanation:

To allow web traffic on port 80 (HTTP), UFW accepts either:

ufw allow http # uses predefined service nameufw allow 80/tcp # allows HTTP over TCP protocol

So D is correct.

What is TCP?

TCP stands for Transmission Control Protocol. It is one of the main protocols used on the internet.

| Feature | Description | | | | | Purpose | Moves data between devices reliably | | Connection type | Connection-based (handshake before data transfer) | | Reliability | Ensures data arrives correctly and in order | | Use cases | Web traffic (HTTP/HTTPS), email, SSH, FTP, MySQL |

When we write:

ufw allow 80/tcp

It means: “Allow connections to port 80 using the TCP protocol,” which is standard for websites.

If needed, I can give more explanation about TCP vs UDP after the quiz. Just say “Explain more TCP later.”

Q7 (Medium)

  1. If your WordPress site uses HTTPS, which UFW rule should be added?

A. ufw allow 443/tcp

B. ufw allow https

C. ufw allow ssl

D. Both A and B are correct

Your answer?

You:

D

ChatGPT:

Correct again!

Explanation:

HTTPS uses port 443 over TCP, and UFW supports both service name and port syntax, so both commands are valid:

ufw allow https # service nameufw allow 443/tcp # port number + protocol

So D. Both A and B are correct

Q8 (Medium)

  1. Which command shows numbered UFW rules so you can delete them later?

A. ufw status

B. ufw numbered

C. ufw status verbose

D. ufw status numbered

Your answer?

You:

C. I just guest it please explain it

ChatGPT:

Incorrect — but good guess. Let’s break it down.

Correct Answer: D. ufw status numbered

Explanation

To view active firewall rules in UFW, we use:

| Command | Description | | | | | ufw status | Shows rules only | | ufw status verbose | Shows rules + default policies | | ufw status numbered | Shows rules with numbers | | ufw delete <number> | Delete a rule by number |

Example:

sudo ufw status numbered

Output:

[ 1] 22/tcp ALLOW Anywhere[ 2] 80/tcp ALLOW Anywhere[ 3] 443/tcp ALLOW Anywhere

Numbering is useful when deleting specific rules:

sudo ufw delete 2 # Deletes rule 2 (port 80)

Summary of Options

| Option | Correct? | Why | | | | | | A – ufw status | | No numbering | | B – ufw numbered | | Invalid command | | C – ufw status verbose | | Verbose info but no numbers | | D – ufw status numbered | | Shows rule numbers |

Ready for the next one?

Q9 (Medium – WordPress Security)

  1. Your WordPress admin /wp-login.php is being attacked by brute-force bots. Which UFW rule helps slow them down?

A. ufw deny 80/tcp

B. ufw limit ssh

C. ufw limit 22/tcp

D. ufw limit 80/tcp

Your answer?

You:

C. I guest please explain it

ChatGPT:

Incorrect — but you’re close.

Correct Answer: D. ufw limit 80/tcp

Explanation

ufw limit is used to rate-limit connections — it allows connections but blocks IPs that connect too many times in a short time (helps prevent brute-force attacks).

  • Port 80/tcp is used for HTTP (WordPress login traffic if not using HTTPS).
  • So rate-limiting HTTP traffic helps reduce brute-force attacks on /wp-login.php.

Example:

sudo ufw limit 80/tcp

This means:

Allow normal visitors

Block bots that spam too many login requests

Note: If your website uses HTTPS, you’d limit 443/tcp instead of port 80.

Why other answers are wrong

| Option | Why it’s wrong | | | | | A. ufw deny 80/tcp | Blocks website completely | | B. ufw limit ssh | Limits SSH, not WordPress | | C. ufw limit 22/tcp | Same as B (SSH only) | | D. ufw limit 80/tcp | Correct – rate limits web traffic |

Bonus Tip

For HTTPS WordPress sites:

sudo ufw limit 443/tcp

Ready for next?

Q10 (Medium)

  1. Which command removes a specific rule by its number from UFW?

A. ufw delete rule 2

B. ufw remove 2

C. ufw delete 2

D. ufw rm rule 2

Your answer?

You:

Before continue what difference between limit vs fail2 ban

ChatGPT:

Great question. Many people confuse UFW limit with Fail2Ban, but they are not the same and serve different purposes.

Quick Comparison: ufw limit vs Fail2Ban

| Feature | ufw limit | Fail2Ban | | | | | | Purpose | Simple rate-limiting | Full intrusion prevention system | | Protection level | Basic | Advanced | | Works on | Network ports only | Log-based attacks (SSH, WP login, XMLRPC, etc.) | | Ban logic | Blocks IP if too many connections per minute | Monitors logs and bans on suspicious behavior | | Custom rules | Very limited | Highly customizable | | WordPress brute-force protection | Weak | Strong | | Installation | Built-in | Separate installation | | Recommended for production? | Not enough alone | Yes |

How they work differently

UFW limit example

sudo ufw limit 80/tcp
  • Allows traffic but rate-limits rapid connections
  • If too many requests come from one IP → temporarily blocks it
  • Good for basic bot filtering

Fail2Ban example

sudo fail2ban-client status sshd

Fail2Ban checks log files like /var/log/auth.log or /var/log/nginx/error.log for suspicious patterns:

  • Too many failed logins
  • SQL injection attempts
  • wp-login.php attacks
  • XMLRPC brute force
  • Slowloris attacks

and automatically bans attackers using UFW/iptables.

Which one should I use for a WordPress VPS?

Recommended setup:

Use both together for layered security.
  • ufw limitbasic firewall rate limit
  • Fail2Ban → intelligent attack detection & bans

Simple Security Stack Recommendation

| Security Layer | Tool | | | | | Firewall | UFW | | Login brute-force protection | Fail2Ban | | WordPress hardening | Limit login attempts, disable xmlrpc | | Web app firewall | Cloudflare or ModSecurity | | Antivirus | ClamAV / ImunifyAV |

If you want later, I can create a comparison with commands and use cases for WordPress. Just say:

“Give deeper comparison UFW vs Fail2Ban”

Ready to continue Quiz?

Last question was:

Q10 (Medium)

  1. Which command removes a specific rule by its number from UFW?

A. ufw delete rule 2

B. ufw remove 2

C. ufw delete 2

D. ufw rm rule 2

Your answer?

You:

A

ChatGPT:

Incorrect.

Correct Answer: C. ufw delete 2

Explanation

UFW allows deleting rules using their number from the output of:

ufw status numbered

Example:

[ 1] 22/tcp ALLOW Anywhere[ 2] 80/tcp ALLOW Anywhere[ 3] 443/tcp ALLOW Anywhere

To delete rule number 2:

sudo ufw delete 2

Why other options are wrong

| Option | Why it’s wrong | | | | | A. ufw delete rule 2 | Incorrect syntax | | B. ufw remove 2 | Invalid command | | C. ufw delete 2 | Correct | | D. ufw rm rule 2 | No rm in UFW |

Ready for the next?

Q11 (Medium – Practical)

  1. After allowing SSH, HTTP, and HTTPS, what is a common best practice before enabling UFW?

A. Reboot the server

B. Add FTP rule

C. Set default policies (deny incoming, allow outgoing)

D. Delete all firewall rules

Your answer?

You:

C

ChatGPT:

Correct!

Explanation:

Before enabling UFW on a server, especially a production server like a WordPress VPS, you should set the default policies:

sudo ufw default deny incoming
sudo ufw default allow outgoing

This ensures:

  • All incoming traffic is blocked by default (good security)
  • Outgoing traffic is allowed (so server updates work)
  • Only ports you explicitly allow can be accessed

Q12 (Medium)

  1. Which UFW command allows traffic from a specific IP address only?

Example: Allow SSH access from only 192.168.1.10

A. ufw allow from 192.168.1.10 to any port 22

B. ufw permit 192.168.1.10:22

C. ufw allow 22 from 192.168.1.10

D. ufw accept from 192.168.1.10 to ssh

Your answer?

You:

A

ChatGPT:

Correct!

Explanation:

To allow access only from a specific IP to a port like SSH (port 22), UFW uses this syntax:

ufw allow from 192.168.1.10 to any port 22

This is useful for security—for example, allowing SSH only from your home IP or Office IP.

Quick Tip for WordPress VPS Security

For better SSH security:

ufw allow from <your-ip-address> to any port 22
ufw deny 22/tcp # Block everyone else

This blocks anyone except your IP from SSH access.

Q13 (Medium)

  1. Which command blocks a single IP address from accessing your VPS entirely?

A. ufw reject 192.168.1.10

B. ufw drop 192.168.1.10

C. ufw deny from 192.168.1.10

D. ufw block ip 192.168.1.10

Your answer?

You:

C

ChatGPT:

Correct!

Explanation:

To block a specific IP from accessing your server completely, you use:

ufw deny from 192.168.1.10

This blocks all connections from that IP. It’s useful when you detect malicious IPs attacking your WordPress login or sending spam requests.

Quick Tip

To block bots by IP range:

ufw deny from 192.168.1.0/24

Blocks the whole network 192.168.1.*.

Q14 (Medium – WordPress Scenario)

  1. Your WordPress server uses SSH on custom port 2581. Which UFW rule allows this port safely?

A. ufw allow ssh

B. ufw allow 2581

C. ufw allow 2581/tcp

D. ufw enable 2581/tcp

Your answer?

You:

C

ChatGPT:

Correct!

Explanation:

If you change your SSH port from 22 to a custom port like 2581, you must allow it in UFW with TCP protocol:

ufw allow 2581/tcp

This is the safest way because SSH always uses TCP, not UDP.

Correct answer: C

Q15 (Medium – Concept)

  1. What is the difference between allow and limit in UFW?

A. limit blocks everything, allow doesn’t

B. allow opens port fully, limit rate-limits to reduce abuse

C. limit is for download speed

D. Both are the same

Your answer?

You:

B

ChatGPT:

Correct again!

Explanation:

  • ufw allow opens access to a port normally
  • ufw limit allows access BUT rate-limits repeated connections to protect against abuse like SSH brute-force or WordPress login bots

Example:

ufw allow 22/tcp # Open SSHufw limit 22/tcp # Safer for SSH (prevents brute-force)

Answer: B

Q16 (Medium – Syntax)

  1. How do you disable UFW completely?

A. ufw stop

B. ufw shutdown

C. ufw delete

D. ufw disable

Your answer?

You:

A

ChatGPT:

Incorrect.

Correct Answer: D. ufw disable

Explanation

To turn off UFW firewall completely, you must run:

sudo ufw disable
  • Option A: ufw stop → Invalid command (UFW doesn’t use stop)
  • Option B: ufw shutdown → Doesn’t exist
  • Option C: ufw delete → Used to delete a rule, not disable firewall
  • D is correct and safe to remember

If UFW is disabled:

  • Your server will no longer block unwanted traffic
  • All security rules will be inactive
  • Use only for troubleshooting, not for production

Q17 (Medium – Real Server Case)

  1. After changing SSH port to 2581 in /etc/ssh/sshd_config, you enabled UFW but now you are locked out of SSH. What did you most likely forget?

A. ufw reload

B. ufw allow 22/tcp

C. ufw allow 2581/tcp

D. ufw status verbose

Your answer?

You:

C

ChatGPT:

Correct!

Explanation:

If you changed your SSH port to 2581 and then enabled UFW without allowing that port, you will be disconnected from your server and locked out.

To prevent this, you should always run:

ufw allow 2581/tcp

before enabling UFW.

Security Tip

For custom SSH ports, best practice is:

ufw allow from <your-IP> to any port 2581 proto tcp
ufw deny 22/tcp

This keeps SSH locked to your safe IP.

Q18 (Medium – Networking Logic)

  1. What happens if you add this rule before enabling UFW?
ufw allow from 203.0.113.5 to any port 22

A. Allows SSH from any IP

B. Blocks SSH completely

C. Allows SSH only from IP 203.0.113.5

D. Deletes SSH access

Your answer?

You:

A

ChatGPT:

Incorrect.

Correct Answer: C. Allows SSH only from IP 203.0.113.5

Explanation

This rule:

ufw allow from 203.0.113.5 to any port 22

means:

Allow SSH access only from the specific IP 203.0.113.5

All other IPs will be denied by default firewall policy

Why other answers are wrong

| Option | Why it’s wrong | | | | | A. Allows SSH from any IP | No, rule is restricted by IP | | B. Blocks SSH completely | It allows specific IP | | C. Allows SSH only from IP 203.0.113.5 | Correct | | D. Deletes SSH access | No |

This is a best security practice for SSH. Always restrict SSH to trusted IPs.

Example for production server:

ufw allow from <your-home-ip> to any port 22 proto tcp

Ready for next

Q19 (Hard – WordPress Security)

  1. Your WordPress site is under attack by bots from Russia (RU) and China (CN). Can UFW block traffic by country?

A. Yes, using ufw deny country

B. Yes, using ufw geo-block

C. Yes, but only using iptables or external tools

D. No, Linux cannot block countries

Your answer?

You:

C

ChatGPT:

Correct!

Explanation:

UFW does not support country blocking directly. To block countries like China or Russia, you must use iptables with geoip modules or external tools like:

xtables-addons

ipset

crowdsec

csf (ConfigServer Firewall)

Cloudflare Firewall (recommended for WordPress)

Example using ipset (not UFW):

ipset create china hash:net
ipset add china 43.132.0.0/16
iptables -A INPUT -m set --match-set china src -j DROP

Most WordPress servers use Cloudflare instead for geo-blocking:

Easier

Zero server load impact

Better protection

Works even before the attack reaches your VPS

Q20 (Medium)

  1. What is the correct UFW command to allow MySQL remote access on port 3306 only from a specific IP?

A. ufw allow 3306/tcp

B. ufw allow mysql

C. ufw allow from 192.168.1.10 to any port 3306

D. ufw enable mysql 192.168.1.10

Your answer?

You:

A

ChatGPT:

Incorrect.

Correct Answer: C. ufw allow from 192.168.1.10 to any port 3306

Explanation

  • MySQL runs on port 3306 by default.
  • Allowing it globally with ufw allow 3306/tcp (Option A) is dangerous because it exposes your database to the internet — big security risk.
  • Best practice is to allow MySQL only from a trusted IP, such as another application server or your local machine.

Correct and secure way:

ufw allow from 192.168.1.10 to any port 3306

This means:

  • Only IP 192.168.1.10 can access your MySQL
  • All other IPs are blocked
  • Your database stays protected

Why other answers are wrong

| Option | Why it’s wrong | | | | | A. ufw allow 3306/tcp | Exposes MySQL to everyone (unsafe) | | B. ufw allow mysql | Same as A but using service name | | C. Allowed from specific IP only | Secure (best practice) | | D. ufw enable mysql 192.168.1.10 | Invalid syntax |

Ready for next?

Q21 (Hard – UFW Logic)

  1. If you run these commands in this order:
ufw default deny incoming
ufw allow 80/tcp
ufw deny 80/tcp

What will happen to port 80?

A. Port 80 will be allowed

B. Port 80 will be denied

C. UFW will crash

D. Both rules cancel each other

Your answer?

You:

B

ChatGPT:

Correct!

Explanation:

UFW processes rules in order, and the last matching rule wins.

So when you run:

ufw default deny incoming
ufw allow 80/tcp
ufw deny 80/tcp
  • First line blocks all incoming traffic by default
  • Second line opens port 80
  • Third line overrides it and blocks port 80 again

Final result: port 80 is blocked

Important rule in UFW:

The last rule applied takes priority if two rules conflict.

Ready for the next?

Q22 (Hard – Network Range)

  1. Which command allows the IP range 192.168.0.0/24 to SSH into your server?

A. ufw allow from 192.168.0.0/24 to any port ssh

B. ufw allow ssh from 192.168.0.0/24

C. ufw allow net 192.168.0.0/24 ssh

D. ufw allow 192.168.0.0/24:22

Your answer?

You:

A

ChatGPT:

Correct!

Explanation:

To allow access from an IP range or subnet in UFW, we use CIDR notation. Example:

ufw allow from 192.168.0.0/24 to any port ssh

This means:

  • Allow SSH access (port 22) from the entire subnet 192.168.0.0 – 192.168.0.255
  • Useful when many devices access SSH from the same network (office, team, VPN)

Why others are wrong

| Option | Why wrong | | | | | A | Correct | | B | Invalid syntax | | C | net is not valid in UFW | | D | Bad format |

Ready for the next?

Q23 (Hard – WordPress Protection)

  1. What UFW rule helps reduce XML-RPC attacks on WordPress?

A. ufw deny 21/tcp

B. ufw limit 80/tcp

C. ufw limit 443/tcp

D. Both B and C

Your answer?

You:

B

ChatGPT:

Correct (Partially) – but let’s clarify deeper.

Correct Answer: D. Both B and C

Explanation

XML-RPC attacks target xmlrpc.php in WordPress over HTTP (port 80) or HTTPS (port 443). So to slow down brute-force login attacks and DDoS-style abuse, you can use UFW rate limiting.

These commands help:

ufw limit 80/tcp # Rate limit HTTPufw limit 443/tcp # Rate limit HTTPS

So the best answer is D (Both B and C) because:

  • Most WordPress sites use HTTPS (443)
  • Some still use HTTP (80)
  • Limiting only port 80 is not enough

Important Security Note

UFW only rate limits traffic—not block botnets completely.

For stronger WordPress protection:

Disable XML-RPC if not needed

Use Fail2Ban WordPress jail

Use Cloudflare WAF rules

Use security plugin like Wordfence (with care), iThemes Security, or Patchstack

Ready for Question 24?

Q24 (Hard – UFW Rule Priority)

  1. You created these UFW rules:
ufw allow 80/tcp
ufw deny from 45.155.205.0/24 to any port 80

What is the result?

A. Port 80 is fully open

B. All traffic to port 80 is blocked

C. Port 80 is open but blocked for IP range 45.155.205.0/24

D. UFW will delete both rules

Your answer?

You:

C

ChatGPT:

Correct!

Explanation:

These two rules together mean:

ufw allow 80/tcp
ufw deny from 45.155.205.0/24 to any port 80
  • The first rule opens port 80 for everyone.
  • The second rule blocks port 80 only for that IP range.
  • So the result is: Your website works normally, but is blocked for IPs in the range 45.155.205.0/24 (this range is often used by bots).

Best answer: C

Q25 (Medium – Service Names)

  1. Which of the following UFW rules will NOT work?

A. ufw allow https

B. ufw allow OpenSSH

C. ufw allow http

D. ufw allow wordpress

Your answer?

You:

D

ChatGPT:

Correct!

Explanation:

UFW supports service names that exist in /etc/services, such as:

| Service Name | Port | | | | | ssh or OpenSSH | 22 | | http | 80 | | https | 443 | | ftp | 21 |

But WordPress is not a network service, it runs on HTTP/HTTPS, so UFW does not recognize wordpress as a valid service name. That makes:

ufw allow wordpress

Invalid command.

Correct way to allow WordPress traffic is either:

ufw allow http
ufw allow https

Q26 (Hard – Interface-Based Rules)

  1. Which UFW rule allows HTTP traffic only on network interface eth0?

A. ufw allow on eth0 80/tcp

B. ufw allow in on eth0 to any port 80

C. ufw allow 80/tcp interface eth0

D. ufw allow from eth0 to 80/tcp

Your answer?

You:

D

ChatGPT:

Incorrect.

Correct Answer: B. ufw allow in on eth0 to any port 80

Explanation

UFW can filter traffic based on network interface, such as:

  • eth0 – main public network interface
  • eth1 – secondary interface
  • lo – loopback (local)

To allow only HTTP traffic on eth0, use:

ufw allow in on eth0 to any port 80

Breakdown:

  • allow → allow traffic
  • in → inbound traffic
  • on eth0 → only for this interface
  • to any port 80 → only HTTP

Why other answers are wrong

| Option | Why it’s wrong | | | | | A. ufw allow on eth0 80/tcp | Missing direction (in) | | B. Correct | Correct syntax | | C. ufw allow 80/tcp interface eth0 | Invalid syntax | | D. ufw allow from eth0 to 80/tcp | Wrong logic, interfaces aren’t used with from |

Ready for the final 4 questions?

Q27 (Hard – Firewall Safety)

  1. You accidentally locked yourself out using UFW and need emergency access. What command resets UFW completely?

A. ufw restart

B. ufw reset

C. ufw unblock all

D. ufw purge

Your answer?

You:

B

ChatGPT:

Correct!

Explanation:

If your UFW rules block your access or break your server network, the emergency reset command is:

sudo ufw reset

This:

Deletes all firewall rules

Restores default settings

Disables UFW safely

You must reconfigure rules again after reset

Emergency Recovery Tip

If SSH is blocked and you’re using a VPS provider (Vultr, Hetzner, DO), you can:

  1. Use web console access from your VPS dashboard

  2. Run:

    ufw reset
    ufw allow ssh
    ufw enable
  3. Connection restored

Q28 (Hard – Outgoing Firewall)

  1. By default, UFW allows all outgoing connections. Which command blocks all outgoing connections for security hardening?

A. ufw deny out all

B. ufw default deny outgoing

C. ufw block outgoing

D. ufw disable outgoing

Your answer?

You:

D

ChatGPT:

Incorrect.

Correct Answer: B. ufw default deny outgoing

Explanation

By default, UFW applies:

Default: deny incomingDefault: allow outgoing

So your server can connect out to the internet freely (for apt updates, wget, curl, etc).

But if you want to lock down outgoing traffic for a hardened security setup:

sudo ufw default deny outgoing

After that, your server cannot connect to the internet unless you allow specific ports.

Example: Safe controlled outgoing rules

If you deny outgoing traffic, you must allow important system ports:

ufw allow out 53 # DNS resolutionufw allow out 80/tcp # HTTPufw allow out 443/tcp # HTTPS (updates & API calls)ufw allow out 25/tcp # Optional: SMTP for email

This is used in high-security servers or PCI-compliant environments.

Why other answers are wrong

| Option | Why it’s wrong | | | | | A ufw deny out all | Invalid syntax | | B ufw default deny outgoing | Correct | | C ufw block outgoing | Not a valid UFW command | | D ufw disable outgoing | Does not exist |

Q29 (Hard – UFW Logging)

  1. Which command enables firewall logging in UFW?

A. ufw log start

B. ufw enable logging

C. ufw logging on

D. ufw default log

Your answer?

You:

B

ChatGPT:

Incorrect.

Correct Answer: C. ufw logging on

Explanation

UFW supports logging firewall activity for monitoring and security diagnostics.

To enable UFW logging:

sudo ufw logging on

To turn logging off:

sudo ufw logging off

You can also set logging levels:

sudo ufw logging low # Defaultsudo ufw logging medium
sudo ufw logging high
sudo ufw logging full

Logs are stored in:

/var/log/ufw.log

Why other options are wrong

| Option | Why wrong | | | | | A. ufw log start | Invalid syntax | | B. ufw enable logging | Not a valid option | | C. ufw logging on | Correct | | D. ufw default log | Invalid command |

Final Question coming up!

Q30 (Hard – VPS Security Firewall Strategy)

  1. What is the best UFW strategy for securing a WordPress VPS?

A. Allow all, deny specific ports

B. Deny all incoming, allow only required ports

C. Disable UFW to improve performance

D. Only allow SSH, block everything else

Your answer?

You:

B

ChatGPT:

Correct – Perfect Final Answer!

Explanation

The best firewall strategy for a WordPress VPS is always:

Deny everything by default
Then allow only what is needed

This is known as a “least privilege” security model — and it looks like this in UFW:

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp # or your custom SSH portsudo ufw allow 80/tcp # HTTPsudo ufw allow 443/tcp # HTTPSsudo ufw enable

Safe

Minimal attack surface

Production-ready firewall

Recommended by security best practices

UFW Quiz Complete!

You answered 22 / 30 correctly73% Score

Difficulty: Mixed (Medium + Hard)

Result: Good command understanding, improving on advanced security logic

Score Breakdown

| Category | Performance | | | | | Basic UFW Commands | Good | | Firewall Concept | Good | | WordPress Security Use Cases | Good | | Advanced UFW Options | Needs practice | | Emergency Firewall Recovery | Good | | Rate-Limiting & Security Layers | Needs deeper understanding |