nerdexam
CompTIA

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.

System Management

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)
  • A
    73% (29)
  • C
    3% (1)
  • D
    15% (6)
  • F
    3% (1)
  • H
    8% (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.

Aecho "1" > /proc/sys/net/ipv4/ip_forwardCorrect

`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.

Biptables -A FORWARD -j ACCEPTCorrect

`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.

Ciptables -A PREROUTING -j ACCEPT

`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.

Diptables -t nat -s 10.10.204.0/24 -p tcp -A PREROUTING -j MASQUERADE

`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.

Eecho "0"> /proc/sys/net/ipv4/ip_forward

`echo "0" > /proc/sys/net/ipv4/ip_forward` disables IP forwarding, which would prevent the VM from acting as a router.

Fecho "1" > /proc/net/tcp

`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.

Giptables -t nat -s 10.10.204.0/24 - A POSTROUTING -j MASQUERADECorrect

`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.

Hiptables -t nat -A PREROUTING -j MASQUERADE

`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

#Linux Networking#IP Forwarding#iptables#NAT

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice