Networking – Default gateway for isolated network

networking

What should the default gateway setting be set to for a simple network of 2 computers and one switch? Basically when there is no gateway (ie. no router, no internet, and no other connections into the switch).

Should it be set to:

  • 0.0.0.0
  • IP address of computer ON network.
  • IP address of computer NOT on network.
  • Something else.

Other notes:

  1. Some applications require 'something' entered. So gateway cannot just be 'blank' or ingored.
  2. Does the particular gateway address used affect the PING time performance between these two machines? (ie. more/less traffic).

Best Answer

You don't have to have a default gateway. If no router exists on your network, you want to NOT specify one.

In the Windows configuration for a network adapter you can leave the default gateway blank.

Linux has no problem if you want to delete the default route, or not specify one.

The default gateway address will only come into play if a system is trying to reach a subnet that's not currently on any network adapter. So if your network adapter is set to 192.168.15.1/255.255.255.0, and you send traffic to 192.168.15.5/255.255.255.0, the default gateway never comes into play. It would only possibly use it you tried to send traffic to something like 192.168.16.1 or something not in that subnet.


What should happen is if a process attempts to send traffic to a network access, and there is no route to it, then it should receive a "No route to host" error. If you don't specify a default gateway at all, it shouldn't even try to send traffic to any IP that's not in the subnet of your network adapter.

If you specify any other IP (including 127.0.0.1), it's going to try to send traffic to that IP if the destination IP is not in the same subnet as your network adapter (and no other interface matches the subnet). Nothing will respond, and the connection will time out. Waiting for the timeout will consume more time than simply not specifying a default gateway and letting the Windows TCP/IP software issue an error to the process trying to make a connection.

Related Question