Skip to Content

CompTIA Linux+ (Plus): What Does the iptables -A INPUT -p tcp –dport 22 -j ACCEPT Command Do?

What does the iptables -A INPUT -p tcp –dport 22 -j ACCEPT command do in Linux? Learn how this iptables rule allows incoming SSH traffic and why it’s essential for secure remote server management—key for CompTIA Linux+ (Plus) XK0-005 exam success.

Table of Contents

Question

What does the iptables -A INPUT -p tcp –dport 22 -j ACCEPT command do?

A. Blocks all SSH traffic
B. Forwards SSH packets to another port
C. Allows incoming SSH traffic
D. Logs all SSH connections
E. Rejects TCP traffic on port 22

Answer

C. Allows incoming SSH traffic

Explanation

This iptables rule appends (-A) a policy to the INPUT chain, accepting (-j ACCEPT) TCP traffic on port 22 (SSH), configuring basic firewall security.

The command iptables -A INPUT -p tcp –dport 22 -j ACCEPT allows incoming SSH traffic to the server.

iptables is the standard Linux firewall utility for managing network traffic rules.

-A INPUT appends a rule to the INPUT chain, which processes incoming packets destined for the local system.

-p tcp specifies the rule applies to TCP protocol traffic.

–dport 22 targets traffic destined for port 22, the default port for SSH connections.

-j ACCEPT tells iptables to accept and allow this traffic through the firewall.

This rule is essential for enabling remote SSH access, allowing administrators to connect to the server for management and troubleshooting tasks.

This iptables rule explicitly permits TCP traffic on port 22, enabling SSH connections to the server.

CompTIA Linux+ (Plus) XK0-005 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the CompTIA Linux+ (Plus) XK0-005 exam and earn CompTIA Linux+ (Plus) XK0-005 certification.