Courseiva

PEN-200 Port Redirection and Tunneling Practice Question

Exhibit

sshd_config snippet:
AllowTcpForwarding yes
GatewayPorts no
X11Forwarding no

Refer to the exhibit. If you attempt an SSH remote port forward (-R) to bind a port to all network interfaces on the server, what will happen?

⚠ Common exam trap

Candidates assume that specifying 0.0.0.0 in an SSH command overrides server-side configurations, forgetting that 'GatewayPorts no' strictly enforces loopback-only bindings on the remote host.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

The port will be bound to 127.0.0.1 instead of 0.0.0.0.

The 'GatewayPorts no' setting in the sshd_config specifically prevents forwarded ports from binding to any interface other than the loopback (localhost). Even if the user specifies 0.0.0.0 or a public IP in their SSH command, the server will ignore this request and bind the port only to 127.0.0.1. This is a common security hardening measure to prevent unauthorized access to forwarded ports from external networks.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The request will be rejected and the connection will close.

    Why it's wrong here

    The SSH server does not reject the entire connection due to a GatewayPorts configuration. It simply ignores the request to bind to external interfaces and binds to the loopback instead. The connection remains open and the tunnel functions, but it is restricted to the local interface of the server.

  • ✓

    The port will be bound to 127.0.0.1 instead of 0.0.0.0.

    Why this is correct

    Because GatewayPorts is set to 'no', the SSH daemon forces all forwarded ports to bind to the loopback interface, regardless of the user's request. This effectively enforces a security policy where only local processes on the jump host can interact with the forwarded port, preventing external access.

  • ✗

    The server will allow the binding because it is a superuser request.

    Why it's wrong here

    The sshd_config settings apply globally to all users, including superusers. If GatewayPorts is explicitly set to 'no', there is no override provided for privileged users within the configuration file. The daemon will always prioritize the security configuration over the user's specific request for an external interface binding.

  • ✗

    The connection will hang indefinitely.

    Why it's wrong here

    The SSH server processes the configuration check as part of the initial connection setup. There is no mechanism that would cause the connection to hang indefinitely due to this setting. It would either succeed in creating the tunnel (bound to loopback) or fail immediately if other errors were present.

About these practice questions

This PEN-200 question is part of Courseiva's 285-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official OffSec exam blueprint

This PEN-200 practice question is part of Courseiva's free OffSec certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PEN-200 exam.