What's the difference between a gateway and a router?

A gateway and a router are essentially the same. The term "default gateway" is used to mean the router on your LAN which has the responsibility of being the first point of contact for traffic to computers outside the LAN.

If your LAN has multiple routers, the router designated as a default gateway can notify your computer, using an ICMP redirect or other mechanism, of a more appropriate route for a given destination.

For example


                   (Internet)---[Google]
                       |         64.20.60.99
                      [R2]
67.23.27/255           |187
|------+--------+------+-----|
       |9       |1
     [PC]     [R1]
                |      67.23.28/255
           |----+------+----------|
                       |9
                    [Server]

If router R1 is PC's default gateway, when PC first tries to contact Google, PC will send data to R1 (as PC knows Google's IP-address is not in PC's subnet), However R1 will tell the PC that a more appropriate route to 64.20.60.99 is via router R2. PC will add this to it's routing table, hence R1 won't show in a subsequent traceroute.

The command netstat -nr on your PC will reveal both the static routes it learned from it's configuration files and the dynamic routes it learned by ICMP redirects or by listening to routing protocol broadcasts/multicasts.

The term "gateway" has other connotations that are not relevant for the file and command in your question.


@RedGrittyBrick is absolutely correct with his answer ("a router and a gateway are essentially the same"), some other responders are confusing the terms or, to put it kindly, have misunderstood the question (or wikipedia).

As far as routing goes the term "gateway" is almost only ever used in conjunction with "default", and that "gateway" provides a route to every network for which there is no more specific route available.

By definition then, the gateway must be a device that does routing, it could be a dedicated device, specifically a router, or a host which has been configured to route, but it is doing the same job. Thus a gateway can be a router and a router can be known as a gateway.

There is no difference in TTL between a "default gateway" and a router, once a device which is doing routing passes an IP packet from one network/subnet to another it must decrement the TTL, that is made quite clear in the relevant RFC.

A gateway need not be doing NAT, typically a home network will have a default gateway that is a router connected to ADSL, that type of device will do NAT, whereas the default gateway on your subnet at work will just lead to the wider office LAN and will not do NAT.

In answer to your question about getting out to somewhere that is not on the local subnet, @RedGrittyBrick is again correct about the ICMP redirects, in addition, the process that a host goes through when sending out a packet is this:

1 - Use own IP address and mask to check if destination packet's IP address is in local subnet.

2 - If destination in local subnet, send ARP request for MAC address of that local device then send frame to host.

3 - If destination not in local subnet, send ARP request for MAC address of gateway to that network then send frame to gateway for onward forwarding (at which point the point about ICMP redirects may kick in).

Thus it can be seen that every host makes a routing choice of its own prior to sending out packets (of course this data is cached so lookups are not occurring for every single packet).


A router serves as a gateway, but with additional functionality. Per wikipedia: "A gateway is an essential feature of most routers, although other devices (such as any PC or server) can function as a gateway."


What is your IP?

Packets originating from the router itself will not have the Time-To-Live (TTL) reduced as they exit the router.

Packets from another source passing through a router will have it's TTL reduced by 1 at each hop. If the packets enter the router with a TTL of 1 and the router is the destination then the traffic will be received by the router. If the router is not the destination the packets will have their TTL reduced to 0 before exiting the router and will be dropped.