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

Apprentice picture Apprentice · Mar 13, 2015 · Viewed 60.9k times · Source

For example:

  • IP Address: 130.45.34.36
  • Mask: 255.255.240.0

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

Answer

Malt picture Malt · Mar 13, 2015

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)