Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Imagine a network consisting of three computers all of which connecting to a switch. And we need to manually fill routing table in one of them.

The gateway column in routing table must contain the same information as the Next hop. But there is no next hop; all packets directly go between computers without any mediation (they actually go throught the switch, but it has no IP-address).

So what is the correct value for the gateway in the routing table?

share|improve this question
up vote 3 down vote accepted

Short answer: none, you don't need a gateway in order that the machines can communicate. In fact you don't even need routing, or a routing table.

If all the computers are in the same subnet, which they must, they don't need a gateway to communicate. A gateway is needed only when ou want to communicate with a machine that is on another network. Like I've said before they don't even need routing.

I recommend you read a tutorial or a book about IP. This can be an option.

share|improve this answer
PS: sory I can't give a better explanation about this but I don't have the proper time. The tutorial I pointed to can help but maybe someone can give a more detailed explanation. Anyway I really recommend you study a little bit about IP since I think you're missing some background. – criziot Jul 19 '12 at 22:03
But how 'none' will look in the routing table? (if I print it, for example) – Jofsey Jul 19 '12 at 22:04
@Lescott In fact you don't even need a routing table. Routing is done between multiple networks. If you don't have multiple networks you don't need routing. – criziot Jul 19 '12 at 22:05
okay, imagine one more network interface, wlan0 for example with an internet access. Now we need a routing table :) So how none will look in the table? – Jofsey Jul 19 '12 at 22:11
@Lescott imagine your "internal" network is and wlan is connected to other network. The default gateway should be the IP address of the ethernet interface in the computer that have the wlan, like, and the routing table will look something like (network next_hop netmask). – criziot Jul 19 '12 at 22:20

In most systems, for a route in a routing table, you either set an interface or give a next hop (or both).

In the case where only an interface is given, the packet will be sent directly to the destination host's MAC address through that interface (i.e. packets for hosts within the same subnet).

If a next hop is given, then the packet will be sent to the MAC address corresponding to that IP and the port used to send this packet is figured out using an interface route mentioned above.

In systems where you're not allowed to supply a port for the destination, you can probably use an IP address bound to the port to identify the port. For example:

Your computer's IP on a /24 subnet. Your routing table should look like

IP         Mask Next hop   /24 (meaning the NIC is connected to)   /32 (meaning the loop back interface) /32
share|improve this answer

You must log in to answer this question.

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