4

Please help me with one doubt regarding ARP requests. Based on my understanding the subnet of an IP is identified by it's Subnet Mask so consider this scenario:-

Suppose Device1 with IP- 30.129.33.225 needs to talk to a Device2 with IP- 30.113.220.62.

i)If Device1 know the Subnet Mask of Device2 IP-

It calculates and finds out Device2 to be on a different subnet hence for the communication IT SENDS THE DATAGRAM(packet) to THE DEFAULT GATEWAY---NO ARP REQUESTS.

ii) If Device1 doesn't know the Subnet Mask of Device2 IP -

This is my doubt. What does Device1 do? Does it send a broadcast ARP request thinking of Device2 to be on the same subnet as its? How does any networking device calculate the subnet mask or how do they identify the subnet of an IP and decide whether to ARP or route to GATEWAY.

The scenario is important because in my case Device1 is a Network Device Discovery Appliance, it fetches IPs from the Switch MAC table/ARP Tables and then pings the IPs to find out if they are alive/exists. To my knowledge Switch MAC Table/ARP Tables does not contain Subnet Mask. Only Route Table has Subnet Mask information I believe. So does Device1 send an ARP broadcast of the form "who has 30.113.220.62(Device2 IP)" "tell 30.129.33.225(Device1 IP)" or Device1 calculates the mask by some means and finds out Device2 to be in different network hence routes the packet to Default Gateway?

ARP REQUEST SOURCE IP:0.0.0.0

Please guide me. Thank you

1

3 Answers 3

3

An ARP request is generally limited to the broadcast domain = the local subnet or segment. MAC addresses outside the local subnet are meaningless.

The only relevant question is Is the destination IP address in my own subnet = local?

If yes, ARP the destination address and send to MAC.

If no, select gateway from routing table, ARP the gateway's IP address and send to that MAC.

To find out if the destination IP address is inside your own subnet, you bitwise AND your own IP address with your network mask, resulting in your subnet address. Then you bitwise AND the destination IP address with your network mask and compare the result with your own subnet address. If both subnet addresses are identical the destination is local.

If you mean to discover the MAC address for a remote device (for whatever reason) you'll have to find (or install) a device in the appropriate subnet that can ARP the IP address and tell you the MAC.

Discovering remote devices is much harder than local ones (which you just try to ARP and when you get an answer you know it's there). You can only detect remote devices by using IP/layer 3 functions because these can be routed.

You can try to ping a device (which may choose not to answer or the echo request or reply is filtered on the way), or you can try to connect to some common port. On failure, you can analyze the ICMP reply (a device request might actively reject the connection or a router might tell you there's no one there). If you get nothing you can't be sure there's nothing there though.

2
  • Hi Zac67, thank you for the clarification but I have a problem with a device sending ARP request broadcasts to IP in a different network. As I posted,30.129.33.225 sending ARP requests for 30.113.220.62. It means 30.129.33.225 is not able to understand/calculate that 30.113.220.62 is a different subnet hence ARP broadcasts for that should not be generated rather the GATEWAY should be contacted. Is that it or am i missing something?
    – nowiz
    Commented May 4, 2018 at 18:57
  • 1
    ARP is using Ethernet broadcast. It can't reach beyond the local segment, ie.across a router. So, you simply can't send an ARP request unless you've got a local interface in that segment. You can't use a gateway for ARP, it can't be routed.
    – Zac67
    Commented May 4, 2018 at 19:48
10

A device NEVER knows the subnet mask of another device.

A device knows its IP address and its own subnet mask and based on this information knows in which network it resides.

When host A sends a packet to host A it determines if B is in the local network solely by looking up B's IP address.

Example 1:

Host A : IP 30.129.33.225 - subnet mask 255.255.255.0.

-> A belongs to network 30.129.33.0/24.
This network contains IP address 30.129.33.1 to 30.129.33.255 (broadcast address)

Host B : IP 30.113.220.62.
This IP is not in the same network, so if host A sends a packet to B it will send it to a gateway.

Example 2:

Host A : IP 30.129.33.225 - subnet mask 255.0.0.0 -> A belongs to network 30.129.33.0/8 This network contains IP address 30.0.0.1 to 30.255.255.255 (broadcast address)

Host B : IP 30.113.220.62.
This IP is in the same network, so host A can send a packet directly to host B and it will perform an ARP request to find B's MAC address.

Notes:

  • For this to works it requires that the subnet masks are coherent. In example 2 if host B has a subnet mask of 255.255.255.0 the communication will likely fail.

  • In practice the way host A determines if B is in the same network is by applying its own subnet mask to both its own IP address and B's IP address and check if the results are identical.

6
  • Communication can still work with inconsistent subnet masks if the router cooperates. A sends directly to B, but B replies by sending to the router, which forwards to A.
    – Barmar
    Commented May 4, 2018 at 19:18
  • Hi JFL, thank you for the response . But I am facing this scenario where IP 30.129.33.225 is sending ARP Request for IP 30.113.220.62 . I understand the ARP request broadcasts sent by 30.129.33.225 wont reach 30.113.220.62 as router will stop it. But I dont understand why is it sending an ARP broadcast in the first place? Doesnt the device1(30.129.33.225) understand that 30.113.220.62 is on another network and to communicate with it, it should approach the Gateway rather than sending ARP.
    – nowiz
    Commented May 4, 2018 at 21:04
  • 3
    @nowiz Sounds like you misconfigured the subnetmask on device A, which leads it to think that device B is in the same subnet.
    – Nzall
    Commented May 4, 2018 at 21:15
  • 1
    @Barmar it may works but there's many, many different possible cases. This is why I wrote "will likely fail ;)
    – JFL
    Commented May 4, 2018 at 21:37
  • @nowiz I agree with Nzall. What is the subnet mask configured on device A?
    – JFL
    Commented May 4, 2018 at 21:45
7

A device only knows its own subnet mask, and it helps the device to calculate which network it belongs to.

Everything outside the network must go through the default gateway and everything in the network must be discovered using ARP.

In your example Device 1 has the IP 30.129.33.225.

a) if the subnet mask is 255.255.255.0 then:

The network is from 30.129.33.0 to 30.129.33.255. Everything outside that range goes to the default gateway.

However,

b) if the subnet mask is 255.255.0.0 then:

The network is wider (from 30.129.0.0 to 30.129.255.255) and again, everything outside that range goes to the default gateway.

2
  • 1
    wow same response with almost the same examples the same minute ;)
    – JFL
    Commented May 4, 2018 at 7:51
  • @JFL Great minds think alike
    – jcbermu
    Commented May 4, 2018 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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