Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I determine network and broadcast address from the IP address and subnet mask?

For example:

  • IP Address: 130.45.34.36
  • Mask: 255.255.240.0

What would be Net ID/Subnet Address, and Broadcast Address?

like image 299
Apprentice Avatar asked Mar 13 '15 14:03

Apprentice


1 Answers

Let's write both in binary:

130.45.34.36 = 10000010.00101101.00100010.00100100

255.255.240.0 = 11111111.11111111.11110000.00000000

A bitwise AND between the two would give us the network address:

10000010.00101101.00100010.00100100   (ip address) AND 11111111.11111111.11110000.00000000   (subnet mask) = 10000010.00101101.00100000.00000000 = 130.45.32.0 (the resulting network address) 

A bitwise OR between the network address and the inverted subnet mask would give us the broadcast address:

10000010.00101101.00100000.00000000   (netadress) OR 00000000.00000000.00001111.11111111   (inverted subnet mask) = 10000010.00101101.00101111.11111111 = 130.45.47.255 (broadcast address) 
like image 192
Malt Avatar answered Oct 02 '22 06:10

Malt