LFCS · Question #225
What does the following iptables rule accomplish: iptables A INPUT s 208.77.188.166 d 10.142.232.1 p tcp dport 22 j ACCEPT
The correct answer is C. Forwards all requests from the host 208.77.188.166 on port 22 the internal host 10.142.232.1. This iptables rule permits TCP traffic on destination port 22, originating from 208.77.188.166 and destined for 10.142.232.1, to be accepted.
Question
Options
- AAccepts traffic on port 22 only from the hosts 208.77.188.166 and 10.142.232.1.
- BForwards all requests from the host 10.142.232.1 on port 22 the internal host 208.77.188.166
- CForwards all requests from the host 208.77.188.166 on port 22 the internal host 10.142.232.1
- DDrops traffic on port 22 only from the hosts 208.77.188.166 and 10.142.232.1.
How the community answered
(17 responses)- A6% (1)
- B6% (1)
- C88% (15)
Why each option
This `iptables` rule permits TCP traffic on destination port 22, originating from 208.77.188.166 and destined for 10.142.232.1, to be accepted.
The rule specifies a single source IP (`-s`) and a single destination IP (`-d`), not traffic from two sources or to two destinations.
This rule is in the `INPUT` chain, which processes traffic destined for the local machine, not for forwarding to another internal host. Also, the source and destination IPs are reversed from the interpretation given.
The `iptables -A INPUT` command adds a rule to the `INPUT` chain. The `-s 208.77.188.166` specifies the source IP, `-d 10.142.232.1` specifies the destination IP (of the local machine), `-p tcp` specifies the TCP protocol, and `--dport 22` specifies the destination port 22. The `-j ACCEPT` target means that matching packets are allowed. This effectively allows incoming TCP traffic on port 22 from the specified source to the local host's specified IP.
The `j ACCEPT` target explicitly allows traffic, it does not drop it.
Concept tested: Iptables rule interpretation (source, destination, port)
Source: https://linux.die.net/man/8/iptables
Topics
Community Discussion
No community discussion yet for this question.