LFCS Networking Practice Question
A developer needs to temporarily allow incoming TCP connections on port 8080 for testing. Which iptables command adds a rule to the INPUT chain to accept this traffic?
⚠ Common exam trap
A common mix-up: candidates confuse the INPUT chain with the FORWARD chain, or mistakenly think that `--sport` (source port) is appropriate for incoming traffic, when `--dport` (destination port) is required for packets arriving at the local system.
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 -p tcp --dport 8080 -j ACCEPT
The INPUT chain processes traffic destined for the local system, and the `--dport 8080` flag matches incoming TCP packets with destination port 8080. The `-j ACCEPT` target allows these packets through, which is exactly what is needed to temporarily permit incoming TCP connections on port 8080 for testing.
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 OUTPUT -p tcp --sport 8080 -j ACCEPT
Why it's wrong here
This affects outgoing traffic, not incoming.
- ✓
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
Why this is correct
Appends a rule to INPUT chain to accept TCP on port 8080.
- ✗
iptables -A FORWARD -p tcp --dport 8080 -j ACCEPT
Why it's wrong here
This affects forwarded traffic, not locally destined traffic.
- ✗
iptables -I INPUT 1 -p tcp --dport 8080 -j DROP
Why it's wrong here
This inserts a DROP rule at position 1, which would block traffic.
Visual reference
Go deeper
Related to this question
About these practice questions
One of 507 original LFCS 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 LFCS practice question is part of Courseiva's free Linux Foundation 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 LFCS exam.