Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Here's the overview of the configuration: 3 computers on a switch. Computer1 has DNS/DHCP/router (routers) in place. Computer2 receives static DHCP from Computer1. Computer3 has a staticIP with a different subnet than that of Computer1.
And someone tries to ping 10.0.0.101. At the time the only entries in ARP cache (of 10.0.0.1) is :
10.0.0.1 at 00:11:22:33:44:55 on en0
10.0.0.100 at 11:22:33:44:55:66 on en0
What I would expect is that since 10.0.0.101 isn't in ARP's cache and since there is a route saying if it fits the 10.0.0.0 format, direct it to the gateway 1.2.3.4.
From my testing results, this isn't the case. The router starts querying for who have 10.0.0.101 and Computer2 responds.
Why is this?
Click here to see the post LQ members have rated as the most helpful post in this thread.
I believe it would be because the gateway defined for the 10.0.0.0/8 network is not reachable for computer 3. 1.2.3.4 is not in the same network as 192.168.1.100 (unless, of course, the network mask is set to 0.0.0.0). However, as ARP works at the physical (TCP/IP model) or data link (OSI model) level (i.e. doesn't care about networks and subnets), then its broadcast will reach computer 2, so long as they're attached to the same switch.
The routing table also contains an entry for each network you have a nic attached to with no gateway(next hop) set. As there is no gateway the machine then knows that it needs to send an arp request to find the target as it's directly connected.
There are two type of routes - direct (or connected) and indirect. If you configure 10.0.0.1 255.255.255.0 on an interface the router implicitly aquires a direct route 10.0.0.0 255.255.255.0 via eth0. The router then needs to be given indirect routes (static configured routes or a routing protocol) that directs any traffic that does not belong to directly connected networks. These routes can be more explicit 10.1.0.0 255.255.255.0 less explicit, 10.0.0.0 255.0.0.0 or default 0.0.0.0 0.0.0.0.
A router should, on being given a packet to route, look for the longest match route. If a packet is destined for 10.1.0.3, 10.0.0.0 255.0.0.0 is a match, but 10.1.0.0 255.255.255.0 will be the preferred route because it is the longest, or most explicit, match. 10.2.0.1 will match 10.0.0.0 255.0.0.0 because its a longer match than 0.0.0.0. 11.0.0.1 does not match anything except 0.0.0.0 so will follow the default route.
Any packet that gets directed along an indirect route will require a gateway that is a member of a shared directly connected network to use as a next hop. Your route 10.0.0.0 255.0.0.0 1.2.3.4 will not work as you have no interface configured with 1.2.3.x.
Any packet that matched a direct route will be sent to the interface. If the interface is a multi acces network such as ethernet or token ring you run into a problem, there are lots of peer devices on that interface so you need to work out which one is the actual destination. So ARP is invoked to work out which host on the shared network owns the next hop address.
So if I assume that your PC's are configured as 10.0.0.1 255.255.255.0 and 10.0.0.100 255.255.255.0 then they both have a direct route of 10.0.0.0 255.255.255.0. If you ask them to ping 10.0.0.101 the longest match is 10.0.0.0 255.255.255.0 via eth, therefore the CP will ARP for 10.0.0.101.
If you ping 10.2.1.1 the router will match this to 10.0.0.0 255.0.0.0. It will then, if it supports recursive routing, do a route lookup for 1.2.3.4. If it doesn't it will immediately fail due to having no interface as a member of this network. Either way when it doesn't find the next hop it will discard the packet and send an ICMP network unreachable message to the PC.
Thanks for the input. I managed to solve my problems. At the time I had routes set up poorly so every computer on 10.0.0.0/8 could talk directly to each other instead of using the router. I was also intentionally trying to route to a NULL gateway in hopes of getting the packets to drop (I had to do a workaround for it to even accept the fake gw). All is well now, and I have since furthered my knowledge on routes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.