A gateway is a network node that connects two systems using different protocols, data formats, or architectures to enable communication between them. Serving as an entry and exit point for data moving across disparate networks, it translates protocols and converts data so otherwise incompatible environments can interoperate. Unlike standard routers that remain confined to the network layer (L3), gateways can operate at any layer of the OSI model depending on the translation required.
How it works
When data arrives at a gateway, the node inspects the incoming traffic and strips away the control information, headers, and protocol-specific framing of the source network. It then translates the payload or address structure and re-encapsulates the data to match the requirements of the destination network. This bridge allows legacy infrastructures to communicate with modern IP networks and links private data centers to public cloud environments.
In hosting and DevOps architectures, gateways typically fall into a few functional roles:
- Default Gateway: The routing interface used by a host to forward packets destined for IP addresses outside its local subnet.
- API Gateway: An application-layer entry point that routes client requests to backend microservices while handling authentication, rate limiting, and TLS termination.
- Cloud Gateway: A secure bridge connecting on-premises hardware to cloud storage, compute, or virtual private networks.
- NAT Gateway: A network address translation service that lets instances in private subnets initiate outbound internet connections without exposing them to unsolicited inbound traffic.
Example
In a cloud environment such as AWS or Azure, application servers often live in private subnets without public IP addresses. To allow those servers to download security patches via apt-get or yum without opening inbound ports to the public internet, administrators route outbound traffic through a NAT Gateway.
On a Linux host inside a private subnet, you can inspect the active routing table to verify which gateway handles external traffic:
ip route show
default via 10.0.1.1 dev eth0 proto dhcp src 10.0.1.45 metric 100
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.45
Here, any packet not destined for the local 10.0.1.0/24 subnet is forwarded to 10.0.1.1, which passes external requests onward to the NAT Gateway. The gateway maps the private source IP to a single public IP for the outbound session and drops any unsolicited inbound packets.
What matters when choosing a server or hosting
- Throughput and packet rate: Because all cross-network traffic passes through the gateway, insufficient network interface bandwidth or CPU capacity for packet inspection quickly creates a bottleneck.
- High availability: A single gateway instance represents a single point of failure. Production setups require redundant gateways across multiple availability zones or failover routing protocols such as VRRP.
- Managed vs. self-hosted: Cloud providers offer managed NAT and API gateways that scale automatically, whereas bare-metal or VPS environments require configuring and maintaining software like HAProxy, Envoy, Nginx, or Linux
iptables/nftablesyourself. - Latency overhead: Deep packet inspection, TLS termination, and protocol conversion add processing time. Place gateways geographically and logically close to the workloads they serve.
Common mistakes
- Exposing an API gateway without rate limiting: Leaving an edge gateway unthrottled allows traffic spikes or abusive clients to overwhelm downstream microservices.
- Routing internal traffic through a NAT gateway: Sending traffic meant for internal cloud storage or databases through an internet-bound NAT gateway adds unnecessary latency and often incurs avoidable data-processing fees.
- Misconfigured subnet routes: Pointing a private subnet's default route directly to an internet gateway instead of a NAT gateway accidentally exposes private instances if public IPs are attached.
FAQ
What is the difference between a router and a gateway?
A router forwards packets between networks that share the same protocol stack, operating at Layer 3 (the network layer) using IP addresses. A gateway can operate up through Layer 7 (the application layer) to translate between different protocols, data formats, or network architectures.
Can a single server act as both a firewall and a gateway?
Yes. Many Linux-based network appliances and cloud gateways combine routing, network address translation, and packet-filtering firewall rules on the same node to control and translate traffic at the network boundary.
Why use an API gateway instead of a standard load balancer?
A standard load balancer distributes traffic across identical backend servers at the transport or HTTP level. An API gateway provides finer application-level control, including path-based microservice routing, token authentication, request transformation, and per-client rate limiting.