Networking Basics
Basic Rules
- A system will be able to communicate with other system directly if it is in the same network
- Every system in the network has to have unique id.
Concepts/Terms to be understood
- TCP
- HTTP
- HTTPS
- ICMP
- UDP
- Subnetting
- CIDR
- DHCP Server
- DNS Server
- DNS Records (CNAME/C-Record and ANAME)
- Proxy Server
- Layer – 4 load balancing
- Layer -7 Load balancing
- Reverse Proxy
- Subnets
- Routing
- Gateway
- NAT Servers
- NAT/Bridge Connections
- VPN
Network
- Collection of Systems (hosts)
- Every network is identified by network id
Note
- Packets can be sent from one network to other network using router.
IP Address
- Uniquely identify a host/system on the network
- IP Address = Network id + host id
- now enter the following
ipconfig
IPv4 Address. . . . . . . . . . . : 192.168.0.117
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : fe80::f68c:ebff:feab:37ff%20
192.168.0.1
# linux
ifconfig
-
Subnet Mask:
- Helps in finding network id and host id
- Also helps in determining size of the network.
-
Default Gateway: ipaddress of your router
-
IP Formats
- IpV4
- IPV6
IPV4
- IPV4 is a 4 byte (32 bit) representation
- Example:
192.168.0.10
10.40.100.9
77.89.34.8
- 1 byte = 8 bits => each bit => 0 or 1
- => Total combinations => 2^8
- Number range in byte => 0 to 255
Size of network
- We need ip address and subnet mask
ip: 192.168.10.11
sm: 255.255.255.0
nid: 192.168.10
hid: 11
size of hid: 8 bits => 2^8-1-1 => 254
ip: 172.16.0.8
sm: 255.255.0.0
nid: 172.16
hid: 0.8
size of network => 2^16-2
ip: 10.0.0.7
sm: 255.0.0.0
nid: 10
hid: 0.0.7
size of network => 2^24-2
- Size of network: 2^n-2
- n => number of bits for host id
- one ip address (all zeros) cannot be used bcoz of network id and other ip (all 1’s) bcoz of broadcast ip
Scenario-1: Create a network which should connect 200 devices
- Subnet mask will be 255.255.255.0 ~> 254
Scenario-2: Create a network which should connect 400 devices
- Subnet mask will be 255.255.0.0 ~> 65000
Solution for ip address
- Go for Class Based Ranges. Refer Here
- Class A
- Class B
- Class C
- Class D
- Class E
- CIDR:
- Lets relook how we calculated network sizes
ip: 192.168.10.11
sm: 255.255.255.0
* SM is considered as decimal number
ip: 192.168.10.11
sm: 255.255.255.0
nid: 192.168.10
hid: 11
size = 2^8-2
* consider SM as binary, all sequence of 1's is network id and all sequence of zero's is host id
ip: 192.168.10.10
SM: 11111111.11111111.11111111.00000000
bits of zeros => 8 => 2^8-2 = 254
ip: 192.168.10.10
SM: 11111111.11111111.11111110.00000000
bits of zeros => 9 => 2^9-2 ~ 500
- Each subnet mask has following combinations
11111111 => 255
11111110 => 254
11111100 => 252
11111000 => 248
11110000 => 240
11100000 => 224
11000000 => 192
10000000 => 128
- Same Subnet masks can be represented in CIDR format
ip: 192.168.0.0
sm: 255.255.254.0
sm: 11111111.11111111.11111110.00000000
cidr => 192.168.0.0/23
- another example
ip 10.0.0.8
sm: 255.255.128.0
sm: 11111111.11111111.10000000.00000000
10.0.0.8/17
Scenario-1: Create a network which should connect 200 devices (Revisited)
- CIDR => 192.168.0.0/24
Scenario-2: Create a network which should connect 400 devices (Revisited)
- CIDR => 192.168.0.0/23
Scenario -3 Create a network which should connect to 600 devices
- Try to find a least value of x so that
(2)^x >= 600
value of x is 10
cidr => 192.168.0.0/22
Scenario -4 Find a cidr which can connect to 2000 devices
2^x >= 2000
x=> 11
cidr => 192.168.0.0/21
CIDR Ranges reserved for private usage
- 10.0.0.0/8 => 10.0.0.0 – 10.255.255.255
- 172.16.0.0/12 => 172.16.0.0 – 172.31.255.255
- 192.168.0.0/16 => 192.168.0.0 – 192.168.255.255
