TCP/IP Flashcards
What is DHCP and How DHCP Works? Dynamic Host Configuration Protocol
DORA - Discover/Offer/Request/Ack
- DHCPDISCOVER
It is a DHCP message that marks the beginning of a DHCP interaction between client and server. This message is sent by a client (host or device connected to a network) that is connected to a local subnet. It’s a broadcast message that uses 255.255.255.255 as destination IP address while the source IP address is 0.0.0.0 - DHCPOFFER
It is DHCP message that is sent in response to DHCPDISCOVER by a DHCP server to DHCP client. This message contains the network configuration settings for the client that sent the DHCPDISCOVER message. - DHCPREQUEST
This DHCP message is sent in response to DHCPOFFER indicating that the client has accepted the network configuration sent in DHCPOFFER message from the server. - DHCPACK
This message is sent by the DHCP server in response to DHCPREQUEST recieved from the client. This message marks the end of the process that started with DHCPDISCOVER. The DHCPACK message is nothing but an acknowledgement by the DHCP server that authorizes the DHCP client to start using the network configuration it received from the DHCP server earlier. - DHCPNAK
This message is the exact opposite to DHCPACK described above. This message is sent by the DHCP server when it is not able to satisfy the DHCPREQUEST message from the client. - DHCPDECLINE
This message is sent from the DHCP client to the server in case the client finds that the IP address assigned by DHCP server is already in use. - DHCPINFORM
This message is sent from the DHCP client in case the IP address is statically configured on the client and only other network settings or configurations are desired to be dynamically acquired from DHCP server. - DHCPRELEASE
This message is sent by the DHCP client in case it wants to terminate the lease of network address it has be provided by DHCP server.
Now as we know about the various DHCP messages, it’s time to go through the the complete DHCP process to give a better Idea of how DHCP works. Note that the steps mentioned below assume that DHCP functionality is enabled by default on the client side.
Here are the steps :
Step 1: When the client computer (or device) boots up or is connected to a network, a DHCPDISCOVER message is sent from the client to the server. As there is no network configuration information on the client so the message is sent with 0.0.0.0 as source address and 255.255.255.255 as destination address. If the DHCP server is on local subnet then it directly receives the message or in case it is on different subnet then a relay agent connected on client’s subnet is used to pass on the request to DHCP server. The transport protocol used for this message is UDP and the port number used is 67. The client enters the initializing stage during this step.
Step 2: When the DHCP server receives the DHCPDISCOVER request message then it replies with a DHCPOFFER message. As already explained, this message contains all the network configuration settings required by the client. For example, the yaddr field of the message will contain the IP address to be assigned to client. Similarly the the subnet mask and gateway information is filled in the options field. Also, the server fills in the client MAC address in the chaddr field. This message is sent as a broadcast (255.255.255.255) message for the client to receive it directly or if DHCP server is in different subnet then this message is sent to the relay agent that takes care of whether the message is to be passed as unicast or broadcast. In this case also, UDP protocol is used at the transport layer with destination port as 68. The client enters selecting stage during this step
Step 3: The client forms a DHCPREQUEST message in reply to DHCPOFFER message and sends it to the server indicating it wants to accept the network configuration sent in the DHCPOFFER message. If there were multiple DHCP servers that received DHCPDISCOVER then client could receive multiple DHCPOFFER messages. But, the client replies to only one of the messages by populating the server identification field with the IP address of a particular DHCP server. All the messages from other DHCP servers are implicitly declined. The DHCPREQUEST message will still contain the source address as 0.0.0.0 as the client is still not allowed to use the IP address passed to it through DHCPOFFER message. The client enters requesting stage during this step.
Step 4: Once the server receives DHCPREQUEST from the client, it sends the DHCPACK message indicating that now the client is allowed to use the IP address assigned to it. The client enters the bound state during this step.
The Concept of Lease
With all the necessary information on how DHCP works, one should also know that the IP address assigned by DHCP server to DHCP client is on a lease. After the lease expires the DHCP server is free to assign the same IP address to any other host or device requesting for the same. For example, keeping lease time 8-10 hours is helpful in case of PC’s that are shut down at the end of the day. So, lease has to be renewed from time to time. The DHCP client tries to renew the lease after half of the lease time has expired. This is done by the exchange of DHCPREQUEST and DHCPACK messages. While doing all this, the client enters the renewing stage.
What is Symmetrical encryption?
Symmetric encryption is a form of encryption where a secret key is used for both encryption and decryption of a message by both the client and the host. Effectively, any one possessing the key can decrypt the message being transferred.
Symmetrical encryption is often called shared key or shared secret encryption.
Symmetric keys are used to encrypt the entire communication during a SSH Session. Both the client and the server derive the secret key using an agreed method, and the resultant key is never disclosed to any third party. The process of creating a symmetric key is carried out by a key exchange algorithm. What makes this algorithm particularly secure is the fact that the key is never transmitted between the client and the host. Instead, the two computers share public pieces of data and then manipulate it to independently calculate the secret key. Even if another machine captures the publicaly shared data, it won’t be able to calculate the key because the key exchange algorithm is not known
What is Asymmetric encryption?
Asymmetrical encryption uses two separate keys for encryption and decryption. These two keys are known as the public key and the private key. Together, both these keys form a public-private key pair.
The public key, as the name suggest is openly distributed and shared with all parties. While it is closely linked with the private key in terms of functionality, the private key cannot be mathematically computed from the public key. The relation between the two keys is highly complex: a message that is encrypted by a machine’s public key, can only be decrypted by the same machine’s private key. This one-way relation means that the public key cannot decrypt its own messages, nor can it decrypt anything encrypted by the private key.
The private key must remain private i.e. for the connection to be secured, no third party must ever know it. The strength of the entire connection lies in the fact that the private key is never revealed, as it is the only component capable of decrypting messages that were encrypted using its own public key.
What is hashing encryption?
One-way hashing is another form of cryptography used in Secure Shell Connections. One-way-hash functions differ from the above two forms of encryption in the sense that they are never meant to be decrypted. They generate a unique value of a fixed length for each input that shows no clear trend which can exploited. This makes them practically impossible to reverse.
Hash
It is easy to generate a cryptographic hash from a given input, but impossible to generate the input from the hash. This means that if a client holds the correct input, they can generate the crypto-graphic hash and compare its value to verify whether they possess the correct input.
SSH uses hashes to verify the authenticity of messages. This is done using HMACs, or Hash-based Message Authentication Codes. This ensures that the command received is not tampered with in any way.
While the symmetrical encryption algorithm is being selected, a suitable message authentication algorithm is also selected. This works in a similar way to how the cipher is selected, as explained in the symmetric encryption section.
Each message that is transmitted must contain a MAC, which is calculated using the symmetric key, packet sequence number, and the message contents. It is sent outside the symmetrically encrypted data as the concluding section of the communication packet.
What is link balancing?
Link balancing is designed to balance the load between the local area network (LAN) and the Internet. A link balancer is usually positioned between the LAN and the WAN (Wide Area Network).
Application Protocols
DNS DHCP LDAP HTTP FTP TFTP SNMP SMTP POP3 IMAP4 SMB
Network Protocols
IP4 IP6 ARP IGMP ICMP IPSec RIP OSPF
Reverse proxy vs Load Balancer
RP sends client’s request to a particular server, LB distributes traffic across LB
What is DNS Failover?
DNS failover helps websites or network services remain accessible in the event of outage. The Domain Name System (DNS) is the protocol used to translate human readable hostnames into IP addresses. By providing two or more IP address in a DNS record, each IP representing an identical server, you can move traffic from a failing server to a live, redundant server.
Load balancer fail over strategies?
Two load balancer master and standby, if one fails second one starts getting traffic, both need to be in same physical network with different IP
Another thing which can be done is keeping multiple LBs in different network and one with high routing cost(just a number, which says it takes this much hops to reach to this router) and other will small cost, that way every request is routed to the small one everytime, but when it fails the routers know about it and switch to the high cost one, both have same IP.
Types of LB?
L4 and L7. Also remember about SSL VIPs which indicate that the SSL termination happens on LB not on the service
Classfull networks
5 classes
A (devices) - Large networks 1st octet for network, rest 3 host
1st bit of the 1st octet is zero, therefore it can range from 0-127
range - 1.0.0.0 to 126.0.0.0
B (devices) - medium networks first two octets for network, rest 2 host
range - 128.0.0.0 to 191.255.0.0
C (devices) - small networks first three octets for network, rest 1 for host
range - 192.0.0.0 to 233.255.255.0
D multicast
E Reserved
Types LB failures?
Least connections algo will end up in a black hole situation when every request goes through same server which is failing because of another service dependency
Queuing at LBs when the services are taking long time to serve a request
Classless networks
Moves away from classfull networks and introduces subnets with a mask
CIDR notation
/24 means first 24 bits of subnet mask is turned on, first 24 bits identify the network and rest identify the host