简体   繁体   中英

How to identify Network ID from an IP address

i already have studied about the internet IP and all those stuff, but i'm still confused about how to identify network ID from an given IP address, for example, if i have given an IP address: 192.168.250.0/24, so what will be the network ID?

can you guys help me?? and explain the method?

Thank you in advance

You need to convert the IP address and mask to binary, then logically AND them, then convert back to decimal:

192.168.250.0 -----> 11000000.10101000.11111010.00000000
24 bit mask -------> 11111111.11111111.11111111.00000000
                     =================================== <--- Logical AND
Network address ---> 11000000.10101000.11111010.00000000 ---> 192.168.250.0

This answer on Network Engineering describes how to do all your IP operations.

It s simple, your IP address is 192.168.250.0/24 and you should know that IP address is in a fact 32 bits value of zeros and ones. So it s easy for human to say listen this first 24 bits are network ID (network part) and remaining 8 bits are host ID (host part), but machines need parameter that will use to determine what bits are in network and what bits are ih host part. That s why we have subnet mask, that map IP address in a way that binary ones "1" map bits that belongs to network part and binary zeros "0" map bits that belongs to host part. So your IP address in binary form is

11000000.10101000.11111010.00000000  when we add subnet mask then you have
11111111.11111111.11111111.00000000  or 255.255.255.0 in decimal form
-------------------------------------
11000000.10101000.11111010.          bits maped by binary ones (network part)
                          .00000000  bits maped by binary zeros (host part)

If you count number of ones in subnetmask you will see that there are 24 binary ones, and that s why we use other notations for presenting subnet mask, and that is by something we call network prefix or "/24".

When host want to send packets he first must determine network address, but how he do that? Every host have IP address and subnet mask let say

192.168.250.6 and subnetmask /24 == 255.255.255.0 or in binary

11000000.10101000.11111010.00000110  
11111111.11111111.11111111.00000000  
------------------------------------- network hosts use logical AND operation
11000000.10101000.11111010.00000000 

(notice that network address is address that have binary zeros in host part of IP address. Logical AND use two values (0 or 1), results of this logical operation is "1" only when both values are "1" (or you can easily rememmber it has to be "1" AND "1" to get "1" as result :) ).

After this host examine destination IP let s say 192.168.10.6, and host use again same operation and if result show that network part is identical with his IP than thay communicate directly or if they have different networkID hosts use gateway since destination is at another network.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM