From Tanenbaum's Computer Networks:

The general name for a machine that makes a connection between two or more networks and provides the necessary translation, both in terms of hardware and software, is a gateway. Gateways are distinguished by the layer at which they operate in the protocol hierarchy. We will have much more to say about layers and protocol hierarchies starting in the next section, but for now imagine that higher layers are more tied to applications, such as the Web, and lower layers are more tied to transmission links, such as Ethernet.

Since the benefit of forming an internet is to connect computers across net- works, we do not want to use too low-level a gateway or we will be unable to make connections between different kinds of networks. We do not want to use too high-level a gateway either, or the connection will only work for particular ap- plications. The level in the middle that is ‘‘just right’’ is often called the network layer, and a router is a gateway that switches packets at the network layer.

Is "makes a connection between two or more networks" exactly what a router does?

Is "provides the necessary translation" exactly what a NAT does? What is the "translation"?

Does the quote mean a gateway has to be a router and a NAT?

If "translation" means NAT, a router can't be a gateway, because it doesn't do what a NAT does, correct? Or does "translation" mean something strictly in the network layer?


4 Answers 4


Gateway and router are the same thing (here). Router is used when talking about the device, gateway is the function it serves in a network. Gateway may also refer more generally to services in higher layers (including certain types of proxies, protocol converters, and application-level gateways).

Translation in this context refers to adaption to the used layer-2 and layer-1 protocols. Encapsulation and encoding might be more precise. Routers can usually have very different interfaces and route between them, e.g. ATM over DSL or Ethernet.

A normal router is stateless: it treats each packet on its own and does not remember the state of any connection running through it.

NAT is translation scheme used between public and private networks. When used on a router (mostly NAPT) it needs to track the state of each connection (TCP socket state from private srchost:srcport mapped to localip:localport to public dsthost:dstport and so on). Therefore, a NAT router is stateful.

  • Thanks. "A normal router is stateless." What is "state" here?
    – Tim
    Commented Mar 26, 2019 at 22:18
  • 1
    @Tim, that means that a router routes packets individually, regardless of what came before, and with no expectations of what is to come. NAT must build a table to know what has come before, and what is still to come. The table defines the state. For example, a packet originated inside for a certain outside address, and the NAT must remember that so that replies can be delivered back to the originator. Routing doesn't do that, but it is required for NAT. IP is supposed to be end-to-end (only the endpoints maintain a state), but NAT breaks that.
    – Ron Maupin
    Commented Mar 26, 2019 at 22:21
  • @tim Stateless means it doesn't have to remember anything after processing a packet. A NAT router does need to remember the state of each connection it is translating.
    – Zac67
    Commented Mar 26, 2019 at 22:23
  • Thanks. I use the definition in the book for the purpose of understanding it. Also see my update. Is a NAT also a gateway (I am not sure whether a NAT connects more than one networks)? Is a firewall a gateway (I guess not, because a firewall doesn't connect networks)?
    – Tim
    Commented Mar 26, 2019 at 22:24
  • "NAT" is not a device, it's a translation scheme. NAT is often done on a gateway/router but not necessarily so. A firewall can be a router but it can also be transparent to layer 3.
    – Zac67
    Commented Mar 27, 2019 at 7:41

In an IP network, a gateway is the router that allow hosts within this network to reach hosts in other networks.

The translation here doesn't refer to NAT but to the "conversion", if needed, between a layer 2 protocol (like Ethernet) and another layer 2 protocol (like PPP), because not all communicating network use the same technology.


In most cases, a gateway is a router, and routers route packets between networks. There are corner cases of gateways that are not routers, e.g. ALGs (Application Layer Gateways).

NAT is one form of translation, but, for example, ALGs may translate application protocols or data. Routers can route without NAT and still be gateways. A router or firewall is a convenient place to NAT.

Definitions from RFC 1009, Requirements for Internet Gateways:

In this document there are many terms that may be obscure to one unfamiliar with the Internet protocols. There is not much to be done about that but to learn, so dive in. There are a few terms that are much abused in general discussion but are carefully and intentionally used in this document. These few terms are defined here.

  Packet      A packet is the unit of transmission on a physical

  Datagram    A datagram is the unit of transmission in the IP
              protocol.  To cross a particular network a datagram is
              encapsulated inside a packet.

  Router      A router is a switch that receives data transmission
              units from input interfaces and, depending on the
              addresses in those units, routes them to the
              appropriate output interfaces.  There can be routers
              at different levels of protocol.  For example,
              Interface Message Processors (IMPs) are packet-level

  Gateway     In the Internet documentation generally, and in this
              document specifically, a gateway is an IP-level
              router.  In the Internet community the term has a long
              history of this usage [32].
  • Thanks. (1) Since a gateway makes a connection between two or more networks, does it mean a gateway has to work at least as low as in the network layer, and maybe work in higher layer? (2) a router is a gateway. Is a NAT also a gateway (I am not sure whether a NAT connects more than one networks)? Is a firewall a gateway (I guess not, because a firewall doesn't connect networks)?
    – Tim
    Commented Mar 26, 2019 at 22:06
  • Do not make the mistake that the book is definitive. That is the author's interpretation. The real definitions are contained in the standards. For example, RFC 1009, Requirements for Internet Gateways gives definitions of "Router" and "Gateway" from the perspective of IP. These are the definitions most commonly accepted for network engineering, but others, such as software developers, may have a different perspective.
    – Ron Maupin
    Commented Mar 26, 2019 at 22:12
  • Thanks. I use the definition in the book for the purpose of understanding it. Also see my update.
    – Tim
    Commented Mar 26, 2019 at 22:21

A gateway is a network device that sits between two networks and acts as the entry and exit point of those networks. From the perspective within a network, a gateway provides connectivity outside of a network. From the perspective outside of the network, the gateway provide an entrypoint into the network. Furthermore, if the networks the gateway sits between uses different protocols, a gateway would also need to translate from one protocol to another, and vice versa.

A router is a network device that is involved in routing network packets to the correct network. A router operates at the network layer (layer 3) of the OSI model. If a network packet is not intended for the networks for which the router is currently attached, it will forward the packet on to the next network.

A router must be set up as a gateway, as it needs to route/forward packets from within the network to outside of the network.

But not all gateways are routers. Routers work at the network layer, but there are also application gateways that work at the application layer. Whilst routers route request solely based on destination IP addresses, application gateways can determine where the request goes based on data at the application layer (e.g. HTTP request headers and body).

N.B. The "translation" that a gateway may have to do is to translate between different protocols. The "translation" done in NAT is network address translation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.