Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have two rules in my routing tables. The default route, which is to the gateway, and a second route which forwards everything in the network segment to * or to no gateway. Is this second rule necessary so that local packets do not by default go to the router first, or is the nic smart enough to check its own settings and see that if a packet is sending is in it's network segment, not to send it to the gateway?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

In general, you will see two rules (at least) in your routing table on most flavors of *nix.

You'll have a route to your local network (for this example, 10.11.12.0/24):

10.11.12.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0

And one identifying your default route.

0.0.0.0          10.11.12.1      0.0.0.0         UG        0 0          0 eth0

So, what this effectively tells your kernel, is:

send any packets going to 10.11.12.0/24 out eth0, directly, without specifically sending them to the default router (flags: U = route is UP)

send any packets to any address other than the local network (0.0.0.0 matches anything) to the gateway (10.11.12.1) (flags: U = route is Up, G = gateway).

If you have more interfaces, or you are multi-homed, or if you have specific network or host routes configured, you may see more routes than that, but this is sort of the minimum that you'd see on a regular basis.

By configuring and bringing up the interface, the kernel will automatically create that local network route.

You don't need to manually add that route.

share|improve this answer
    
does the 0.0.0.0 for local network mean send to "no one" or basically the any address already specified by the packet? –  rubixibuc Dec 29 '11 at 1:55
1  
the 0.0.0.0 in netstat, or * in the output of route -e just means that there is no gateway set for that route, and that packets are just routed out a particular interface. you will only see that with directly connected networks. –  Tim Kennedy Dec 29 '11 at 6:01
    
cool :-), thank you –  rubixibuc Dec 29 '11 at 6:09

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.