
When used on machines that are not the default gateway of the network, the source address must be changed to be the address of the translating machine, or packets will bypass the translator and the connection will fail. The source address and port are, in this case, left unchanged. When used on gateway devices, a port forward may be implemented with a single rule to translate the destination address and port. BSD and macOS operating systems prior to Yosemite (OS 10.10.X) implement it in the Ipfirewall (ipfw) module while macOS operating systems beginning with Yosemite implement it in the Packet Filter (pf) module. In Linux kernels, this is achieved by packet filter rules in the iptables or netfilter kernel components. Running a publicly available game server within a private LANĪdministrators configure port forwarding in the gateway's operating system.Permitting FTP access to a host on a private LAN from the Internet.Permitting Secure Shell access to a host on the private LAN from the Internet.

Running a public HTTP server within a private LAN.

Typical applications include the following: Often, the port numbers of well-known Internet services, such as port number 80 for web services (HTTP), are used in port forwarding, so that common Internet services may be implemented on hosts within private networks. External hosts must know this port number and the address of the gateway to communicate with the network-internal service. When configuring port forwarding, the network administrator sets aside one port number on the gateway for the exclusive use of communicating with a service in the private network, located on a specific host. The computers behind the router, on the other hand, are invisible to hosts on the Internet as they each communicate only with a private IP address. The NAT device's external interface is configured with a public IP address.

Hosts on the private network are connected to an Ethernet switch or communicate via a wireless LAN. In a typical residential network, nodes obtain Internet access through a DSL or cable modem connected to a router or network address translator (NAT/NAPT). Port forwarding facilitates the connection by remote computers, for example, Internet hosts, to a specific computer or service within a local area network (LAN). This technique is most commonly used to make services on a host residing on a protected or masqueraded (internal) network available to hosts on the opposite side of the gateway (external network), by remapping the destination IP address and port number of the communication to an internal host. In computer networking, port forwarding or port mapping is an application of network address translation (NAT) that redirects a communication request from one address and port number combination to another while the packets are traversing a network gateway, such as a router or firewall.
