Showing posts with label Networking. Show all posts
Showing posts with label Networking. Show all posts

Wednesday, 26 November 2014

IP Address Subnetting

IP Address Subnetting

IP Address Subnetting

Subnetting allows yout o create multiple logical networks that exists within a single class A, B, C.

There are so many reasons why we subnet:

a. It helps in the preservation of address space in other not to waste addresses.

b. It used for security.

c. It helps to control network traffic due to collisions of packets transmitted by other node 

(host) on the same segment.


Subnetting a Network Address


In order to subnet a network address, The  subnet mask has to be extended, using some of 

the bits from the host ID portion of the address to create a subnetwork ID. 

For example, given a Class C network of 192.17.5.0 which has a natural mask of 

255.255.255.0, you can create subnets in this manner:

192.17.5.0 - 11000000.00010001.00000101.00000000

255.255.255.224 - 11111111.11111111.11111111.11100000
                                                                                 
By extending the mask to be 255.255.255.224, you have borrowed three bits (indicated by 

"sub") from the original host portion of the address and used them to create subnets. With 

these three bits, it is possible to create eight subnets. With the remaining five host ID bits, 

each subnet can have up to 32 host, addresses, 30 of which can actually be assigned 

to a device on the same segment.These subnets have been created.





192.17.5.0 255.255.255.224 host address range 1 to 30


192.17.5.32 255.255.255.224 host address range 33 to 62


192.17.5.64 255.255.255.224 host address range 65 to 94


192.17.5.96 255.255.255.224 host address range 97 to 126


192.17.5.128 255.255.255.224 host address range 129 to 158


192.17.5.160 255.255.255.224 host address range 161 to 190


192.17.5.192 255.255.255.224 host address range 193 to 222


192.17.5.224 255.255.255.224 host address range 225 to 254



Another example:-

Given a class C network address of 192.168.1.0,  as a network administrator, you need to 

utilize this network address across multiple small groups within the organization. You can do 

this by subnetting this network with a subnet address.

All you have to do is , try to create 14 subnets of 14 nodes (hosts) each. This will limit us to 

196 nodes (hosts) on the network instead of 254 we would have without subnetting. To 

accomplished this we begin with the default network mask for class C

255.255.255.0 (11111111.11111111.11111111.00000000) binary

255.255.255.240 (11111111.11111111.11111111.11110000) binary

Remember the cram table:-

   1     1    1   1  1  1  1  1

  128 64  32 16  8  4  2  1 (128+64+32+16+8+4+2+1=255)

Look at this because you will always come across it during subnetting

128+64 =192

128+64+32 =224

128+64+32+16=240

128+64+32+16+8=248

128+64+32+16+8+4=252 an so on!

So to give us 16 possible network numbers, 2 of which cannot be used:-

192.168.1.0 (Reserved)

Network address     hosts address,       broadcast address

192.168.1.16             192.168.1.17 – 30    192.168.1.31

192.168.1.32             192.168.1.33 - 46     192.168.1.47

192.168.1.48             192.168.1.49 – 62    192.168.1.63

192.168.1.64             192.168.1.65 – 78    192.168.179

192.168.1.80 (keep adding 16 till you get to 224)

That will give you up to 14 networks shared among 14 hosts (nodes).

Saturday, 22 November 2014

What is an IP address?

What is an IP address?

Image Source: Wisegeek

A Brief Overview of IP Addresses


An IP address (Internet Protocol address) is an assigned numerical label that is used to 
identify Internet communicating devices on a computer network. Think of it like this: An IP address is to a computer what a telephone number is to a house. Each computer or house 
can stand alone without its respective IP address or telephone number. However, if you want 
to be able to communicate with people in other houses from within your house, you will need a telephone number. In a like manner, if you would like to communicate with other computers 
from yours, you will need an IP address.


Technical Facts about an IP Address


  • An IP address is a set of four numbers divided by periods
  • The numbers of an IP address range from 0 to 255


In more technical terms:


  • An IP address is a 32 bit binary number that is divided into four sections by periods
  • Each individual set of numbers in an IP address is called an octet
  • There are four octets in an IP address and each octet is 8 bits
  • An octet can range from 0 to 255 in value. (255 is the largest number that you can represent with 8 bits)


Internal vs External IP Addresses


If you are using a home router then you likely have both an External and Internal IP address.
Your External IP address will be issued to you by your ISP (Internet Service Provider). 
Because an IP address acts as identification number, no two computers on the Internet can have the same External IP address. Your External IP address will be the IP address that is 
used to contact your computer by the outside world.

Everything connected on your side of your router is in your local network and is designated a uniqueInternal IP address. In most cases, Internal IP addresses are issued by your router, but you may set a static IP address for the nodes in your local network. 
There are some IP address ranges that are commonly used for internal networks. Here are a few examples of what these addresses look like:

192.168.x.x
10.0.x.x
10.1.x.x
172.x.x.x

Where x can represent any number from 0 to 255.
Static vs Dynamic IP Addresses

Dynamic IP addresses are IP addresses that are vended by a router to a node when necessary. As their name would suggest Dynamic IP addresses are not fixed and are subject to change. Dynamic IP addresses are a handy network function but they can cause problems when trying to do more advanced networking proceedures like port forwarding. If the IP address to which you port forward changes, then your port forwards no longer work.

Static IP addresses are unchanging IP addresses that are assigned to a network node. Static IP addresses will never change. When using Static IP addresses you lose a small amount of plug and play functionality, but you gain reliability. 
Please note that for almost all purposes regarding port forwarding you will only need to set up a static Internal IP address.

IP "Classful" Addressing Overview and Address Classes 


When the first precursor of the Internet was developed, some of the requirements of the internetwork, both present and future, were quickly realized. The Internet would start small but eventually grow. It would be shared by many organizations. Since it is necessary for all IP addresses on the internetwork to be unique, a system had to be created for dividing up the available addresses and share them amongst those organizations. A central authority had to be established for this purpose, and a scheme developed for it to effectively allocate addresses.
The developers of IP recognized that organizations come in different sizes and would therefore need varying numbers of IP addresses on the Internet. They devised a system whereby the IP address space would be divided into classes, each of which contained a portion of the total addresses and were dedicated to specific uses. Some would be devoted to large networks on the Internet, while others would be for smaller organizations, and still others reserved for special purposes.
Since this was the original system, it had no name; it was just “the” IP addressing system. Today, in reference to its use of classes, it is called the “classful” addressing scheme, to differentiate it from the newer classless scheme. As I said at the end of the introduction to this section, “classful” isn't really a word, but it's what everyone uses.

IP Address Classes


There are five classes in the “classful” system, which are given letters A through E. Table  provides some general information about the classes, their intended uses and other general characteristics about them:


Looking at this table you can see that the first three, classes A, B and C, comprise most of the total address space (7/8ths of it). These are the classes used for unicast IP addressing, which means for messages sent to a single network interface. (The blocks also include associated broadcast addresses for these networks.) This is what we usually consider “normal” IP addressing. You can think of classes A, B and C as the “papa bear”, “mama bear” and “baby bear” of traditional IP addressing. They allow the Internet to provide addressing for a small number of very large networks, a moderate number of medium-sized organizations, and a large number of smaller companies. This approximately reflects the distribution of organization sizes, approximately, in the real world, though the large gulf in the maximum number of hosts allowed for each address class leads to inflexibility and problems.

As you can see, the classes differ in the place where the “dividing line” is drawn between the network ID and the host ID portions of the addresses they contain. However, in each case the division is made on octet boundaries: in classful addressing, the division does not occur within an octet.


 Division of IPv4 Address Space Into Classes



Classes D and E are special—to the point where many people don't even realize they exist. Class D is used for IP multicasting, while class E was reserved for “experimental use”.

The “classful” IP addressing scheme divides the total IP address space into five classes, A through E. One of the benefits of the relatively simple “classful” scheme is that information about the classes is encoded directly into the IP address. This means we can determine in advance which address ranges belong to each class. It also means the opposite is possible: we can identify which class is associated with any address by examining just a few bits of the address.
This latter benefit was one of the main motivators for the initial creation of the “classful” system, as we saw in the previous topic.

"Classful" Addressing Class Determination Algorithm


When TCP/IP was first created computer technology was still in its infancy, compared to its current state. Routers needed to be able to quickly make decisions about how to move IP datagrams around. The IP address space was split into classes in a way that looking at only the first few bits of any IP address would tell the router where to “draw the line” between the network ID and host ID, and thus what to do with the datagram.
The number of bits the router needs to look at may be as few as one or as many as four, depending on what it finds when it starts looking. The algorithm used corresponds to the system used to divide the address space; it involves four very basic steps.






If the first bit is a “0”, it's a class A address and we're done. (Half the address space has a “0” for the first bit, so this is why class A takes up half the address space.) If it's a “1”, continue to step two.
If the second bit is a “0”, it's a class B address and we're done. (Half of the remaining non-class-A addresses, or one quarter of the total.) If it's a “1”, continue to step three.
If the third bit is a “0”, it's a class C address and we're done. (Half again of what's left, or one eighth of the total.) If it's a “1”, continue to step four.
If the fourth bit is a “0”, it's a class D address. (Half the remainder, or one sixteenth of the address space.) If it's a “1”, it's a class E address. (The other half, one sixteenth.)
And that's pretty much it.

In the preceding topics I introduced the concepts of IP address classes and showed how the classes related to ranges of IP addresses. Of the five classes, D and E are dedicated to special purposes, so I will leave those alone for now. Classes A, B and C are the ones actually assigned for normal (unicast) addressing purposes on IP internetworks, and therefore the primary focus of our continued attention.
As we've seen, they differ in the number of bits (and octets) used for the network ID compared to the host ID. The number of different networks possible in each class is a function of the number of bits assigned to the network ID, and likewise, the number of hosts possible in each network depends on the number of bits provided for the host ID. We must also take into account the fact that one, two or three of the bits in the IP address is used to indicate the class itself, so it is effectively "excluded" from use in determining the number of networks (though again, it is still part of the network ID).
Based on this information, we can calculate the number of networks in each class, and for each class, the number of host IDs per network shows the calculations.


Let's walk through one line of this table so we can see how it works. I'll stick with class B since it's "in the middle". The basic division is into 16 bits for network ID and 16 bits for host ID. However, the first two bits of all class B addresses must be "10”, so that leaves only 14 bits to uniquely identify the network ID. This gives us a total of 214 or 16,384 class B network IDs. For each of these, we have 216 host IDs, less two, for a total of 65,534.
Why less two? For each network ID, two host IDs cannot be used: the host ID with all zeroes and the ID with all ones. These are addresses with "special meanings" as described in the topic that follows. You will also notice that 2 has been subtracted from the number of network IDs for class A. This is because two of the class A network IDs (0 and 127) are reserved. There are actually several other address ranges that are set aside in all three of the classes that I haven't shown here. They are listed in the topic on reserved, private and loopback addresses. (The exclusion of 0 and 127 from class A is probably the best-known address range reservation which is why I am explicit with that one in the table above.)

As you can see, there is quite a disparity in the number of hosts available for each network in each of these classes. What happens if an organization needs 1,000 IP addresses? They have to either use four class Cs or use one class B (and in so doing waste over 90% of the possible addresses in the class B network.) Bear in mind that there are only about 16,000 class B network IDs available worldwide and you begin to understand one of the big problems with "classful" addressing.
What is PORT?

What is PORT?

What is a Port?


Ports are virtual pathways on which Internet data flows. You probably know that data on the Internet is sent to and from IP addresses. If you are not sure about what an IP address is then check out our What is an IP Address guide. What you might not have known is that all data sent to an IP address is sent on specific ports.
If we think of an IP address as a telephone number, (an identifying number that allows communication between two locations), then we can think of ports as telephone number extensions. Suppose you wanted to make a telephone call to a major corporation; Ford for example. If Ford only had one simple telephone line it would take a very long time for your call to finally get through. However, by using telephone number extensions, Ford can channel incoming calls to the proper locations and as a result handle many calls on one line as opposed to just one call.
Ports are like telephone number extensions as they allow multiple pieces of data to flow back and forth on a single IP address. In fact, port numbers are appended to the end of IP addresses just as extensions are appended to telephone numbers.
In other words, ports are numerical identifiers that make it possible for you to check your email and browse the web at the same time. Technically speaking, this is possible because browsing the web traffic generally uses port 80, and getting your email generally uses port 110.

Image Source: Insecure.org

Technical Facts about Ports

  • Ports are a 16-bit number can range from 1-65535
  • TCP and UDP packets specify the port on which they are to be sent in their packet header
  • The ports that a given application uses are generally set by the programmers of that application

Ports in Relation to Port Forwarding


Now that you know what ports are, how do you use that knowledge to your advantage? One way is to learn how to forward ports. Port forwarding is the simple action of telling your router to pass the information that it receives on a given port directly to a specific device on your network. This can decrease the delay in information reception resulting in increased performance of your applications. For more information on port forwarding, please see our What is Port Forwarding page.

Ports in Relation to IP Addresses


Remember at the top of this page when it was mentioned that ports are appended to the end of IP addresses just as extensions are appended to telephone numbers? There is a specific syntax for appending port numbers to IP addresses and it is as follows:
  • (IP Address):(Port Number) or..
  • 27.1.1.1:80
Notice the colon acting as a separator between the IP address and the Port Number. Port Numbers are appended to the end of all IP addresses whenever data is sent.

Why don't I see a port number appended to the end of web addresses?


There are a few commonly used port numbers. Web traffic uses port 80 and is in fact so common that port 80 is assumed to be appended to the end of a web address by your internet browser and thus can be left off. You can test this by typing google.com:80 into your browser's address bar. When you press enter, you should go straight to google. Now, try typing google.com:6060 into your browser's address bar. When you press enter, you will not be connected to google. For more information on common ports and which applications use them please see our Port List page.
In order to fully understand what ports are and how they work, you must first have a solid understanding of IP addresses. For more information on IP addresses click here.
What is Port-Forwarding?

What is Port-Forwarding?

What is Port Forwarding?


Port forwarding is a method of making a computer on your network accessible to computers on the Internet, even though you are behind a router.
It is commonly used for hosting game servers, peer to peer downloading, and voice over IP type applications. There are many other reasons you may need to forward a port, this is not an exhaustive list.

What are Ports?


Ports are virtual pathways on which information on the Internet travel. There are 65,536 ports to choose from. A good analogy is to think of ports like extensions on a phone sytstem.

What are some commonly used ports?


Every program on your computer that uses the internet is programmed to send its packets through specific ports. Sometimes the ports are selected arbitrarily by the programmers of the software, but other times programmers will use a more standard port depending on the functionality of the software. Here are a few examples of industry standard uses for common ports:
  • HTML pages: port 80
  • FTP file transferring: port 21
  • POP3 email: port 110
  • MSN Messenger: port 6901 and ports 6891-6900

Now that you have a basic understanding of port forwarding, let's dive a bit deeper
  1. Every device on the internet has at least one IP address.

  2. Every IP address is divided up into many ports. When one computer sends data to another computer, it sends it from a port on an IP address to a port on an IP address.

  3. A port can only be used by one program at a time.

With that out of the way, we should talk about NAT. NAT, or Network Address Translation, is a technology that allows each device on your network to have its own IP address.
While each device in your network has its own IP address, from the outside, every request coming out of all of those devices appears to be coming from the single publicly visible IP address assigned to you by your Internet Service Provider.
Lets say you want to browse the web. We suggest port forwarding. For instance, when you click on this link to our site, whythehack.blogspot.in, the request doesn't go straight out to the Internet. Instead, the request goes to your router, which makes a note of which internal device is requesting the information, then sends that request out to the Internet. When our web server responds, your router will know exactly which device to relay that response back to.
It works exactly the same in reverse! When a computer on the Internet requests, for example, a web page from your IP address, your router needs to figure out which internal device is a web server so the request can be filled. NAT can handle such requests in certain circumstances. For the rest, you need to know about port forwarding.
Luckily, you have almost all the information you need already. What if your router just doesn't know which internal device has a web server running? All you need to do is tell it: "Router, please send any requests for web pages to my server." That's what you'd say if this were Star Trek, but we're not quite there yet, so for now you need to sign in to your router's configuration utility and tell it which services are running on which internal devices.
For example ... Have an FTP server running on an internal computer with IP address 192.168.1.123? Tell your router to FORWARD all requests that come in on port 21 to 192.168.1.123. Need your internal web server to be accessible to the public? Forward port 80.
Sure, you can get complicated if you want, but for the most part it's just that easy.
Oh, you want to complicate things? Have TWO web servers running? Well, port forwarding can still come to the rescue. See, while each of your internal web servers might be answering on port 80 (192.168.0.2:80, 192.168.0.3:80), you can still make them both accessible on the Internet.
A diagram for how to forward two ports to two different computers
Say your public IP address is 20.1.1.1. You can make up a forwarding rule in your router that says that all requests to http://20.1.1.1:80 should be forwarded to 192.168.0.2:80, and all requests to http://20.1.1.1:8080 should be forwarded to 192.168.0.3:80! No need to pick and choose. That works when we have the easy ability to change the port that is requested as in the example above. A bigger problem arises when you can't change the requested port, perhaps because you're using an application that won't allow you to specify an alternate port. Remember #3 way up above? It says that a port can only be used by one program at a time, so if we want to have two web servers, we can't have them BOTH answer on 20.1.1.1:80. The router wouldn't know which internal device to forward the request to! This is a reasonably big pitfall for those new to port forwarding.
List of TCP and UDP Ports

List of TCP and UDP Ports

List of TCP and UDP Ports


0
1tcpmux
3
4
5rje
7echo
9discard
11systat
13daytime
15netstat
17qotd
18send/rwp
19chargen
20ftp-data
21ftp
22ssh, pcAnywhere
23Telnet
25SMTP
27ETRN
29msg-icp
31msg-auth
33dsp
37time
38RAP
39rlp
40
41
42nameserv, WINS
43whois, nickname
49TACACS, Login Host Protocol
50RMCP, re-mail-ck
53DNS
57MTP
59NFILE
63whois++
66sql*net
67bootps
68bootpd/dhcp
69Trivial File Transfer Protocol (tftp)
70Gopher
79finger
80www-http
87
88Kerberos, WWW
95supdup
96DIXIE
98linuxconf
101HOSTNAME
102ISO, X.400, ITOT
105cso
106poppassd
109POP2
110POP3
111Sun RPC Portmapper
113identd/auth
115sftp
116
117uucp
118
119NNTP
120CFDP
123NTP
124SecureID
129PWDGEN
133statsrv
135loc-srv/epmap
137netbios-ns
138netbios-dgm (UDP)
139NetBIOS
143IMAP
144NewS
150
152BFTP
153SGMP
156
161SNMP
175vmnet
177XDMCP
178NextStep Window Server
179BGP
180SLmail admin
199smux
210Z39.50
213
218MPP
220IMAP3
256
257
258
259ESRO
264FW1_topo
311Apple WebAdmin
350MATIP type A
351MATIP type B
360
363RSVP tunnel
366ODMR (On-Demand Mail Relay)
371
387AURP (AppleTalk Update-Based Routing Protocol)
389LDAP
407Timbuktu
427
434Mobile IP
443ssl
444snpp, Simple Network Paging Protocol
445SMB
458QuickTime TV/Conferencing
468Photuris
475
500ISAKMP, pluto
511
512biff, rexec
513who, rlogin
514syslog, rsh
515lp, lpr, line printer
517talk
520RIP (Routing Information Protocol)
521RIPng
522ULS
531IRC
543KLogin, AppleShare over IP
545QuickTime
548AFP
554Real Time Streaming Protocol
555phAse Zero
563NNTP over SSL
575VEMMI
581Bundle Discovery Protocol
593MS-RPC
608SIFT/UFT
626Apple ASIA
631IPP (Internet Printing Protocol)
635mountd
636sldap
642EMSD
648RRP (NSI Registry Registrar Protocol)
655tinc
660Apple MacOS Server Admin
666Doom
674ACAP
687AppleShare IP Registry
700buddyphone
705AgentX for SNMP
901swat, realsecure
993s-imap
995s-pop
999
1024
1025
1050
1062Veracity
1080SOCKS
1085WebObjects
1100
1105
1114
1227DNS2Go
1234
1243SubSeven
1338Millennium Worm
1352Lotus Notes
1381Apple Network License Manager
1417Timbuktu
1418Timbuktu
1419Timbuktu
1420
1433Microsoft SQL Server
1434Microsoft SQL Monitor
1477
1478
1490
1494Citrix ICA Protocol
1498
1500
1503T.120
1521Oracle SQL
1522
1524
1525prospero
1526prospero
1527tlisrv
1529
1547
1604Citrix ICA, MS Terminal Server
1645RADIUS Authentication
1646RADIUS Accounting
1680Carbon Copy
1701L2TP/LSF
1717Convoy
1720H.323/Q.931
1723PPTP control port
1731
1755Windows Media .asf
1758TFTP multicast
1761
1762
1808
1812RADIUS server
1813RADIUS accounting
1818ETFTP
1968
1973DLSw DCAP/DRAP
1975
1978
1979
1985HSRP
1999Cisco AUTH
2000
2001glimpse
2005
2010
2023
2048
2049NFS
2064distributed.net
2065DLSw
2066DLSw
2080
2106MZAP
2140DeepThroat
2301Compaq Insight Management Web Agents
2327Netscape Conference
2336Apple UG Control
2345
2427MGCP gateway
2504WLBS
2535MADCAP
2543sip
2565
2592netrek
2727MGCP call agent
2766
2628DICT
2998ISS Real Secure Console Service Port
3000Firstclass
3001
3031Apple AgentVU
3052
3128squid
3130ICP
3150DeepThroat
3264ccmail
3283Apple NetAssitant
3288COPS
3305ODETTE
3306mySQL
3352
3389RDP Protocol (Terminal Server)
3520
3521netrek
3879
4000icq, command-n-conquer
4045
4144
4242
4321rwhois
4333mSQL
4444
47017
4827HTCP
5000
5001
5002
5004RTP
5005RTP
5010Yahoo! Messenger
5050
5060SIP
5135
5150
5190AIM
5222
5353
5400
5500securid
5501securidprop
5300
5423Apple VirtualUser
5555
5556
5631PCAnywhere data
5632PCAnywhere
5678
5800VNC
5801VNC
5900VNC
5901VNC
5843
6000X Windows
6112BattleNet
6050
6499
6500
6502Netscape Conference
6547
6548
6549
6666
6667IRC
6670VocalTec Internet Phone, DeepThroat
6699napster
6776Sub7
6968
6969
6970RTP
6971
7000
7007MSBD, Windows Media encoder
7070RealServer/QuickTime
7161
7323
7777
7778Unreal
7640
7648CU-SeeMe
7649CU-SeeMe
7654
8000
8002
8010WinGate 2.1
8080HTTP
8100
8181HTTP
8383IMail WWW
8765
8875napster
8888napster
8890
9000
9090
9200
9704
9669
9876
9989
10008cheese worm
10752
12345
11371PGP 5 Keyserver
12346
13000
13223PowWow
13224PowWow
14000
14237Palm
14238Palm
14690
16969
18888LiquidAudio
21157Activision
22555
22703
22793
23213PowWow
23214PowWow
23456EvilFTP
26000Quake
27000
27001QuakeWorld
27010Half-Life
27015Half-Life
27374
27444
27665
27910
27960QuakeIII
28000
28001
28002
28003
28004
28005
28006
28007
28008
30029AOL Admin
30100
30101
30102
30103
30303
30464
31335
31337Back Orifice
32000
32771
32777rpc.walld
34555
40193Novell
41524arcserve discovery
45000Cisco NetRanger postofficed
50505
52901
54321
61000
65301
Multicasthidden
ICMP Typehidden
9998
32773rpc.ttdbserverd
32776rpc.spray
32779rpc.cmsd
38036timestep