Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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) –  Lescott 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? –  Lescott Jul 19 '12 at 22:11
1  
@Lescott imagine your "internal" network is 192.168.1.0 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 192.168.1.10, and the routing table will look something like 0.0.0.0 192.168.1.10 0.0.0.0 (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 10.0.0.2 on a /24 subnet. Your routing table should look like

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.