Courseiva
System SecuritymediumMultiple ChoiceObjective-mapped

LPIC-2 System Security Practice Question

An administrator wants to block all incoming traffic from the IP address 203.0.113.55 except for SSH (port 22) using iptables. The current default policy for the INPUT chain is ACCEPT. Which set of commands achieves this?

⚠ Common exam trap

The trap here is that candidates mistakenly think a drop rule can be placed before an accept rule for the same source, not realizing that iptables stops processing rules after the first match, so the drop rule must come after the specific accept rule.

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

iptables -A INPUT -s 203.0.113.55 -p tcp --dport 22 -j ACCEPT; iptables -A INPUT -s 203.0.113.55 -j DROP

Iptables processes rules in order. The first rule accepts SSH traffic from 203.0.113.55, and the second rule drops all other traffic from that IP. Since the default INPUT policy is ACCEPT, the drop rule must be placed after the SSH allow rule to ensure SSH packets are accepted before being dropped by the subsequent rule.

Answer analysis

Option-by-option breakdown

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

  • iptables -A INPUT -p tcp --dport 22 -s 203.0.113.55 -j ACCEPT -m; iptables -A INPUT -s 203.0.113.55 -j DROP

    Why it's wrong here

    Syntax error: -m without module.

  • iptables -A INPUT -s 203.0.113.55 -j DROP; iptables -A INPUT -s 203.0.113.55 -p tcp -j ACCEPT

    Why it's wrong here

    Drop all first, then accept any TCP (including SSH) but never reached due to DROP.

  • iptables -A INPUT -s 203.0.113.55 -j DROP; iptables -A INPUT -s 203.0.113.55 -p tcp --dport 22 -j ACCEPT

    Why it's wrong here

    Order drops all before SSH rule; SSH will be dropped.

  • iptables -A INPUT -s 203.0.113.55 -p tcp --dport 22 -j ACCEPT; iptables -A INPUT -s 203.0.113.55 -j DROP

    Why this is correct

    First accepts SSH, then drops all other traffic from the IP.

About these practice questions

This LPIC-2 question is part of Courseiva's 507-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LPIC-2 practice question is part of Courseiva's free LPI 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 LPIC-2 exam.