1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

subnetting basics

Discussion in 'Network+' started by smooney, Oct 30, 2012.

  1. smooney

    smooney New Member

    2
    0
    1
    hi there guys my first post. ive started a networking course six weeks ago and ive been getting on fine with most of my classes. but we have just started on subnetting and try as i might i can not get my head around i have watch videos about the so called magic number and read lots of websites, but i just can get it, could someone please point me in the right direction any help would be much appreciated whether its books or videos or websites, thanks in advance
     
  2. The Zig

    The Zig Kilobyte Poster Forum Leader

    305
    19
    46
    Not sure about best resources.
    But if you write here what you do get and what you don't, I'll happily try to help out. For instance is it the purpose of subnetting you don't get, what it's for, or the binary behind it?
     
    Certifications: A+; Network+; Security+, CTT+; MCDST; 4 x MTA (Networking, OS, Security & Server); MCITP - Enterprise Desktop Support; MCITP - Enterprise Desktop Administrator; MCITP - Server Administrator; MCSA - Server 2008; MCT; IOSH; CCENT
    WIP: CCNA; Server 2012; LPIC; JNCIA?
  3. smooney

    smooney New Member

    2
    0
    1
    thanks for the reply. correct me if im wrong but do we subnet to create more smaller networks from a large network ?

    the parts im struggling with is

    how do i calculate the subnet mask ?
    also what is the /24 etc
    how do i find the broadcast
    and the first host
    and last host
    for instance

    192.168.5.0/26
    how do i calculate the 1st host,last host and broadcast
    from this ip address i understand the binary part i think
    just need some help with how u come about to calculate these, thanks for your time, i just thought i would say in my class we have only went over the subnetting for two hours, but i think im gonna struggle with it

    - - - Updated - - -

    when i say calculate the subnet, i mean if im giving an ip address, what calculations do i make to find out what the subnet mask is and also how many hosts i can have on it. thanks again
     
  4. Coupe2T

    Coupe2T Megabyte Poster

    590
    43
    67
    In the example you give above they are telling you the subnet mask. the /24 or /26 is what tells you. So in the latter, 26 of your binary digits will be the mask. Which means that all 8 of the first 3 octets are on, and the first two of the last. ie: 11111111.11111111.11111111.11000000 or 255.255.255.192.

    the binary numbers count backwards, starting at 1 on the right hand side and doubling as it goes up, but when doing the subnet mask you go left to right.

    so binary looks like

    128 64 32 16 8 4 2 1 , so for a subnet mask, you have 4 octets,
    128 64 32 16 8 4 2 1, 128 64 32 16 8 4 2 1, 128 64 32 16 8 4 2 1, 128 64 32 16 8 4 2 1 and you know that 26 bits are 'ON' so add these below:
    1 1 1 1 1 1 1 1, 1 1 1 1 1 1 1 1, 1 1 1 1 1 1 1 1, 1 1 0 0 0 0 0 0 then add up each octet. Apologies for the poor formatting.

    So to break it back down, each of the first 3 octets has every binary bit 'ON', therefore you add all the numbers in decimal so 128+64+32+16+8+4+2+1 = 255. The same is true for all three of the first octets, but the last octet only has 2 bits 'ON', which are the bits for 128 + 64 in decimal, giving you 192. Hence 255.255.255.192

    Not sure if i've explained that as well as I could have, but if not then let me know and I can try and explain more.
     
    Certifications: ECDL, Does that Count!?!
  5. The Zig

    The Zig Kilobyte Poster Forum Leader

    305
    19
    46
    Nice answer here. But just to rewind a bit, because I've seen people miss something at the start, and soldier on without really getting what they're doing.

    The bit you probably already know:
    An IP(v4) address is 32 bits. The first part of it is the "network address", the second part the "host address". This means, the first part is used to identify a network, and the rest identifies an individual computer (host) on that network.

    So let's say the IP is: 192.168.55.12
    How do we know where the network bit ends and the host bit begins? Is this host number 55.12 on the 192.168 network? Or host 12 on the 192.168.55 network? Do we need to send it to the 192.168 network, or the 192.168.55 network? Or the 192 network? Or something else?
    This is where the subnet mask comes in.

    The subnet draws the line between the network part of the address and the host part of the address. You've probably seen subnets written in dotted decimal (255.255.0.0 and such) but to understand them it helps to think in binary. In binary, the subnet mask is just a continuous line of ones, followed by a continuous line of zeros up to 32 bits, e.g.:
    11111111 11111111 00000000 00000000 (which can be written 255.255.0.0), or
    11111111 11111111 11111111 00000000 (255.255.255.0)
    11111111 00000000 00000000 00000000 (255.0.0.0)

    Wherever there's a 1 it's Network Address, and where there's a 0 it's host.
    To illustrate, say we had this IP and subnet...
    11000000 10101000 00110111 00001100 - 192.168. 55. 12
    11111111 11111111 00000000 00000000 - 255.255. 0. 0
    You can see from looking at the binary that the ones cover the fist two parts (octets). This lets us know that these parts are the network address, leaving the last two parts for our host ID. So,
    Network ID: 11000000 10101000 00000000 00000000 = 192.168.0.0
    & Host ID : 00000000 00000000 00110111 00001100 = 0.0.55.12

    Wheras if the subnet was 255.255.255.0
    11000000 10101000 00110111 00001100 - 192.168. 55. 12
    11111111 11111111 11111111 00000000 - 255.255.255.0
    We'd be looking for Host ID:12, on network 192.168.55.0

    Shorthand notation
    So the line of ones simply tells us how to split up the address. Now we know the rules (i.e. "there have to be continuous ones followed by continuous zeros up to 32 bits") we can simplify. Why bother writing it all? For the first example we can say "there are 16 ones" and we have everything we need to make the mask. For the second, there are 24 ones. This can be written in shorthand notation as /16 and /24.
    So instead of writing "11111111 11111111 11111111 00000000" or "255.255.255.0" we can write "/24" (there are 24 ones).
    11111111 00000000 0000000 00000000 (or 255.0.0.0) can be written /8. And so on.

    That was the first part of the foundation: here's the second.
    There's no reason the subnet has to be limited neatly to the octets (the groups of eight)
    11111111 11111111 11110000 00000000 is a perfectly valid subnet mask (32bits long, continuous ones followed by continuous zeros - fine)
    This can be written as /20, and a bit of binary maths (see Coupe2T's post above) will show that this is 255.255.240.0**
    As another example: 11111111 11111111 11000000 00000000 or /18 or 255.255.192.0


    Here's where it gets tricky
    Say you have that same IP address as above, but now a /20 subnet:
    11000000 10101000 00110111 00001100
    11111111 11111111 11110000 00000000
    The subnet now covers half of the third octet, splitting that octet in half.
    How do we figure out the network ID now?! The only way I can do the next bit is to visualise/write it in binary.

    Network ID: 11000000 10101000 00110000 00000000
    Again, with a little binary maths, this gives:
    Network ID: 192.168.48.0

    Just to give one more example, so you can watch how it works.
    Here's our IP & Subnet info: 57.76.108.9 /12

    /12: 11111111 11110000 00000000 00000000
    IP = 00111001 01001100 01101100 00001001

    Network ID: 00111001 01000000 00000000 00000000
    Network ID: 57.64.0.0


    I've written enough for one post/night. Take some time to make sure you're good with everything so far. Tomorrow or over the weekend, I'll get into figuring out the broadcast address, how many hosts you can fit, and first and last host. If no one else beats me to it.
    This is a LOONG post so may have errors. If so, someone let me know.


    * You can convert binary to decimal with Windows Calculator, by the way: just go to the View menu and put it in Programmer view. Every Linux flavour I've tried also has a calculator that can do this, and guessing Mac does too.
     
    Certifications: A+; Network+; Security+, CTT+; MCDST; 4 x MTA (Networking, OS, Security & Server); MCITP - Enterprise Desktop Support; MCITP - Enterprise Desktop Administrator; MCITP - Server Administrator; MCSA - Server 2008; MCT; IOSH; CCENT
    WIP: CCNA; Server 2012; LPIC; JNCIA?
  6. The Zig

    The Zig Kilobyte Poster Forum Leader

    305
    19
    46
    Ha! Didn't say which weekend did I?!

    For the next stretch, I'm gonna give basically a cheat sheet. If you want to know why this works, ask. But the important thing for now is that it works.
    When you get to situation where you have to divide a network, or plan subnets (or an exam) here's what to write.
    Next line, write the binary sequence (1, 2, 4, 8...) but write it right to left like so...
    (I'll also put a line of '1's over the top, to help explain something in a bit)
    [table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
    [/table](You only need to go up to 8 columns)

    In the second row, write the sum of all the numbers in the row above, up to that column. So in the first column, it's just 128. Same as above. In the second column the number above is 64, so we do 128 + 64 to give us 192. In the third column, 128 + 64 + 32, and so on...[table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]...[/td][td][/td][td][/td][td][/td][td][/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
    [/table]And so on...[table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]240[/td][td]248[/td][td]252[/td][td]254[/td][td]255[/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
    [/table]

    How has this helped? This is your cheat-sheet for converting between binary and dotted decimal!
    Say you're given the subnet 255.255.240.0
    If you look at the table, that 255 is right over on the right. This means that to 'make' 255 we need all the bits to be 'on' (if you put your hand flat on the table after the 255, all the ones at the top are visible). So the first octet is all ones (11111111 in binary). The second is also 255, so the same. The next one is 240.
    Now, if you put your hand over the table after the 240, you can only see the first 4 bits, the first four '1's at the top.[table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]...[/td][td]...[/td][td]...[/td][td]...[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]...[/td][td]...[/td][td]...[/td][td]...[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]240[/td][td]...[/td][td]...[/td][td]...[/td][td]...[/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
    [/table]
    This means, we need the first four '1's to be 'on' to get '240' - that is: 11110000 in binary.
    And for that final zero, we don't need any '1's to be 'on'. That is: 00000000 in binary.

    So without any calculator, we can see: 255.255.240.0 is 11111111 11111111 11110000 00000000. Clear?
    By counting the ones (as we did in the previous post) we can also see this can be written: /20

    Try it for these:
    255.252.0.0 could be written
    /14
    255.255.255.128 is the same as
    /25

    To reverse this: if you've got /22, just write 22 ones with a space every eight: 11111111 11111111 11111100 00000000
    Use the table again to get the answer: 111111111 =
    255
    , 111111100 =
    252
    , 00000000 =
    0
    . So answer =
    255.255.252.0

    /10 =
    255.192.0.0
    /16 =
    255.255.0.0
    /29 =
    255.255.255.248
    Good?

    And finally
    So what's that last row for? Here's where it gets tricky. Frankly I'll explain if someone really wants. The fact is, it works.
    The last column is for how many hosts you can have in the network.
    [table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]240[/td][td]248[/td][td]252[/td][td]254[/td][td]255[/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
    [/table]
    Here's the formula. Look two squares up. Get that number, and take away two. That's it.
    Two squares up and take away two.

    Let's just demo that. So for the right-most one, look two up. There's a '1'. Now take away 2, and we get -1. We can't have -1 devices, so call it zero. And it's correct. If we've got no bits for addressing, we can't address anything.
    Next. Two squares up is a two. Take away 2, again zero. Again that's right. If we only have one bit for addressing, we only have two options for it, a 1 and a 0. Now remember, we always lose two addresses - the first and last are reserved. It's a rule of IP. The last address (all ones) is always the "broadcast address" and the first (all zeros) address is the "network address". So with just two options, but both being taken away for these reserved addresses, we don't have any space left for computers in a subnet this small. Pretty useless. Zero.
    [table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]240[/td][td]248[/td][td]252[/td][td]254[/td][td]255[/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td][/td][td]0[/td][td]0[/td][/tr]
    [/table]Next.
    Two squares up. It's a four. 4 take away 2 equals 2.
    Done.
    [table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]240[/td][td]248[/td][td]252[/td][td]254[/td][td]255[/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td][/td][td]2[/td][td]0[/td][td]0[/td][/tr]
    [/table]Too easy? Let's check it. Put your hand on the table to divide the first six bits from the last two. So the first 6 are taken away as network ID. We just have the last two bits for addressing. There are four possible addresses we can get with 2 bits:-
    Namely: 00, 01, 10 and 11
    The last of these '11' is reserved as the 'broadcast address'. So we can't use it. The first '00' is called the 'Network ID' so we can't use that either. So that leaves, 01 and 10. There are the 2 addresses that we can use.

    Next! 8 - 2 = 6. Simple.[table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]240[/td][td]248[/td][td]252[/td][td]254[/td][td]255[/td][/tr]
    [tr][td][/td][td][/td][td][/td][td][/td][td]6[/td][td]2[/td][td]0[/td][td]0[/td][/tr]
    [/table]This is the last one we'll check. If you want to work out the rest, go for it.
    With the first 5 bits taken away for network, we just have three left for host. With three bits, we now have 8 possibilities.
    000, 001, 010, 011, 100, 101, 110, 111
    As before, the last one gets stolen away. What's that one reserved for?
    111 will be the Broadcast address
    Also, the first one gets taken again as well. What's this reserved for?
    000 will be the network ID
    So we're left with 001, 010, 011, 100, 101, 110. Six options. Each of these can be given to a PC or printer or whatever (a host) as an address, allowing us six hosts on our subnet.


    Following the process, the table ends up like this...
    [table="width: 500, class: grid, align: center"]
    [tr][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]64[/td][td]32[/td][td]16[/td][td]8[/td][td]4[/td][td]2[/td][td]1[/td][/tr]
    [tr][td]128[/td][td]192[/td][td]224[/td][td]240[/td][td]248[/td][td]252[/td][td]254[/td][td]255[/td][/tr]
    [tr][td]126[/td][td]62[/td][td]30[/td][td]14[/td][td]6[/td][td]2[/td][td]0[/td][td]0[/td][/tr]
    [/table]

    A limitation is, this only works 100% in the case of splitting the LAST OCTET. (e.g. 255.255.255.240 will allow 14 hosts, but 255.240.0.0 would allow a hell of a lot more).

    So a real world kind of problem (or exam question) might be: you have the IP range 192.168.16.0 with subnet mask 255.255.255.0. You need to split this for four offices each with 40-50 devices, what subnet mask would you choose?
    The first step will be to choose the subnet mask. We need 40-50 devices (hosts). Looking along the bottom row of the table, we can see that the 62 network is the first one that's big enough. 30 just isn't big enough.
    So by cutting after the 2nd bit, we get 62 host addresses. A bit more than we needed, but then it's always a good idea to have some space for growth. So by cutting after the second bit, we get a subnet of 255.255.255.192 (aka /
    26
    )

    And that's enough for one post
     
    Certifications: A+; Network+; Security+, CTT+; MCDST; 4 x MTA (Networking, OS, Security & Server); MCITP - Enterprise Desktop Support; MCITP - Enterprise Desktop Administrator; MCITP - Server Administrator; MCSA - Server 2008; MCT; IOSH; CCENT
    WIP: CCNA; Server 2012; LPIC; JNCIA?

Share This Page

Loading...