Question 78 of 1,000
SecurityhardMultiple ChoiceObjective-mapped

XK0-005 nftables rule syntax Practice Question

This XK0-005 practice question tests your understanding of security. Match the stated requirement to the specific cloud service, access model, or configuration option — many options are valid in isolation but not for this scenario. A key principle to apply: nftables rule syntax. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A server running nftables has a rule set that allows incoming SSH from the management network (192.168.1.0/24). An administrator needs to insert a rule to drop SSH from all other sources. Which nft command accomplishes this? Assume the input chain is 'input' and the table is 'inet filter'.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

nft add rule inet filter input ip saddr != 192.168.1.0/24 tcp dport 22 drop

The correct command is A. The existing rule allows SSH from 192.168.1.0/24. To drop SSH from all other sources, we need a rule that matches packets with source IP address not in that subnet and destination port 22, and then drops them. The `add rule` subcommand appends the rule to the chain, which is appropriate because the allow rule for the management network should remain first. Using `ip saddr != 192.168.1.0/24` properly negates the source subnet. Option B drops SSH from any source (including the management network), which would block the allowed traffic. Option C replaces an existing rule by handle but does not specify the source condition. Option D accepts SSH from all sources, which is not desired. Therefore, A is correct.

Key principle: nftables rule syntax

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • nft add rule inet filter input ip saddr != 192.168.1.0/24 tcp dport 22 drop

    Why this is correct

    This drops SSH from sources not within the management network.

    Related concept

    nftables rule syntax

  • nft insert rule inet filter input tcp dport 22 drop

    Why it's wrong here

    This would drop all SSH, including from management network.

  • nft replace rule inet filter input handle 1 tcp dport 22 drop

    Why it's wrong here

    This replaces a specific rule, but without knowing the handle, it's not appropriate.

  • nft add rule inet filter input tcp dport 22 accept

    Why it's wrong here

    This would accept all SSH, defeating the purpose.

Common exam traps

Common exam trap: answer the scenario, not the keyword

Candidates often confuse 'add' vs 'insert' in nftables. The question says 'insert a rule', but the correct approach is to append a drop rule after the allow rule. Adding the drop rule before the allow rule would make the allow rule irrelevant. 'Add rule' appends, which is correct here.

Detailed technical explanation

How to think about this question

Treat this as a scenario question. Identify the problem, the constraint, and the best action. Then compare each option against those facts.

KKey Concepts to Remember

  • nftables rule syntax
  • IP address negation
  • Rule ordering
  • TCP destination port matching

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

nftables rule syntax

Real-world example

How this comes up in practice

A network engineer segments a warehouse floor into three subnets: 20 scanners, 5 printers, and 2 management hosts. Picking the wrong mask wastes addresses or leaves too few usable hosts. Exam questions test whether you can apply CIDR notation, calculate block size, and identify the correct usable-host range for a given prefix.

Visual reference

192.168.1.0 /24 256 addresses (254 usable) 192.168.1.0 /25 Subnet A 128 addr (126 usable) 192.168.1.128 /25 Subnet B 128 addr (126 usable) Borrowing 1 bit from host portion creates 2 subnets (/25)

What to study next

Got this wrong? Here's your next step.

Review nftables rule syntax, then practise related XK0-005 questions on the same topic to reinforce the concept.

Related practice questions

Related XK0-005 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free XK0-005 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this XK0-005 question test?

Security — This question tests Security — nftables rule syntax.

What is the correct answer to this question?

The correct answer is: nft add rule inet filter input ip saddr != 192.168.1.0/24 tcp dport 22 drop — The correct command is A. The existing rule allows SSH from 192.168.1.0/24. To drop SSH from all other sources, we need a rule that matches packets with source IP address not in that subnet and destination port 22, and then drops them. The `add rule` subcommand appends the rule to the chain, which is appropriate because the allow rule for the management network should remain first. Using `ip saddr != 192.168.1.0/24` properly negates the source subnet. Option B drops SSH from any source (including the management network), which would block the allowed traffic. Option C replaces an existing rule by handle but does not specify the source condition. Option D accepts SSH from all sources, which is not desired. Therefore, A is correct.

What should I do if I get this XK0-005 question wrong?

Review nftables rule syntax, then practise related XK0-005 questions on the same topic to reinforce the concept.

What is the key concept behind this question?

nftables rule syntax

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jul 4, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This XK0-005 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-005 exam.