Tuesday, June 9, 2015

Subnets, netmask and slash notation or CIDR

Netmasks group IP addresses.

There are the basic A,B,C class networks :

   1st address   Last address      Netmask per network

A:   0.0.0.0 ... 127.255.255.255   255.0.0.0
B: 128.0.0.0 ... 191.255.255.255   255.255.0.0
C: 192.0.0.0 ... 223.255.255.255   255.255.255.0
 
CIDR instead of limiting the network size to 245, 64k or 16M it uses any power of 2 for the network size. It sees the netmask as a 32 bit number instead of 4 bytes.

The CIDR (Classless Inter-Domain Routing) is the number of 1 from left to right in the netmask.

11111111 11111111 11111111 00000000 = 255.255.255.0 = /24 =   256 ips in the network  (2^8) 32-24=8 bits
11111111 11111111 11111100 00000000 = 255.255.252.0 = /22 = 1024 ips in the network (2^10)  32-22=10 bits

Netmask: 255.255.255.252 or /30
Starts with multiple of 4
0 - 3 | 4-7 | 8-11 | 12-15 | ..... | 252-255

Binary                             Hex        Quad Dec          2ⁿ    CIDR   Number of addresses

00000000000000000000000000000000   00000000   0.0.0.0           2³²   /0     4,294,967,296     4 G
10000000000000000000000000000000   80000000   128.0.0.0         2³¹   /1     2,147,483,648     2 G
11000000000000000000000000000000   C0000000   192.0.0.0         2³⁰   /2     1,073,741,824     1 G
11100000000000000000000000000000   E0000000   224.0.0.0         2²⁹   /3       536,870,912   512 M
11110000000000000000000000000000   F0000000   240.0.0.0         2²⁸   /4       268,435,456   256 M
11111000000000000000000000000000   F8000000   248.0.0.0         2²⁷   /5       134,217,728   128 M
11111100000000000000000000000000   FC000000   252.0.0.0         2²⁶   /6        67,108,864    64 M
11111110000000000000000000000000   FE000000   254.0.0.0         2²⁵   /7        33,554,432    32 M
11111111000000000000000000000000   FF000000   255.0.0.0         2²⁴   /8        16,777,216    16 M
11111111100000000000000000000000   FF800000   255.128.0.0       2²³   /9         8,388,608     8 M
11111111110000000000000000000000   FFC00000   255.192.0.0       2²²   /10        4,194,304     4 M
11111111111000000000000000000000   FFE00000   255.224.0.0       2²¹   /11        2,097,152     2 M
11111111111100000000000000000000   FFF00000   255.240.0.0       2²⁰   /12        1,048,576     1 M
11111111111110000000000000000000   FFF80000   255.248.0.0       2¹⁹   /13          524,288   512 k
11111111111111000000000000000000   FFFC0000   255.252.0.0       2¹⁸   /14          262,144   256 k
11111111111111100000000000000000   FFFE0000   255.254.0.0       2¹⁷   /15          131,072   128 k
11111111111111110000000000000000   FFFF0000   255.255.0.0       2¹⁶   /16           65,536    64 k
11111111111111111000000000000000   FFFF8000   255.255.128.0     2¹⁵   /17           32,768    32 k
11111111111111111100000000000000   FFFFC000   255.255.192.0     2¹⁴   /18           16,384    16 k
11111111111111111110000000000000   FFFFE000   255.255.224.0     2¹³   /19            8,192     8 k
11111111111111111111000000000000   FFFFF000   255.255.240.0     2¹²   /20            4,096     4 k
11111111111111111111100000000000   FFFFF800   255.255.248.0     2¹¹   /21            2,048     2 k
11111111111111111111110000000000   FFFFFC00   255.255.252.0     2¹⁰   /22            1,024     1 k
11111111111111111111111000000000   FFFFFE00   255.255.254.0     2⁹    /23              512
11111111111111111111111100000000   FFFFFF00   255.255.255.0     2⁸    /24              256
11111111111111111111111110000000   FFFFFF80   255.255.255.128   2⁷    /25              128
11111111111111111111111111000000   FFFFFFC0   255.255.255.192   2⁶    /26               64
11111111111111111111111111100000   FFFFFFE0   255.255.255.224   2⁵    /27               32
11111111111111111111111111110000   FFFFFFF0   255.255.255.240   2⁴    /28               16
11111111111111111111111111111000   FFFFFFF8   255.255.255.248   2³    /29                8
11111111111111111111111111111100   FFFFFFFC   255.255.255.252   2²    /30                4
11111111111111111111111111111110   FFFFFFFE   255.255.255.254   2¹    /31                2
11111111111111111111111111111111   FFFFFFFF   255.255.255.255   2⁰    /32                1



Monday, June 8, 2015

Email protocols

There are 3 main email protocols used : POP3 and IMAP for mail retrieving and SMTP for sending emails.

Acronyms :
POP (Post Office Protocol)
IMAP (Internet Message access protocol)
SMTP (Simple mail transfer protocol)

POP3 downloads the emails from the server (and if not specified to keep a copy it also deletes the emails) - you have to make rules to filter the email on every client individually and if you lose the email client database you lose all your filters and emails.
Pop3 is good if you have a low email quota and you like your privacy (because as soon as an email is read is deleted from the server) 

IMAP synchronizes you folders and email from the server to you mail client and does not delete the messages unless you delete them.
Main advantage to imap is the it syncs your emails,folders etc the same way on any device.

POP3 : 110 and secure POP3 with SSL/TSL 995
IMAP : 143 and secure IMAP with SSL/TSL 993
SMTP : 25 and secure SMTL with SSL/TSL 465 

SMTP port is 25 and is usually blocked by the ISP to prevent spam by infected users.