XK0-006 practice question 14 of 15

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? (Select three).

Full set: 149 questions
Answer options
A: echo "1" > /proc/sys/net/ipv4/ip_forward Correct answer
B: iptables -A FORWARD -j ACCEPT Correct answer
C: iptables -A PREROUTING -j ACCEPT
D: iptables -t nat -s 10.10.204.0/24 -p tcp -A PREROUTING -j MASQUERADE
E: echo "0" > /proc/sys/net/ipv4/ip_forward
F: echo "1" > /proc/net/tcp
G: iptables -t nat -s 10.10.204.0/24 -A POSTROUTING -j MASQUERADE Correct answer
H: iptables -t nat -A PREROUTING -j MASQUERADE
Correct Answer:
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
Explanation

To function as a router, a Linux system requires three configurations. First, IP forwarding must be enabled in the kernel, which is done by writing "1" to /proc/sys/net/ipv4/ipforward (A). Second, the firewall must be configured to allow traffic to pass between interfaces; a simple rule to permit this is iptables -A FORWARD -j ACCEPT (B). Third, to allow the private network to access external networks, Source NAT (SNAT) must be configured. iptables -t nat -A POSTROUTING -j MASQUERADE (G) achieves this by translating the source IP of packets from the specified subnet as they leave the router.

Why Incorrect

C: The PREROUTING chain is used for Destination NAT (DNAT), not for allowing traffic forwarding. D: MASQUERADE is a source NAT action and must be in the POSTROUTING chain, not PREROUTING. E: This command disables IP forwarding, which is the opposite of the required action. F: The /proc/net/tcp file is used to view active TCP connections, not to configure routing. H: The MASQUERADE target must be applied in the POSTROUTING chain, not PREROUTING.

References

1. The Linux Kernel Documentation. Documentation/networking/ip-sysctl.txt. The entry for ipforward in /proc/sys/net/ipv4/ describes it as the master switch for enabling or disabling packet forwarding.

2. iptables(8) Linux manual page. The "TABLES" section describes the nat table's POSTROUTING chain for altering packets "as they are about to go out." The "TARGETS" section describes MASQUERADE for SNAT.

3. Red Hat Enterprise Linux 7 Documentation. (2023). Networking Guide. Chapter 21, "Network Address Translation," Section 21.2, "IP Forwarding and Masquerading," provides a procedure that includes enabling ipforward and using iptables with POSTROUTING and MASQUERADE.

Scroll to Top