LPIC-2 System Security Practice Question
An administrator wants to drop incoming TCP packets on port 22 from IP 10.0.0.5 using iptables. Which command is correct?
⚠ Common exam trap
Many candidates confuse the `-s` (source) and `-d` (destination) flags, or mistakenly apply the rule to the FORWARD or OUTPUT chain instead of the INPUT chain, failing to understand the packet flow through iptables chains.
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 10.0.0.5 -p tcp --dport 22 -j DROP
It adds a rule to the INPUT chain, which processes packets destined for the local system. The `-s 10.0.0.5` flag specifies the source IP address, `-p tcp --dport 22` matches TCP packets destined for port 22 (SSH), and `-j DROP` silently discards matching packets. This configuration drops incoming SSH traffic from the specified host before it reaches any local service.
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 -d 10.0.0.5 -p tcp --dport 22 -j DROP
Why it's wrong here
The -d flag specifies destination IP; for incoming packets, the source should be 10.0.0.5.
- ✗
iptables -A FORWARD -s 10.0.0.5 -p tcp --dport 22 -j DROP
Why it's wrong here
The FORWARD chain affects forwarded traffic, not incoming packets to the host.
- ✗
iptables -A OUTPUT -s 10.0.0.5 -p tcp --dport 22 -j DROP
Why it's wrong here
The OUTPUT chain affects outgoing packets, not incoming.
- ✓
iptables -A INPUT -s 10.0.0.5 -p tcp --dport 22 -j DROP
Why this is correct
This correctly matches incoming packets from 10.0.0.5 to port 22 and drops them.
Go deeper
Related to this question
About these practice questions
One of 507 original LPIC-2 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
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.