Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My ISP has given me two static IPs, and I was just configuring the etc/network/interfaces file and saw that I need netmask, gateway, address, broadcast and network values.

I only have the first three, so can I calculate the broadcast and network values from the other three?

My network is currently working without them, but I'm wondering if it'll affect me in any way by leaving them off?

share|improve this question
    
I suppose so. If your gateway is 192.168.1.0 and your mask is 255.255.0.0 then your network address would be 192.168.0.0 and your broadcast would be 192.168.255.255 Whereas if as is more likely, your gateway is 192.168.1.0 and your broadcast is 255.255.255.0 then your network address would be 192.168.1.0 and your broadcast address would be 192.168.1.255 Though i'm not into ubuntu so this may not be relevant.. but that's what I know from what I know of subnetting. You should be able to see the pattern and apply the principle to your network, and see if it works. –  barlop Jul 19 '11 at 11:37
    
in the netmask, the 255s mark the network portion, the 0s mark the host portion. broadcast is host portion set to all 1s, so 255s(for any octet that is all 1s). if a netmask is not of the pattern 255(s) followed by 0(s), then it may be a little more complicated. –  barlop Jul 19 '11 at 11:38
    
what is the IP and mask? –  Keith Jul 19 '11 at 12:15

1 Answer 1

up vote 3 down vote accepted

All you need to calculate the network and broadcast addresses are an address somewhere in the network and the netmask, you don't need to know the gateway.

First, Take your network mask and convert to binary:

255.255.255.248 = 11111111 11111111 11111111 11111000

Next, Take the network address you know and do the same:

192.168.216.222 = 11000000 10101000 11011000 11011110

Now you can calculate the network and broadcast, for the network you carry out a logical AND between the known address and the netmask:

    255.255.255.248 = 11111111 11111111 11111111 11111000
    192.168.216.222 = 11000000 10101000 11011000 11011110
AND 192.168.216.216 = 11000000 10101000 11011000 11011000 = Network

For the broadcast, invert net netmask and carry out a logical OR between the known address and the inverted netmask:

    255.255.255.248 = 11111111 11111111 11111111 11111000
NOT 000.000.000.007 = 00000000 00000000 00000000 00000111
    192.168.216.222 = 11000000 10101000 11011000 11011110
OR  192.168.216.223 = 11000000 10101000 11011000 11011111

So, given an address of 192.168.216.222 and a netmask of 255.255.255.248, you can calculate the network as 192.168.216.216 and the broadcast as 192.168.216.223.

In your case, you say your ISP has given you 2 static IP's, this will in reality be 4 IP's, with a netmask of 255.255.255.252 it's just that two of those 4 IP's are taken up by your network and broadcast addresses.

share|improve this answer
    
The question asked if these are needed, not how to calculate them. –  Matt Austin Sep 12 '12 at 7:59
    
Actually, the question did ask how to calculate them: "I only have the first three, so can I calculate the broadcast and network values from the other three?" ... Pretty clear, no? –  Mike Insch Nov 8 '12 at 12:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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