The iptables command is used to configure firewall rules in Linux.To allow packets from a specific source (192.168.10.22) to the server, we must append a rule to the INPUT chain:
iptables -A INPUT -s 192.168.10.22 -j ACCEPT
Explanation of the command:
-A INPUT → Appends a rule to the INPUT chain (incoming traffic).
-s 192.168.10.22 → Specifies the source IP address.
-j ACCEPT → Accepts the packet and allows communication.
Why the other options are incorrect?
A. iptables -L -s 192.168.10.22 -j ACCEPT → Incorrect, -L is used to list rules, not to add them.
B. iptables -D INPUT -s 192.168.10.22 -j ACCEPT → Incorrect, -D is used to delete a rule, not add one.
D. iptables -A OUTPUT -S 192.168.10.22 -j ACCEPT → Incorrect, -A OUTPUT affects outgoing packets, but we need to accept incoming packets.
Persisting the Rule:
To make the rule persistent after a reboot, it must be saved:
iptables-save > /etc/iptables/rules.v4
[References:, CompTIA Linux+ Official Documentation, iptables Documentation – Netfilter, , ]