4

A am a bit confused with routers and gateways.

From my understanding if a client needs to send a packet to another which is not in the same ip segment it sends the packet to the gateway, behind which usually a router takes over. Is this somewhat correct?

But if thats the case, what do I need the gateway for? Or is gateway just a term to describe the default router (I know (or think) that a gateway can also be used to translate between something like ethernet and fiber)? Could I just plug one (or more) routers into a network without specefying a gateway?

5
  • 3
    Router (computing) - Wikipedia
    – DavidPostill
    Commented Jun 9 at 19:26
  • 3
    Gateway (telecommunications) - Wikipedia
    – DavidPostill
    Commented Jun 9 at 19:27
  • 1
    If you don't want to use routers (or gateways) then you need to configure static routes, but that still requires some kind of device in-between that will (sigh) route the packets to the destination. It's unclear to me if we're talking about hardware / physical routing here (i.e. a routing device being present or not, which might not be necessary on radio networks), or software routing.
    – Raf
    Commented Jun 10 at 7:46
  • Also if you have two separate networks on a single router (e.g. 10.0.0.x and 192.168.1.x) then your router will usually have the option to route traffic between those so that the router can act as a 'gateway' for the different ranges. Routers will either offer to add a static route for that or not (and if not, this will keep the two networks unreachable to each other).
    – Raf
    Commented Jun 10 at 7:54
  • The simplest way to think about this are gateways are paths to WAN, with the modem providing the router's WAN interface the default gateway IP address for sending traffic out through WAN. What makes a router a router is that they're capable of doing NAT and have a stateful firewall, whereas devices that can route network traffic, but can't do NAT and don't have a stateful firewall are switches. Switches are "dumb", "managed", or "smart", and managed and smart switches have UIs for configuring them, offering capabilities like vLANs, vLAN tagging, and VPNs that run downstream of a router.
    – JW0914
    Commented Jun 10 at 13:07

6 Answers 6

9

From my understanding if a client needs to send a packet to another which is not in the same ip segment it sends the packet to the gateway, behind which usually a router takes over. Is this somewhat correct?

It starts off correct, but all devices along the path an IP packet takes are actually the same kind of thing1 and all of them can be called either 'gateways' or 'routers'.

That is, "the gateway" refers to a router just like the next one it passes the packet to, but the emphasis is on "the gateway" as in short for "default gateway/router for this particular sender", and that's the one place where the term 'gateway' remains in common use – while the device itself is usually called a 'router'.

1 [This is deliberately not counting devices that are invisible to IP, e.g. switches or bridges or modems, because an IP packet doesn't interact with them but travels straight through them, so they're irrelevant to the topic.]

But if thats the case, what do I need the gateway for? Or is gateway just a term to describe the default router

In this case "gateway" is literally another term for a router, and "default gateway" is the router that's specified in your default route (some systems call it "gateway of last resort").

From what I've learned, ARPANET used to call every such system a "gateway" at first, but switched to "router" as the main term in the early days because the term "gateway" also had plenty of other meanings – prior to IP, the term would've been primarily associated with systems whose job was to forward between different kinds of networks (e.g. there used to be products that were gateways between IP and Novell IPX networks); there used to be mail gateways (e.g. relaying email between Internet and BITNET); and so on. Whereas a "router" specifically meant a device that selects routes for packets.

The term still remains in use, both in the original sense and in a slightly more general sense; a router can be your gateway to some network; the next-hop router for routes in the routing table is almost always called the gateway.

(I know (or think) that a gateway can also be used to translate between something like ethernet and fiber)?

Not quite; those are two different functions that just happen to be bundled into a single unit.

The usual term for a device that translates Ethernet to GPON is either "ONT" or "ONU" (for "optical network terminal/unit"), whereas if it converts copper-Ethernet to fiber-Ethernet then it is just a "media converter". (Most residential fiber connections are GPON, but larger companies are more likely to get fiber-Ethernet.)

Many ISPs, however, bundle the GPON ONT and the IP router into a single device (probably easier for the customer to deal with a single piece of equipment than two), and therefore the same physical box happens to act both as your IP "default gateway" and as your "fiber translator", though those remain two separate tasks.

It's a lot like how Wi-Fi is often bundled together with a router, resulting in a "wireless router" – but it's not the "router" part that does wireless.

Could I just plug one (or more) routers into a network without specefying a gateway?

Generally speaking, no, as routers are only useful if hosts know that they need to use them. If host A needs to reach network B, it needs to be somehow told that it has to send packets through the router (gateway) AB or something such. It might not necessarily be your default gateway, though – it could be the gateway for a specific route towards just that network – but without any host being set up to use it as a gateway for something, it'll just sit there doing nothing.

There is a large exception: Routers can implement proxy-ARP where they allow hosts to pretend that remote addresses are actually local – host A just sends an ARP query for whatever address it wants, and the router answers on its behalf – in which case you indeed do not need to specify any gateways on the hosts involved. (This was common practice for a long time, e.g. it's how subnetting was done before "subnet masks" were a thing, but now it is rare.)

5

what do I need the gateway for

In the context of Ethernet, typically you need it when the destination host is not in the a broadcast domain the host is directly attached to.

which is not in the same ip segment

More precisely, you need it when a (destination) IP address can't be "resolved" to a MAC address by the means of ARP (or NDP).

Instead of resolving the destination's IP address, the gateway's IP address would be resolved. The traffic would then be "L2 forwarded" to the corresponding router by the relevant switch(es) and be "L3/IP forwarded" by the router to (normally) another broadcast domain (or some non-Ethernet network). (To give a simple idea on what "IP forwarding" is, I suppose one can say it is "IP routing" that is performed by a host/router for traffics from another host.) These resolution are triggered by "hit(s)" on indirect routes, i.e., routes that consists of a gateway (IP) address.

With typical / normal configuration, your "local subnets" are the destination blocks that would be covered by direct routes, which consists of no (real) gateway IP address and would hence result in ARP resolution (in the case of Ethernet; via the respective route interface) for the destination IPs themselves, and each broadcast domain would only use one IP subnet. However, technically you can add direct route for arbitrary destination, or use multiple IP subnets within a broadcast domain. (Not that it normally makes sense to though.)

Often the word gateway alone is used to refer to one of the IP addresses of a router -- the one that is configured on the interface that is attached to "our" broadcast domain (e.g. "LAN IP" of a home router is the "gateway" for the "WAN side" / Internet, from the perspective of a LAN host). Therefore, I would say that you can somewhat see it as a word that refers to "a piece" of the router (especially when the usual router symbols look like cakes) -- the piece that "belong" to "our" broadcast domain, whereas the word router is more often used to refer the device / host as a whole. (I'm sure a lot of people would say something like "that is not the (orthodox) definition of the word gateway", and I'm not saying it is either. What I'm saying is, often that seems to be why you would "see router here and gateway there", while at the same time some people just use the two words interchangeably.)

P.S. A router would have multiple interfaces and hence multiple IP addresses configured on it. Therefore, you can more or less say that a router "is composed of multiple gateways", but at the same time, each of the gateways (IP addresses) can be used to refer to the router (regardless of which broadcast domain is the "context").

5

A router is a device that forwards between networks. A gateway is a forwarder within the local network, allowing communication with another network.

Essentially, both are the very same thing, just the perspective varies.

if a client needs to send a packet to another which is not in the same ip segment it sends the packet to the gateway, behind which usually a router takes over.

If you understand the gateway as the IP address/interface you pass data to other networks to, and the router as the device that interface is attached to, then that is basically correct.

what do I need the gateway for?

You need a gateway to communicate with hosts that are not part of your local subnet.

Or is gateway just a term to describe the default router

The default gateway or default router for the default route is the gateway you pass data that you don't have a better route for. Basic hosts use only a default gateway to pass all their non-local traffic to. More complex hosts may use a number of different gateways with more specific routes.

a gateway can also be used to translate between something like ethernet and fiber)?

Not only the medium (copper, fiber, wireless, virtual), physical layer protocol (Ethernet, xDSL, 802.11, avian carrier, ...), but also the data link layer (IEEE 802 family, ATM, FDDI, ...) can be vastly different behind a gateway. The beauty of it is that you don't need to care, only that it supports IP. There's no real translation, just changing underlying networks.

Could I just plug one (or more) routers into a network without specifying a gateway?

Routers generally need some kind of configuration - but you can use a very simple configuration if you don't connect to larger networks or the global Internet.

3
  • 1
    only that it supports IP It might be worth mentioning that though, in some cases, like L3 VPN (point to point link, basically), "gateway" in the context of a route is not really a thing, because there's just "the other end" (although the link could still "branch off" in some sense, like client-to-client + iroute in OpenVPN).
    – Tom Yan
    Commented Jun 9 at 23:29
  • A virtual link is just one of the examples for not having to care what is beyond a gateway.
    – Zac67
    Commented Jun 10 at 6:46
  • @TomYan: That's true, but I think that's getting far too much into the technical weeds for OP's question at this time. Commented Jun 10 at 8:51
4

Gateway and Router are pretty much the same thing ..

The term "gateway" might be older.

And also the term "gateway" might be more the idea of routing between just two networks. So not really any complex routing decision, just if something comes in one port then it either doesn't go out(maybe it shouldn't have been sent there in the first place), or it goes out the other port.

Whereas the term "router" in some peoples minds might be more for routing involving more than two networks. So if a packet comes in one port, then if it should have gone in there, then it's destined for one of the other ports, and a routing decision is made in that regard.

Some people refer to some common devices many have at home ("home routers"), as "NAT Router", when the routing aspect is in the "gateway" sense, in the sense of just two ports. Technically most such devices people have are a router with two ports and a network switch internally connected to one of the ports. So when you see all the ports it might look a bit like a fully fledged router but it isn't a fully fledged router.. so some call it a "NAT Router". It does NAT functionality and Router functionality, and has a network switch built into it.

But an "expensive" router / device which everybody would happily call a router, will route to more than just two networks.

A relevant document is here RFC 1009 " Requirements for Internet Gateways"

https://www.tech-invite.com/y10/tinv-ietf-rfc-1009.html

"In the Internet documentation generally, and in this document specifically, a gateway is an IP-level router." (a router isn't necessarily IP, there are other possible network level / level 3, protocols, but IP is of course very common).

and

"A router is a switch that receives data transmission units from input interfaces" (calling a router a switch might be a bit problematic, since a switch tend to be defined as a level 2 device and a router is defined as being a level 3 device, but anyhow")

So i've taken issue with those quotes a bit but point is a gateway is a router. (with some possible distinction maybe relating to gateway being an older term, and related to gateway being just two ports).

The idea you mention of your computer sending it to your "NAT Router" which is a gateway and then the packets go to routers.. Those routers would be big routers with multiple ports. And they'd connect different vast networks.

The term "router" refers to a functionality, "does routing".

Notice also that document RFC 1009, "Requirements for Gateways"

has been obsoleted by RFC 1812 "Requirements for IP Version 4 Routers" (written in 1995)

https://www.tech-invite.com/y15/tinv-ietf-rfc-1812.html

it says

"Many older Internet documents refer to these devices as gateways, a name which more recently has largely passed out of favor to avoid confusion with application gateways."

(Note- an "application gateway" is not a gateway or a router https://en.wikipedia.org/wiki/Application-level_gateway )

Clearly the term "Gateway" is an old term that has been replaced by the term "Router". (which would include anything that the term "Gateway" referred to).

I notice that the ipconfig command even in Windows 11, (almost 30 years - and will be over 30 years - after the RFCs obsoleted/recommended against the term!), still uses the term "Gateway" / "Default Gateway" !

1
  • The following is not that relevant but As a side note, Funnily enough there might almost be a similar thing with the terms Bridge and "Network switch". Both are L2. But Bridge might suggest just two ports. Whereas switch has more than2. Both do "switching"/"bridging". One other distinction though between the terms bridge and switch.. is maybe4 a bridge a network medium might b different or potentially different. And another side note, there's a term flying around at one point of "layer 3 switch". That's an abuse of the term switch. It's a router. IIRC there was some marketting issue there
    – barlop
    Commented Jun 10 at 15:46
2

the short answer is YES, if youre talking about a domestic router but you dont have a Gateway, that means you dont have a way to go beyond your local network, in this case you could use the router as a switch but this means you can only have communication with your local segment or LAN.

router is the device which can handle IP traffic (L3) whats different from a switch which can only handle frames and MAC Address and doesnt have the capacity to route IP traffic.

the Gateway is just the same thing of a router, its just the way we call the router whats going to give a way out to go to another networks like internet, when you are trying to reach an IP that doesnt belonges to your LAN segment then its packet is routed through the gateway, it could be your ISP... where the packet will be routed again and again until it find its destination, the way to check how many times is routed a packet is by using the command tracert, it gives useful information to understand how is routed a packet, every IP address in this case is a router where the packet is passed through, they are also called hops, because a packet jump between each one to another.

1

One way to think of this, as I haven't seen it mentioned here, are older seperated modem/router set-ups.

The modem is the part of the network that translates the often analog medium of communication to digital communication and vice versa (exchanging digital signals into analog). This is the "Gateway." The part of the network actively exchanging information with an ISP to deliver an IP Address. You can access the internet through these without a router, however only one device at a time. (Modems/Simple Gateways cannot associate more than one IP, as their only job is to deliver a live public IP, connecting to the internet this way is NOT recommended).

The router is usually what you'd connect to the modem next (in fact, some ISPs modems force a router to be connected nowadays, for securities sake). It is the router's job to provide Wi-Fi and extra ethernet ports, as well as providing basic network protections for the local network. This is done by creating a LAN network, or a type of intranet. This allows more than one "private" IP to connect behind your "public" one. Which uses the router's direct modem access for internet access. A router cannot be used without a gateway, as all the router is doing is creating the local network, and allowing a oublic network to be associated with the private one. (If used without a gateway, a LAN connection will still be built, but no internet access will be available for any connected device, only LAN connections will be functional).

Sometimes you'll find router/modem combination boxes. These perform both tasks in one box. Connecting and communicating with the ISP directly, while also hosting the LAN private network. Some people mistakenly refer to these as the "router" or "modem" when really they're both!

5
  • This is the "Gateway." I'm not so sure if the word has ever actually been used to refer to a modem. I think the story was more like, when things were still new to home users (or laymen, if I may) and home router (standalone or not) wasn't even a thing yet, some people might have thought that the word refers to the modem when they hear some "professionals" or so said it, while the professional really meant the router managed by the ISP (basically the "WAN gateway" these days, assuming your router is directly connected to the ISP). I do admit though I don't really know about dialup/PPP(oE)...
    – Tom Yan
    Commented Jun 10 at 7:03
  • What's interesting (but also somewhat unfortunate?) is that, as things develop, home router, and "modem/router", become a thing, and the misunderstanding sort of become a fact, as in, the "gateway" in more/most concern (the "LAN gateway", which "wasn't a thing", or actually, the "WAN" these days was the "LAN") could reside in the device that is also a modem...
    – Tom Yan
    Commented Jun 10 at 7:14
  • "The modem [...] is the "Gateway." - No, it isn't. The gateway is the default router for a client. The modem does not route, so it is not a gateway. It just translates one physical medium to another. When you connect a client directly to a modem, the gateway is some router at the ISP, outside your house.
    – marcelm
    Commented Jun 10 at 10:11
  • The modem IS the gateway. A router controls traffic within a network, whereas a gateway connects various networks. You could I guess call the router a "type of gateway" because it's transmitting data similarly but that just isn't true. It only appears that way because your router is routing data through itself to access the modem. That's the point of the router. The modem intrinsically connects your LAN (which the router splits into multiple ports and Wi-Fi if enabled) to the ISPs WAN. Obviously your modem is a small piece of the bigger picture, but to YOU that's the gateway. Commented Jul 5 at 1:57
  • On another note, modems CAN transmit data without a router. This doesn't require a "router" on the ISPs side either because these ISPs already have a connection to you through the lines. (Likely through a NAP server). The point of the modem is to provide 1 device, and 1 device only, an internet IP address. This is because not every device can have an IP address or we'd run out. So, the modem converts the ISP signal into one a PC can understand. Obviously having only 1 device isn't ideal, so that's where the router comes in. It acts as "the 1 device" and transmits it's connection to others. Commented Jul 5 at 2:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .