LX0-104 · Question #226
What does the following iptables rule accomplish: iptables A INPUT d 10.142.232.1 p tcp dport 20:21 j ACCEPT
The correct answer is D. Forwards all traffic on port 20 and 21 to the host 10.142.232.1.. This iptables rule is designed to permit or forward incoming TCP traffic destined for ports 20 and 21 to a specific host on the network.
Question
Options
- AForwards all traffic not on port 20 or 21 to the host 10.142.232.1.
- BDrops all traffic coming from the host 10.142.232.1 destined for port 20 or 21.
- CAccepts all traffic from the host 10.142.232.1 destined for port 20 or 21.
- DForwards all traffic on port 20 and 21 to the host 10.142.232.1.
How the community answered
(28 responses)- A4% (1)
- C7% (2)
- D89% (25)
Why each option
This iptables rule is designed to permit or forward incoming TCP traffic destined for ports 20 and 21 to a specific host on the network.
The rule explicitly matches traffic on ports 20 and 21, not traffic 'not on port 20 or 21'.
The `-j ACCEPT` target allows traffic, it does not drop it, and the rule specifies the destination, not the source IP for the traffic.
The rule specifies `d 10.142.232.1` for destination, not source, meaning traffic *to* this host, not *from* it.
The `iptables -A INPUT` command appends a rule; `-d 10.142.232.1` specifies the destination IP; `-p tcp --dport 20:21` matches TCP traffic for ports 20 to 21 (commonly FTP); and `-j ACCEPT` allows these packets. In a forwarding scenario, this enables the firewall to direct such traffic to the host `10.142.232.1`.
Concept tested: Iptables rule syntax - destination IP, port range, ACCEPT target, and forwarding context
Source: https://man7.org/linux/man-pages/man8/iptables.8.html
Topics
Community Discussion
No community discussion yet for this question.