Venkatesh K
Venkatesh K

Reputation: 4584

To know whether ip's are from same network or different

IP address of source host is 10.192.240.10 and destination is 10.192.250.10. do the both hosts reside on same network or not ? If so, How can we find it.

Upvotes: 0

Views: 68

Answers (1)

PaulProgrammer
PaulProgrammer

Reputation: 17620

The first thing to know is the netmask. If the bits that are different are in the zero range of the netmask, then they should route on the same network. For instance, my home network uses 192.168.0.0/255.255.254.0 which means that 192.168.0.0-192.168.1.255 are routed by my home router ... 192.168.1.10 is on the same network with 192.168.0.10.

You could also try to traceroute from one to the other to determine how many hops. One hop means there's no active routing between the hosts, thus most likely the same network.

One hop, same network (kinda .. desktop is a wired connection, remote is a wireless connection; but from an IP point of view, the same):

paulw@desktop:~/PROJ$ traceroute 192.168.1.208
traceroute to 192.168.1.208 (192.168.1.208), 30 hops max, 60 byte packets
 1  remote (192.168.1.208)  218.838 ms  219.288 ms  219.484 ms
paulw@desktop:~/PROJ$ 

Many hops, different network:

paulw@desktop:~/PROJ$ traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  router.asus.com (192.168.1.1)  0.232 ms  0.410 ms  0.485 ms
 2  xx.xxx.xx.x (xx.xxx.xx.x)  161.662 ms  161.701 ms  161.701 ms
 3  xe-10-3-3-32767-sur03.arvada.co.denver.comcast.net (68.86.129.153)  87.925 ms  87.963 ms  88.518 ms
 4  te-0-13-0-2-ar02.denver.co.denver.comcast.net (162.151.8.41)  89.585 ms xe-10-0-2-0-sur02.arvada.co.denver.comcast.net (68.86.128.138)  89.493 ms te-0-13-0-2-ar02.denver.co.denver.comcast.net (162.151.8.41)  89.574 ms
 5  pos-0-7-0-0-ar02.aurora.co.denver.comcast.net (68.86.128.246)  91.431 ms  92.441 ms  97.540 ms
 6  he-3-9-0-0-cr01.denver.co.ibone.comcast.net (68.86.92.21)  92.421 ms  95.757 ms  96.290 ms
 7  xe-1-0-2-0-pe01.910fifteenth.co.ibone.comcast.net (68.86.84.122)  159.017 ms  74.074 ms  74.119 ms
 8  as15169-1-c.910fifteenth.co.ibone.comcast.net (23.30.206.106)  74.667 ms  73.637 ms  73.654 ms
 9  72.14.234.59 (72.14.234.59)  74.204 ms 72.14.234.57 (72.14.234.57)  78.921 ms 72.14.234.59 (72.14.234.59)  77.861 ms
10  216.239.46.146 (216.239.46.146)  89.413 ms 216.239.46.150 (216.239.46.150)  84.180 ms 216.239.46.146 (216.239.46.146)  83.705 ms
11  216.239.46.55 (216.239.46.55)  88.090 ms 72.14.239.50 (72.14.239.50)  27.409 ms  81.115 ms
12  216.239.46.193 (216.239.46.193)  85.238 ms 216.239.46.191 (216.239.46.191)  81.420 ms 216.239.43.217 (216.239.43.217)  81.457 ms
13  * * *
14  google-public-dns-a.google.com (8.8.8.8)  82.888 ms  83.473 ms  85.024 ms
paulw@desktop:~/PROJ$ 

Upvotes: 3

Related Questions