2

So I got to thinking today, as I was working on a task, that systems need to know a gateway to which to forward packets which are destined for non-local networks.

Then I recalled that, in a former life, we use to statically assign our workstation IP's and set the default gateway to also be that same IP.

And that's what got me wondering... why did that work?

Ryan Foley
  • 5,479
  • 4
  • 23
  • 43
Jon
  • 133
  • 3
  • It shouldn't have. – Jim G. Jun 02 '14 at 15:11
  • As far as it regards only local IPs in the same subnet it could. Maybe. But if you would have tried to reach something in another subnet it surely didn't. – Sebastian Jun 02 '14 at 16:00
  • So, no problem, default gw just means: add route to network 0.0.0.0/0.0.0.0 through something(host, device, interface...). And there is no problem to route all traffic to local interfaces, it will die somewhere in the OS). Because your host will just arp all ip-addresses(cant start sending ip packets) - it will even not try to route traffic over external host, it is an equal like all hosts in one broadcast domain(vlan). – pyatka Jun 02 '14 at 17:05
  • 5
    One word: *proxy-arp* – Ricky Jun 02 '14 at 17:18
  • As Ricky mentioned, it could be proxy-arp. I have also seen one site where each workstation was configured to listen to a routing protocol, so using itself as a gateway was done as well since it would learn the outside routes (although I still don't think there was any valid reason for that setup). – YLearn Jun 02 '14 at 17:58
  • Ah... okay, that could have been it. I didn't really question it at the time (wasn't my place to manage the network). So, if the gateway is set to the local IP, the workstation just fires packets out that interface, but for anything not on the local net, it issues the ARP, gets the response back from the proper gateway and then sends the packet there. Correct understanding? – Jon Jun 02 '14 at 18:46
  • With the use of proxy-arp, the router/gateway may respond to ARP requests for hosts not on the subnet so traffic will be sent there. If there was a routing protocol, the hosts would be learning routes from advertisements from the router(s), so it will only use the default gateway if there are no better routes in the routing table. – YLearn Jun 02 '14 at 19:24

4 Answers4

6

In a word: proxy-arp

It's a Bad Word™ in networking today, but in years long past it's the way things were done before "default gateways" were used -- back when The Internet was much smaller and no one worried about ARP tables growing to thousands of entries. Machines would ARP for any address as if it were connected to the local LAN. The ("any") router on the LAN with a path to the host would respond with it's address. It still works today... if you overlook the massive security hole. (who ever answers first wins and is now receiving traffic for whatever. aka instant man-in-the-middle attack.)

[I'm actually doing this in our OpenStack test lab. It allows the (/24) network to be sub-divided behind each stack. Because each host will proxy-arp for that stub, machines in the main network will still be able to get there without any explicit routes.]

Ricky
  • 31,438
  • 2
  • 43
  • 84
1

The default gateway is only used by a device if there are no better routes to the destination network in the routing table. If the device doesn't communicate to networks that aren't in the routing table, then the default gateway will never be used.

Routing tables can be updated on a device by making static changes or through the use of a dynamic routing protocol. Static entries don't scale well and can be problematic to maintain so most often a dynamic routing protocol is used.

Routers acting as gateways to a network can advertise the networks (possibly including the "default" network of 0.0.0.0/0) to which they have access. Client devices that are configured to listen to these advertisements can learn about these networks and update their routing tables accordingly.

Not knowing more about the specific environment you mentioned, I would suspect Ricky's answer about proxy-arp is far more likely, but I figured I would add this as a possibility as well.

YLearn
  • 27,141
  • 5
  • 59
  • 128
  • The network was largely comprised of Linux and Windows (XP then 7) workstations. It worked either way - by setting a default gateway to the router IP or by setting default gateway to workstation's static IP. The windows workstations generally used the latter and we had no issues browsing locally or globally. – Jon Jun 03 '14 at 13:25
  • 1
    @Jon, the point still stands. The default gateway is **only** used when there is no better route in the routing table. If they are getting better routes from another source they will never use the default gateway. Linux can support a variety of routing protocols (most common being RIP or OSPF) and Windows has had support for RIP/OSPF back to at least WindowsNT. – YLearn Jun 03 '14 at 18:50
0

Onces traffic is initiàted from source towards destination souce PCs runs ANDing process to check whether source and destination are same networks or in different networks

If source PCs founds destination on same networks then it's check ARP table in PCs and picks destination Mac address and forward packet to layer2 switch , in layer2 switch mac-address table to checked and forwards frame to specific destination ..

If source PCs founds that destination on different networks then packet is directly forwarded towards the gateway from gateway again packet is forwarded towards destination based on routing table .

Sagar Uragonda
  • 835
  • 1
  • 16
  • 73
0

It only worked because you didn't really need a gateway, since you were communicating with other systems on the same local subnet. If you had tried to reach an outside system, it should have failed.

sburlappp
  • 21
  • 2