Courseiva
Advanced Networking ConfigurationmediumMultiple ChoiceObjective-mapped

LPIC-2 Advanced Networking Configuration Practice Question

A company has a server with two network interfaces: eth0 (public IP) and eth1 (private IP). The administrator wants to allow SSH from the public network only. Which iptables rule set achieves this?

⚠ Common exam trap

The trap here is that candidates often forget that iptables rules are evaluated in order, so placing a broad DROP rule before a specific ACCEPT rule will cause the DROP to match first, inadvertently blocking the intended traffic.

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 -i eth0 -p tcp --dport 22 -j ACCEPT; iptables -A INPUT -i eth1 -p tcp --dport 22 -j DROP

It explicitly allows SSH (TCP port 22) traffic arriving on the public interface (eth0) and then drops SSH traffic on the private interface (eth1). This ensures SSH is only accessible from the public network while blocking it on the private network. The order of rules matters: the ACCEPT rule for eth0 must come before any default DROP policy or later rules that might affect it.

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 -i eth0 -p tcp --dport 22 -j ACCEPT; iptables -A INPUT -i eth1 -p tcp --dport 22 -j DROP

    Why this is correct

    This allows SSH on eth0 and drops on eth1.

  • iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT

    Why it's wrong here

    This allows SSH on eth0 but does not block on eth1; default policy may accept.

  • iptables -A INPUT -p tcp --dport 22 -j DROP; iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT

    Why it's wrong here

    The drop rule is first, so SSH is dropped on all interfaces before the accept rule is evaluated.

  • iptables -A INPUT -p tcp --dport 22 -j DROP

    Why it's wrong here

    This drops SSH from all interfaces.

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.