XK0-005 · Question #798
A technician wants to temporarily use a Linux virtual machine as a router for the network segment 10.10.204.0/24. Which of the following commands should the technician issue? (Choose three.)
The correct answer is A. echo "1" > /proc/sys/net/ipv4/ip_forward B. iptables -A FORWARD -j ACCEPT G. iptables -t nat -s 10.10.204.0/24 - A POSTROUTING -j MASQUERADE. To configure a Linux VM as a router, IP forwarding must be enabled, and iptables rules are needed to permit packet forwarding and perform network address translation (NAT) for the specified network segment.
Question
A technician wants to temporarily use a Linux virtual machine as a router for the network segment 10.10.204.0/24. Which of the following commands should the technician issue? (Choose three.)
Options
- Aecho "1" > /proc/sys/net/ipv4/ip_forward
- Biptables -A FORWARD -j ACCEPT
- Ciptables -A PREROUTING -j ACCEPT
- Diptables -t nat -s 10.10.204.0/24 -p tcp -A PREROUTING -j MASQUERADE
- Eecho "0"> /proc/sys/net/ipv4/ip_forward
- Fecho "1" > /proc/net/tcp
- Giptables -t nat -s 10.10.204.0/24 - A POSTROUTING -j MASQUERADE
- Hiptables -t nat -A PREROUTING -j MASQUERADE
How the community answered
(40 responses)- A73% (29)
- C3% (1)
- D15% (6)
- F3% (1)
- H8% (3)
Why each option
To configure a Linux VM as a router, IP forwarding must be enabled, and `iptables` rules are needed to permit packet forwarding and perform network address translation (NAT) for the specified network segment.
`echo "1" > /proc/sys/net/ipv4/ip_forward` enables IP forwarding in the Linux kernel, which is essential for a machine to act as a router and forward packets between network interfaces.
`iptables -A FORWARD -j ACCEPT` adds a rule to the `FORWARD` chain to allow all forwarded packets. This is necessary for routing traffic between interfaces that are not destined for the router itself.
`iptables -A PREROUTING -j ACCEPT` is generally incorrect for simple forwarding as `PREROUTING` is for modifying incoming packets before routing decisions, and blindly accepting there is usually not the correct approach for routing.
`iptables -t nat -s 10.10.204.0/24 -p tcp -A PREROUTING -j MASQUERADE` uses `PREROUTING` for NAT, which is typically for Destination NAT (DNAT), not Source NAT (SNAT)/MASQUERADE, which belongs in `POSTROUTING`. Also, specifying `-p tcp` restricts it unnecessarily.
`echo "0" > /proc/sys/net/ipv4/ip_forward` disables IP forwarding, which would prevent the VM from acting as a router.
`echo "1" > /proc/net/tcp` is not a valid command for configuring IP forwarding or firewall rules; `/proc/net/tcp` provides information about TCP connections, not a configuration interface.
`iptables -t nat -s 10.10.204.0/24 -A POSTROUTING -j MASQUERADE` configures Network Address Translation (NAT) using `MASQUERADE` in the `POSTROUTING` chain for packets originating from the 10.10.204.0/24 network. This allows devices on the private network segment to access external networks using the router's external IP address.
`iptables -t nat -A PREROUTING -j MASQUERADE` uses `PREROUTING` for MASQUERADE without specifying a source, which is generally incorrect for Source NAT, as `MASQUERADE` is usually applied in `POSTROUTING`.
Concept tested: Linux routing, IP forwarding, iptables NAT, packet filtering
Source: https://man7.org/linux/man-pages/man8/iptables.8.html
Topics
Community Discussion
No community discussion yet for this question.