Skip to topic
    ← Back to course topics

    Port forwarding — AQA A-Level Computer Science

    Port forwarding is a network address translation (NAT) technique that directs external Internet traffic destined for a specific public IP address and port number to an internal private IP address and port within a local area network (LAN). This mechanism allows remote devices to access local server applications, such as web servers or game hosts, while keeping the rest of the private network hidden behind a firewall.

    Port forwarding explained

    Port forwarding is a rule configured on a router, usually as part of NAT, that directs incoming traffic arriving on a specific port of the router's public IP address to a specific internal device and port on the private network.

    Read the full explanation

    Because NAT normally only translates connections initiated from inside the network, an external host cannot reach a server inside the network without a rule telling the router where to send the traffic. When a request arrives at the public address on a chosen port, such as port 80 for web traffic, the router rewrites the destination address and port so the packet reaches the intended internal host. A concrete example is a rule sending traffic arriving on public port 8080 to internal address 192.168.1.10 on port 80.

    Your focus

    1. Explain the basic concept of port forwarding

    Port forwarding exam tips

    Topic Overview

    Port forwarding is a network management technique used in conjunction with Network Address Translation (NAT) to route external communications from the Internet to a specific device or service residing on a private local area network (LAN). It operates at the network and transport layers of the TCP/IP stack to inspect destination IP addresses and port numbers.

    Understanding port forwarding is essential for modern networking, systems architecture, and cybersecurity within the AQA A-Level syllabus. It illustrates how firewalls control ingress traffic and how limited IPv4 public address spaces are bypassed to host accessible services securely.

    Key Concepts
    • →Distinction between private IP addressing (RFC 1918) and globally routable public IP addressing.
    • →Role of the transport layer port number in demultiplexing network traffic to specific application processes (e.g., port 80 for HTTP, port 443 for HTTPS, port 22 for SSH).
    • →Header rewriting: The router modifies the destination IP address (and optionally the destination port) from the public value to the internal private host values.
    • →Security implications: Port forwarding bypasses default firewall blocking for specified ports, creating potential entry vectors for unauthorised external access if services are unpatched.
    Marking Points
    • Describes port forwarding as a router rule that redirects incoming traffic on a given port to an internal device
    • Explains that NAT normally only handles connections initiated from inside the network, so a rule is needed for inbound access
    • Identifies the mapping from a public address and port to an internal address and port
    • Gives a concrete example such as forwarding traffic on one port to a specified internal host and port
    Examiner Tips
    • 💡Explain that the rule is configured on the router and applies to incoming traffic
    • 💡Name one example port and one internal address to show the mapping clearly
    • 💡State that port forwarding allows an internal server to be reached from outside the network
    • 💡State explicitly which fields in the packet header change: the destination IP is translated from the router's public IP to the server's private IP.
    • 💡Always specify transport protocols (TCP or UDP) and default standard port numbers when citing examples (such as HTTP 80, HTTPS 443, or SSH 22) to gain precision marks.
    Common Mistakes
    • Describes port forwarding as opening every port on the router; correct it by stating that a rule maps one specific port to one specific internal device
    • Says port forwarding sends traffic from inside the network to the internet; correct it by explaining that it handles incoming traffic from external sources
    • Confuses the port number with the IP address; correct it by stating that the rule maps both an address and a port
    • Believing that port forwarding changes the source IP address; in inbound port forwarding, the router modifies the destination IP to route to the internal device, while the source IP remains that of the external client.
    • Assuming that multiple internal hosts can use the same external port without port mapping; external ports must be unique per public IP to ensure the router knows which internal device to target.
    Revision Plan
    1. 1Day 1: Review IPv4 address classes, private versus public IP ranges, and standard TCP/UDP port allocations.
    2. 2Day 2: Diagram packet traversal for outbound NAT versus inbound port forwarding, highlighting IP and port header modifications.
    3. 3Day 3: Practice multi-host scenarios involving port translation (mapping non-standard external ports to default internal ports).
    4. 4Day 4: Attempt past AQA exam questions focusing on network routing, NAT, and network security trade-offs.
    Exam Question Types
    • 📋Trace and explain questions: Describe the changes made to packet headers as a packet moves from an external client to an internal host.
    • 📋Scenario configuration questions: Given a network diagram with IP addresses, explain how to configure port rules for multiple services.
    • 📋Evaluative questions: Discuss the security risks of opening ports on a router versus using a Virtual Private Network (VPN).
    Command Word Expectations (AQA)
    Explain

    Set out the causes, reasons, or mechanisms clearly. For port forwarding, mention packet headers, router NAT tables, public vs private IPs, and port redirection.

    Describe

    State the key characteristics or steps in order. For networking, recount the chronological journey of the packet across the boundaries.

    How Students Lose Marks (Examiner Pitfalls)
    Pitfall: Confusing standard Network Address Translation (NAT) with Port Forwarding.
    ❌ Weak Answer (Loses Marks):Port forwarding translates private IP addresses to public IP addresses so computers can browse the Internet.
    Example improved answer:While outbound NAT maps multiple private IP addresses to a single public IP address to allow internal hosts to initiate outbound traffic, port forwarding specifically configures a router or firewall to inspect incoming packets on a designated port and redirect that external traffic to a specific private IP address and internal port on the LAN.
    Examiner Tip: Always specify the direction of traffic: port forwarding addresses incoming connections initiated from outside the private network to a service hosted internally.
    Pitfall: Failing to explain the role of port numbers in packet routing.
    ❌ Weak Answer (Loses Marks):The router receives the data and sends it to the computer that needs it based on its IP.
    Example improved answer:Packets arriving at the router contain the router's external public IP address and a destination port number. The router references its NAT routing table to match that specific destination port number to the configured internal private IP address and target port of the host machine, rewriting the destination headers accordingly.
    Examiner Tip: Mention both layers of addressing: IP addresses define host locations, while port numbers identify the specific application or service on that host.
    Step-by-Step Worked Solutions

    Question: An organisation hosts an internal web server with private IP address 192.168.1.50 running on port 80. The network router has a public IP address of 203.0.113.10. Explain how an external client accesses this web server and how port forwarding directs the packet. [4 marks]

    1. 1.Step 1: The external client sends an HTTP request packet destined for the router's public IP address (203.0.113.10) on destination port 80.
    2. 2.Step 2: The packet arrives at the router's external interface, passing through the firewall rule that permits incoming port 80 traffic.
    3. 3.Step 3: The router consults its port forwarding configuration table, which maps incoming requests on port 80 to the internal destination 192.168.1.50:80.
    4. 4.Step 4: The router modifies the destination IP address in the packet header to 192.168.1.50 and forwards the frame across the local network to the web server.
    Final Answer: The external client addresses the router's public IP address (203.0.113.10:80). The router inspects its port forwarding table, rewrites the destination IP header to the internal private IP (192.168.1.50:80), and forwards the packet directly to the internal web server across the LAN.

    Question: A network technician needs to allow remote desktop access (using default port 3389) to two separate machines with private IPs 10.0.0.5 and 10.0.0.6 via a single public IP 198.51.100.2. Explain how port forwarding can be configured to achieve this. [3 marks]

    1. 1.Step 1: Identify that a single public IP cannot route the identical external destination port 3389 to two distinct private IPs simultaneously.
    2. 2.Step 2: Assign distinct external port numbers on the router to differentiate traffic (e.g., external port 3389 for machine 1 and external port 3390 for machine 2).
    3. 3.Step 3: Map external port 3389 to 10.0.0.5:3389 and external port 3390 to 10.0.0.6:3389 in the router's NAT table so the router redirects each unique port request to the correct host.
    Final Answer: Configure port mapping using different external ports: map public IP 198.51.100.2 on port 3389 to private IP 10.0.0.5:3389, and map 198.51.100.2 on port 3390 to private IP 10.0.0.6:3389. The router translates both the port and IP as packets arrive.
    Active Recall Memory Test
    What header fields does a router modify when executing inbound port forwarding?
    Key Fact: The destination IP address (from the router's public IP to the host's private IP) and optionally the destination port number.
    Why is port forwarding necessary when hosting a server behind a NAT-enabled router?
    Key Fact: Because private IP addresses are non-routable over the public Internet, external clients cannot address internal servers directly.
    What transport layer component identifies the target application when an IP packet reaches a host?
    Key Fact: The port number.
    Frequently Asked Questions
    What is the difference between port forwarding and port triggering?
    Port forwarding permanently opens an inbound port and statically maps it to a specific internal device. Port triggering is dynamic: an internal host initiates outbound traffic on a designated trigger port, which causes the router to temporarily open an inbound port for return traffic and route it to that specific host.
    Does port forwarding make my network vulnerable to hackers?
    Yes, it increases the attack surface. Port forwarding tells your firewall to let unsolicited incoming traffic bypass its default drop rule on that port. If the software listening on that port has security flaws, default credentials, or lacks encryption, attackers can compromise the host.
    Can two computers on the same private network host services using the same port?
    Yes, internally both can listen on the same port (e.g., 80) because their private IP addresses differ. However, from the outside, the router only has one public IP address. To access both from the Internet, the router must map two distinct external ports (e.g., 8080 and 8081) to the respective internal machines on port 80.
    Is port forwarding the same as a DMZ?
    No. Port forwarding selectively routes only specific ports (like TCP port 80) to an internal device while blocking others. A demilitarized zone (DMZ) or DMZ host setting on consumer routers redirects all unsolicited inbound traffic on every non-forwarded port to a single designated host machine.