Friday, October 9, 2015

Networking Basics - IP address, netmasks and subnets

In this tutorial, we will cover some networking basics. We won't be hacking anything, but by the end of the tutorial you'll learn a lot of things which will be useful later, especially when you'll use nmap. Please note that it is advised that you go through wikipedia pages of all the concepts covered here since the discussion won't be exhaustive in any way.

IP address

An IP address is simply a 32 bit address that every device on any network (which uses IP/TCP protocol) must have. It is usually expressed in the decimal notation instead of binary because it is less tedious to write it that way. For example,
Decimal notation - 192.168.1.1
Binary  - 11000000.10101000.00000001.00000001
It is clear from the binary form that the IP is indeed 32 bits. It can range from 0.0.0.0 to 255.255.255.255 (for the binary all 0s and all 1s respectively) [A lot of time, the first octet usually goes upto 127 only. However, we aren't concerned with that here.]




Parts of an IP address

Now this IP address has 2 parts, the network address and host address. A lot of wireless routers keep the first 3 octets (8 bits, hence octets) for the network address and the last octet as host address. A very common configuration being 192.168.1.1 . Here, 192.168.1.0 is the network address and 0.0.0.1 is host address. I hope you can see that the host address can vary from 0.0.0.0 to 0.0.0.255 (though usually 0 and 255 are reserved for the network and broadcast respectively).



Need for Netmasks

But different networks have different needs. The previous configuration lets you have a lot of different possible networks (the first 3 octets are for the network and can take different values, not just 192.168.1.0) but only 256 (254 actually) hosts. Some networks may want more hosts (more than 255 hosts per network). This is why there is no "hardcoded" standard enforced on networks for the network and host addresses, and instead, they can specify their own configuration. The first 3 octets being network address and last octet being host address is common, but in no way mandatory. Using Netmasks, we can have very versatile set of configurations, for each and every need.



Netmask

A netmask is used to divide the IP address in subnets. 
We'll start with a basic example. Suppose we want to define a netmask which configures our network like wireless router in the previous example. We want the first 3 octets to correspond to the network and next 1 octet for host address. 
Let's think of an operation which we can use to separate the network and host part of the IP address. For simple purposes, we could have just defined after which octet does the host part start [basically saying that anything after the third period(.) is host address]. While this is a simple solution, it is not very versatile. 
A more elegant and mathematical solution was proposed.



Netmask - Working

First I'll tell you the mathematical functionality of a netmask. Assume A to be an IP address and M to be a netmask. Then, 
A & M gives the Network address
A & (~M) gives the Host address.
Where,
is bitwise And
~ is bitwise Not (i.e. complement, 1s complement to be more precise)

So, basically a netmask is another 32 bit binary number (just like an IP address), but with the purpose of giving Host address and network address when the operation bitwise and is carried out on it (and it's complement) with A.



Example

You'll understand better with example.
A = 192.168.1.1 is you IP address
M = 255.255.255.0
We convert it  to binary, and then carry out the desired operations.


A   =    11000000.10101000.00000001.00000001  (192.168.1.1)
M   =    11111111.11111111.11111111.00000000  (255.255.255.0)
A&M =    11000000.10101000.00000001.00000000  (192.168.1.0)
A&M is network IP that we desired


A   =    11000000.10101000.00000001.00000001  (192.168.1.1)
~M  =    00000000.00000000.00000000.11111111  (0.0.0.255)
A&~M=    00000000.00000000.00000000.00000001  (0.0.0.1)
A&~M is host IP that we desired




Explanation

Basically, if you realize that 11111111 is 255 in decimal, then you can see that for the parts of the IP address that you want for networks, you set the subnet to 255, and for the ones you want for host, you set it to 0.
So, if you want to reserve 2 octets for networks and 2 for hosts, then the subnet will be-
M = 255.255.0.0
If you want 3 octets for host, then
M = 255.0.0.0
Hence, we can see that using netmasks we can achieve what we wanted, i.e. to define networks with whatever number of hosts we require. Now we go a bit further.



Subnets

Now suppose you want to divide your network into parts. It is the sub-networks that are known as subnets (it is correct to call them subnetwork as well). 
We'll jump right to it, consider the netmask M
M = 11111111.11111111.11111111.11000000
Now, the first 3 octets describe the network. But the 4th octet, which is supposed to be for the host, has the 2 most significant bits (i.e. leftmost bits) as 1. Thus, the 2 most significant (leftmost) bits of the 4th octet will show up when we carry out the bitwise AND operation. They will, thus, be a part of the network address. However, they belong to the host octet. Thus, these 2 bits, which belong to the host octet but show up in the network IP address divide the network into subnets. The 2 bits can represent 4 possible combinations, 00, 01, 10 and 11, and hence the network will have 4 subnets. 



Example of Subnetwork

Back to our previous "A",


A   =    11000000.10101000.00000001.xx000001  (192.168.1.1)
M   =    11111111.11111111.11111111.11000000  (255.255.255.192)
A&M =    11000000.10101000.00000001.xx000000  (192.168.1.0)


Earlier, irrespective of what was there in 4th octet of A, we would have got all 0s in 4th octet of A&M i.e. network address. This time we will get the 2 most significant bits in the network address. Four subnets will be formed depending on the value of xx (which can be 00,01,10 or 11). Now, we will see which subnet has which set of hosts.



Which subnet has which hosts

11000000.10101000.00000001.00000000
has hosts 192.168.1.0-63 (00000000 to 00111111)

11000000.10101000.00000001.01000000
has hosts 192.168.1.64-127 (01000000 to 01111111)

11000000.10101000.00000001.10000000
has host 192.168.1.128-191 (10000000 to 10111111)

11000000.10101000.00000001.11000000
has host 192.168.1.192-255 (11000000 to 11111111)

So the netmask M divided the network into 4 equal subnets with 64 hosts each. There are some subnets which are much more complicated and have their applications in certain specific areas. I recommend going through Wikipedia page on Subnetworks to get some more idea. I have covered enough and now you can understand Wikipedia;s content on the topic without any difficulty.




Some Special IPs

0.0.0.0 = All IPs on local machine. Anything hosted on this IP is available to all devices on the network.

127.0.0.1 = LocalHost, this loops back to the machine itself.

255.255.255.255 = Broadcast, anything sent to this IP is broadcasted (like radio is broadcasted to everyone) to all hosts on the network.


Finally

You see the notation in this pic?  
This way of representing subnets using /24, /25, /26, etc. is quite useful while doing vulnerability scans on networks (using nmap, etc.). /24 represents the netmask 255.255.255.0 , the first example we took of Wireless router. It is the most common configuration you'll use while doing nmap scan. The one we discussed later, in the subnets section, is /26. It has 4 subnetworks. /25 has 2 subnets. /27 has 8. /31 has 128 subnets! In this subnet, only 2 host can be there per network, and it is used for 1 to 1 or point to point links. I hope the next time you have to deal with networks, you won't be having difficulties. There are topic like Multicast etc. which build up on this, and you can do further reading on them. That was all for this tutorial. Good luck.

61 comments:

  1. Replies
    1. Emails = exploit dot tools4u at gmail dot com
      Wickr = peeterhacks
      TG/ICQ = @killhacks
      WA = +92 317 2721122

      SSN DOB DL FULLZ
      HIGH CREDT SCORES FULLZ
      CC FULZZ WITH CVV
      DUMPS
      EIN FULLZ
      COMBOS
      LOGS
      TOOLS & TUTORIALS
      LOAN METHODS
      MAILERS
      SMS SENDERS
      TAX RETURN FILLING LEADS/PROS
      I.P's/PROXIES
      HACKING TOOLS
      CRDING METHODS

      Emails = exploit dot tools4u at gmail dot com
      Wickr = peeterhacks
      TG/ICQ = @killhacks
      WA = +92 317 2721122

      Delete
  2. Thank you Shashwat! This was really helpful.

    ReplyDelete
  3. Replies
    1. i also want to hack a fb account but how i can do such

      Delete
  4. Thanks for the article. I found two errors. You need to fix them.

    First error.

    Wrong:

    ~M = 00000000.00000000.00000000.11111111 (0.255.255.255)

    A&~M= 11000000.10101000.00000001.00000000 (0.0.0.1)

    Right:

    ~M = 00000000.00000000.00000000.11111111 (0.0.0.255)

    A&~M= 00000000.00000000.00000000.00000001 (0.0.0.1)

    Second error.

    Wrong:

    M = 11111111.11111111.11111111.11000000 (255.255.255.0)

    Right:

    M = 11111111.11111111.11111111.11000000 (255.255.255.192)

    ReplyDelete
    Replies
    1. Thanks for the corrections. I have made the necessary updates. I was too hasty when writing the dot decimal notation I suppose.

      Delete
    2. Shashwat, maybe I'm too picky, but the binary notation also needs to be corrected.
      If
      A = 11000000.10101000.00000001.00000001 (192.168.1.1)
      ~M = 00000000.00000000.00000000.11111111 (0.0.0.255)
      then
      A&~M= 11000000.10101000.00000001.00000000 (0.0.0.1) - wrong!
      A&~M= 00000000.00000000.00000000.00000001 (0.0.0.1) - right!
      That's all :)

      Delete
    3. Thanks for pointing that one out too :)

      Delete
  5. you should correct that line
    A&~M= 11000000.10101000.00000001.00000000 (0.0.0.1)

    ReplyDelete
  6. "Thus, the 2 most significant (rightmost)"
    it must be least

    ReplyDelete
    Replies
    1. sorry, most is correct one. wrong one is rightmost, its leftmost

      Delete
  7. Interesting, yet over my head. You offer a novice level guide?

    ReplyDelete
  8. how to hack wordpress sites in kali linux......tutorial plz........

    ReplyDelete
  9. Awesome, had a class about this. Everything's seems to be correct and you kept the explanations on a low level that helps many beginners.
    Keep up the good work!

    ReplyDelete
  10. really good work ! good stuff for noobies !
    great job (y)
    do u have any tutorial on advance stuff?

    ReplyDelete
  11. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. https://192-168-i-i.com

    ReplyDelete
  12. I needed to thank you for this incredible read!! I unquestionably adored each and every piece of it. I have you bookmarked your site to look at the new stuff you post. bezoek website

    ReplyDelete
  13. I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job! Meer hierover leest je hier

    ReplyDelete
  14. My friend recommended this blog and he was totally right keep up the fantastic work! Privacy Online

    ReplyDelete
  15. You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this... 192.168 49.1

    ReplyDelete
  16. Thanks for the blog filled with so many information. Stopping by your blog helped me to get what I was looking for. Now my task has become as easy as ABC. https://192-168-i-i.com

    ReplyDelete
  17. 192.168.l.254 This IP address is used by the routers like TP-Link, Netgear, D-Link uses it as the default IP address.

    ReplyDelete
  18. An IP address is a product address and intended to permit have on one system to speak with a host on an alternate system paying little heed to the kind of LANs the hosts are partaking in. Expert Circle

    ReplyDelete
  19. Great post I would like to thank you for the efforts you have made in writing this interesting and knowledgeable article.192.168.1.254

    ReplyDelete


  20. Routers are the most important devices that are required to get the internet connectivity. There are many brands and router models around the globe. Most people use multiple brand routers, they don't know how to configure them for the perfect usage. Here at
    192.168.0.1 we have all the manuals for configuring the router login pages.

    ReplyDelete
  21. Nanocell Networks Pvt Ltd could be a leading organization focused on bringing telecom training solutions everywhere the world. We come up with numerous beneficial telecom training courses on wireless technologies circuit core network, packet core network, transmission technologies and etc. We also provide you 5G Wireless Training to form a bright future on wireless technologies.

    ReplyDelete
  22. Many homework on the continual hunt along with offstage on the road to winning. Definitely not attached, simple to-fall as a result of wayside; And not investigation, afterward into a path travel toward the black. گاد بت

    ReplyDelete

  23. 192.168.l 254

    192.168.0.1 password
    IP address can be used to change the name of the Wi-Fi, control the number of devices that are connected at a time to the network and much more.

    ReplyDelete
  24. I can recommend primarily decent and even responsible tips, as a result view it: top article

    ReplyDelete
  25. This type of message always inspiring and I prefer to read quality content, so happy to find good place to many here in the post, the writing is just great, thanks for the post. Computer monitors in kenya

    ReplyDelete
  26. An organization is a gathering of PCs, printers, and different gadgets that are associated along with links. The sharing of information and assets. Data goes over the links, permitting network clients to trade records and information with one another, print to similar printers, and for the most part share any equipment or programming that is associated with the organization.group discussion online

    ReplyDelete
  27. Whilst by opting for an affordable hosting plan does not mean settling for poor support or less features, it is however important to be able to differentiate the cheap hosting companies from the cheap & nasty hosting companies that can cause you financial harm as well as to your reputation. It is important to be able to choose both the right web hosting plan for your needs as well as to ensure that the web host will live up to its promises and leave you in the dark with no service, website or email... https://hostinglelo.in/

    ReplyDelete
  28. Proxy and proxy server are two terms used by intermediate internet users. A proxy refers to a website, which can be used to blocked information. her explanation

    ReplyDelete
  29. Hi there very cool web site!! Guy .. Beautiful .. Superb .. I’ll bookmark your website and take the feeds additionally…I’m satisfied to search out a lot of helpful info here in the post, we need work out extra techniques on this regard, thank you for sharing. . . . . . White House Market Link

    ReplyDelete
  30. I simply could not depart your site before suggesting that I really loved the usual information an individual supply in your visitors? Is gonna be again frequently to inspect new posts. white house market

    ReplyDelete
  31. This report is based on the training and experience gathered during my six months attachment in the Technical support/Installations department at Linkserve Ltd. best ip tracker

    ReplyDelete
  32. I am typically to blogging i genuinely appreciate your content. The content has really peaks my interest. I am about to bookmark your web site and keep checking for brand new data. learn linux for cloud computing

    ReplyDelete
  33. Switches are utilized for network division in light of the MAC addresses. Switches take a gander at the approaching edge's equipment addresses prior to choosing to either advance the edge or drop it.
    https://onohosting.com/

    ReplyDelete
  34. or a cell, however it can likewise run on a home PC utilizing, for instance Intel, or AMD processors, and its even fit for running on very good quality servers utilizing Sun Sparc CPU's or IBM power PC processors. Some Linux distro's can run one processor, while others can run numerous on the double. https://onohosting.com/

    ReplyDelete
  35. As with all aspects of running a business, the onus is on you to measure this Return on Investment (ROI) and act appropriately to ensure that you are where you want to be at all times. INDUSTRY

    ReplyDelete
  36. Emails = exploit dot tools4u at gmail dot com
    Wickr = peeterhacks
    TG/ICQ = @killhacks
    WA = +92 317 2721122

    SSN DOB DL FULLZ
    HIGH CREDT SCORES FULLZ
    CC FULZZ WITH CVV
    DUMPS
    EIN FULLZ
    COMBOS
    LOGS
    TOOLS & TUTORIALS
    LOAN METHODS
    MAILERS
    SMS SENDERS
    TAX RETURN FILLING LEADS/PROS
    I.P's/PROXIES
    HACKING TOOLS
    CRDING METHODS

    Emails = exploit dot tools4u at gmail dot com
    Wickr = peeterhacks
    TG/ICQ = @killhacks
    WA = +92 317 2721122

    ReplyDelete
  37. I am acquiring the necessary knowledge as a result of the precise information that you contributed. I appreciate your provision of this valuable information.
    fnaf

    ReplyDelete
  38. Shade canopies Houston offer a practical solution for protection against the intense Texas sun. These structures provide shade and comfort for outdoor spaces, including parks, patios, playgrounds, and commercial areas. Constructed with durable materials like UV-resistant fabrics, shade canopies reduce heat and offer sun protection, making them ideal for Houston’s hot climate. They come in various sizes, designs, and colors, and can be custom-built to meet specific needs.

    Shade canopies not only enhance the aesthetics of outdoor areas but also promote energy efficiency by reducing the need for air conditioning in adjacent buildings. Their versatility and durability make them a popular choice for residential and commercial use in Houston.

    ReplyDelete

  39. In networking, an IP address identifies devices on a network, ensuring they can communicate. It consists of a series of numbers, divided into four sections (IPv4) or eight groups. A netmask is used to determine which part of the IP address refers to the network and which part refers to the host. By applying the netmask, routers and computers can figure out whether another device is within the same network or needs to be accessed through a gateway.
    3rd dui in fairfax

    ReplyDelete
  40. Subnets, IP addresses, and netmasks are among the fundamentals of networking that are essential for controlling network traffic. A netmask specifies the range of addresses within a subnet, whereas an IP address allows a device on a network to be uniquely identified. By splitting big networks into smaller, easier-to-manage segments, subnets enable effective network organization. dui lawyer alexandria va For those facing DUI accusations, a DUI attorney in Alexandria, Virginia offers a skilled legal defense that aims to uphold client rights and lessen the consequences of a conviction. They investigate legal defenses to contest the case and closely review the evidence, including field sobriety testing and breathalyzer findings. They strive to get the best result for their clients and have in-depth understanding of Virginia DUI legislation.

    ReplyDelete

© Kali Tutorials, 2016. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Shashwat Chaudhary and Kali Tutorials with appropriate and specific direction to the original content.