Unit 7 · Computer Networks & Cyber Security
Imagine internet is a big city.
DNS = Phonebook of city: You know name google.com but postman needs IP address 142.250.190.14 DNS translates name→IP hierarchical tree root . → com org → google.com → www.google.com Record Types A→IPv4 CNAME→alias MX→mail server NS→nameserver port 53 UDP default TCP zone transfer recursive query resolver does all work client gets final answer iterative resolver asks other servers step by step.
DHCP = Automatic house allotment: When you enter city you need IP address automatically DHCP assigns IP automatically to clients DORA Process 1 Discover Client broadcast to find DHCP server 2 Offer Server offers available IP + subnet gateway DNS 3 Request Client requests that IP 4 Acknowledge Server acknowledges and leases IP for set time Lease temporary must be renewed before expiry.
HTTP = Language of web browser and server: Request/Response protocol for web Request Methods GET→retrieve data POST→create/send new data PUT→update/replace DELETE→remove Status Codes 200 OK→success 404 Not Found→resource not found 500 Server Error→server failure HTTP header format Request GET /index.html HTTP/1.1 Host www.example.com User-Agent... Response HTTP/1.1 200 OK Content-Type text/html.
HTTPS = HTTP + TLS/SSL Encrypted connection via TLS/SSL lock icon port 443 HTTP port 80 unencrypted HTTPS port 443 encrypted certificate.
Email = Post Office System: SMTP Simple Mail Transfer Protocol port 25 send email push protocol MTA Mail Transfer Agent MUA Mail User Agent MDA Mail Delivery Agent sends mail from client to server to server. POP3 port 110 download delete from server offline old phone downloads once deletes from server no sync. IMAP port 143 993 keeps copy on server synchronization folders modern phone laptop both see same emails.
FTP = Courier service for files: Port 21 control 20 data Active mode server connects to client port 20 data connection from server to client problem with firewall Passive mode client connects to server both connections from client to server firewall friendly modern uses passive GET PUT LIST commands. Telnet port 23 unsecure plain text SSH port 22 secure encrypted remote login.
Security = Locks and keys: Symmetric SAME SECRET KEY for both encryption & decryption DES 56-bit old AES 128/192/256 modern FAST Efficient for large data Low cost CON Key Distribution Problem how to securely share key? Both parties must share same key beforehand risk! Plaintext --(same key)-->Ciphertext --(same key)-->Plaintext.
Asymmetric PUBLIC KEY & PRIVATE KEY pair RSA 1024/2048 Pros NO KEY DISTRIBUTION PROBLEM public key can be shared openly Cons SLOW more compute heavy used for small data Process Public key→encrypt Private key→decrypt.
Hashing One-way Irreversible Function checksum message digest Common Hashes MD5 SHA-1 SHA-256 Deterministic fixed length output tiny change=very different hash Use Data integrity check password storage ensuring no tampering Message --hash-->Hash e.g., SHA-256=a3f1b9d...
Digital Signature Purpose Verify AUTHENTICITY + NON-REPUDIATION How Sender hashes message→encrypts hash with their PRIVATE KEY Receiver decrypts hash using sender's PUBLIC KEY & compares to their own hash If match→Valid authentic untampered Proves message is from sender & not altered sender cannot deny.
Digital Certificate Issued by CA Certificate Authority Contains Public Key + Identity info domain/owner Signed by CA to verify legitimacy & trust.
SSL/TLS Handshake 1 Client→Server Hello supported ciphers random 2 Server→Client Certificate + chosen cipher 3 Client verifies Certificate via CA generates pre-master secret 4 Encrypt secret with Server's Public Key→send to server 5 Both derive same Session Key→now use Symmetric encryption for data Handshake uses Asymmetric for key exchange then Symmetric for fast data transfer.
Symmetric vs Asymmetric Comparison Table Symmetric Key Same key for both parties Speed Fast Use Case Bulk data encryption Problem Key distribution challenge Example DES AES 128/192/256 Asymmetric Key Public/Private pair Speed Slow Use Case Key exchange Digital Signature Problem Slower larger key size Example RSA 1024/2048 Key Takeaway Use ASYMMETRIC to securely share key→then switch to SYMMETRIC for fast data transfer.
Firewalls Types Packet Filter stateless filter IP port Protocol number Stateless simple fast Stateful Inspection tracks connection state table remembers connection knows if packet part of existing connection more secure Application Gateway proxy firewall application level understands HTTP FTP proxy acts on behalf of client hides internal network.
IDS Intrusion Detection System NIDS Network monitors network traffic HIDS Host monitors host system logs files processes Signature based known attack patterns low false positive cannot detect new Anomaly based baseline normal behavior detects deviation may false positives can detect new attacks IPS Intrusion Prevention System detection + prevention blocks.
VPN Virtual Private Network tunneling secure tunnel over public internet IPSec network layer SSL VPN application layer site-to-site connect two offices remote access individual user connect to office.
NAT Network Address Translation private to public IP allows many private IPs to share one public IP types Static one-to-one private→public fixed Dynamic pool of public IPs assign on demand PAT Port Address Translation many-to-one using different ports most common home router.
Proxy Forward proxy client side hides client servers don't know real client Reverse proxy server side hides server clients don't know real server load balancing caching.
Network Devices Hub Layer1 physical repeater broadcast all ports dumb hub repeater regenerates signal Switch Layer2 Data Link MAC table intelligent learns MAC addresses forwards only to destination port Router Layer3 Network IP routing path selection routing table Gateway connects different protocols translates e.g., email gateway.
DNS Domain Name System Port 53:
- Hierarchical tree: root . (root) → com org → google.com → www.google.com → FQDN = www.google.com Fully Qualified Domain Name.
- iterative vs recursive query → recursive: resolver does all work client gets final answer → iterative: resolver asks other servers step by step root→TLD→authoritative.
- DNS resolver – asks on behalf of client local DNS server ISP.
- DNS server – authoritative for domain holds records for its domain.
- DNS cache – stores recent lookups to speed up TTL time to live.
- Record Types: A record→IPv4 address e.g., google.com→142.250.190.14, CNAME→alias to another name e.g., www→google.com alias, MX→mail server e.g., mail.google.com, NS→nameserver authoritative name server for domain, AAAA→IPv6, PTR→reverse IP→name.
- port 53 – UDP default queries fast small, TCP zone transfer large responses 512 bytes limit UDP.
DHCP Dynamic Host Configuration Protocol Ports 67 server 68 client:
- Assigns IP addresses automatically to clients no manual configuration.
- DORA Process Must Memorize:
1. Discover → Client broadcast Discover packet to find DHCP server 255.255.255.255.
2. Offer → Server offers available IP + subnet mask gateway DNS server IP.
3. Request → Client requests that IP broadcasts request.
4. Acknowledge → Server acknowledges and leases IP for set time lease granted.
- Lease – temporary must be renewed before expiry e.g., 24 hours after 50% renew.
HTTP HyperText Transfer Protocol Port 80:
- Request/Response protocol for web stateless.
- Request Methods: GET→retrieve data safe idempotent, POST→create/send new data e.g., form submit, PUT→update/replace resource idempotent, DELETE→remove resource idempotent, PATCH partial update, HEAD same as GET but only header.
- Status Codes: 1xx Informational 2xx Success 200 OK→success 201 Created 3xx Redirection 301 Moved Permanently 302 Found 4xx Client Error 400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found→resource not found 5xx Server Error 500 Server Error→server failure 502 Bad Gateway 503 Service Unavailable.
- HTTP header/format: Request GET /index.html HTTP/1.1 Host www.example.com User-Agent... Response HTTP/1.1 200 OK Content-Type text/html Content-Length...
HTTPS HTTP+TLS/SSL Port 443:
- Encrypted connection via TLS/SSL lock icon certificate encryption authentication.
- HTTP port 80 unencrypted plain text can sniff, HTTPS port 443 encrypted secure e-commerce.
SNMP Simple Network Management Protocol Ports 161 agent 162 trap:
- Manages/monitor network devices routers switches.
- Uses agent + manager model agent on device manager central.
- Collects data devices traffic errors MIB Management Information Base.
Email System Components:
- MUA Mail User Agent client Outlook Gmail client Thunderbird user writes reads email.
- MTA Mail Transfer Agent server Sendmail Postfix transfers email between servers SMTP.
- MDA Mail Delivery Agent delivers to mailbox e.g., Dovecot.
- Flow: Client MUA → MTA → MTA → MDA → MUA Receiver.
SMTP Simple Mail Transfer Protocol Port 25 587 submission 465 SMTPS:
- Send email push protocol only sends not receive.
- MTA to MTA communication.
- Commands HELO MAIL FROM RCPT TO DATA QUIT.
- Push only client pushes to server server pushes to next server.
POP3 Post Office Protocol Port 110 plain 995 POP3S SSL:
- Download delete from server offline.
- Old phone downloads once deletes from server no sync if delete from phone not delete from server? Actually deletes from server after download by default.
- POP3 commands USER PASS LIST RETR DELE QUIT.
- Single device offline access.
IMAP Internet Message Access Protocol Port 143 plain 993 IMAPS SSL/TLS:
- Keeps copy on server synchronization folders modern.
- Phone laptop both see same emails sync.
- Keeps copy on server supports folders IDLE push real-time notification.
- Modern protocol used today Gmail Outlook.
Comparison POP3 vs IMAP:
- POP3 offline download delete from server no folders single device old simple 1 device no sync vs IMAP online keeps copy on server synchronization folders multiple devices modern Gmail Outlook.
- POP3 download and delete IMAP keep on server.
- Use POP3 low storage server old IMAP modern multi-device.
FTP File Transfer Protocol Ports 21 control 20 data:
- Port 21 control connection commands, Port 20 data connection Active mode only.
- Active mode: server connects to client port 20 data connection from server to client problem with firewall client behind NAT firewall blocks incoming data PORT command client sends PORT IP+port server connects.
- Passive mode: client connects to server both connections from client to server firewall friendly modern uses passive PASV command server sends PASV IP+port client connects for data no incoming to client firewall friendly.
- GET download PUT upload LIST list files.
- Binary vs ASCII mode binary for images exe ASCII for text files.
- Anonymous FTP anonymous login public files.
Telnet Port 23 unsecure plain text remote login no encryption password sniffable obsolete:
- SSH Port 22 secure encrypted remote login SFTP SCP over SSH secure file transfer modern replacement for Telnet and FTP secure shell encryption authentication.
Symmetric Encryption SAME SECRET KEY for both encryption & decryption:
- Definition SAME SECRET KEY for both encryption & decryption same key both sides.
- Algorithms DES 56-bit old broken 1970s Data Encryption Standard insecure brute force, 3DES triple DES still slow, AES 128/192/256 modern Advanced Encryption Standard Rijndael fast secure used today.
- Pros FAST Efficient for large data Low computational cost high throughput.
- CON KEY DISTRIBUTION PROBLEM how to securely share the key? Both parties must share same key beforehand risk! If attacker intercepts key can decrypt Need secure channel to share key.
- Process [Plaintext] --(same key)--> [Ciphertext] --(same key)--> [Plaintext] Encryption Decryption same key K.
Asymmetric Encryption PUBLIC KEY & PRIVATE KEY pair:
- Definition PUBLIC KEY & PRIVATE KEY pair mathematically linked.
- Algorithms RSA 1024/2048 Rivest Shamir Adleman based on factoring large primes, Diffie-Hellman key exchange, DSA Digital Signature Algorithm, ECC Elliptic Curve Cryptography smaller key same security.
- Pros NO KEY DISTRIBUTION PROBLEM public key can be shared openly anyone can have public key private key secret.
- Cons SLOW more compute heavy used for small data not for bulk encryption.
- Process Public key→encrypt Private key→decrypt confidentiality Sender encrypts with receiver's public only receiver private can decrypt. Private key→encrypt Public key→decrypt authenticity digital signature.
Hashing One-way Irreversible Function:
- Type One-way Irreversible Function checksum message digest fixed length output.
- Common Hashes MD5 128-bit broken collision, SHA-1 160-bit deprecated, SHA-256 256-bit secure SHA-2 family SHA-3.
- Properties Deterministic same input always same output fixed length output regardless input size tiny change=very different hash avalanche effect e.g., hello→aaf4c61d... hello1→... completely different.
- Use Data integrity check ensuring no tampering password storage store hash not plain text ensuring no tampering Message--hash-->Hash e.g., SHA-256=a3f1b9d...
Digital Signature Purpose Verify AUTHENTICITY + NON-REPUDIATION + Integrity:
- How Sender hashes message→encrypts hash with their PRIVATE KEY signature = Encrypt_private(hash) Receiver decrypts hash using sender's PUBLIC KEY & compares to their own hash calculated If match→Valid authentic untampered Proves message is from sender & not altered sender cannot deny non-repudiation.
- If match→Valid = authentic + untampered + non-repudiation Proves message is from sender & not altered sender cannot deny.
- Difference from encryption: Encryption provides confidentiality Digital Signature provides authenticity non-repudiation integrity.
Digital Certificate Issued by CA Certificate Authority:
- Issued by CA Certificate Authority trusted third party VeriSign DigiCert Let's Encrypt.
- Contains Public Key + Identity info domain owner expiry serial number.
- Signed by CA to verify legitimacy & trust CA signs certificate with its private key browser has CA public key pre-installed verifies.
- Chain of trust Root CA→Intermediate CA→Server Certificate.
- If certificate invalid browser shows warning.
SSL/TLS Handshake Must know for DSSSB:
1. Client→Server Hello supported ciphers random number client hello.
2. Server→Client Certificate + chosen cipher server hello certificate.
3. Client verifies Certificate via CA generates pre-master secret random.
4. Encrypt secret with Server's Public Key→send to server.
5. Both derive same Session Key→now use Symmetric encryption for data bulk transfer.
- Handshake uses Asymmetric for key exchange then Symmetric for secure data transfer because Asymmetric slow Symmetric fast best of both hybrid.
Symmetric vs Asymmetric Comparison Table:
Symmetric Key Same key for both parties Speed Fast Use Case Bulk data encryption Problem Key distribution challenge Example DES AES 128/192/256 Asymmetric Key Public/Private key pair Speed Slow Use Case Key exchange Digital Signature Problem Slower larger key size Example RSA 1024/2048.
Key Takeaway Use ASYMMETRIC to securely share key→then switch to SYMMETRIC for fast data transfer. This is what TLS does.
Firewall Types:
- Packet Filter stateless filter IP port Protocol number stateless simple fast but no context filter based on IP address source destination port number protocol TCP UDP stateless no memory of previous packets e.g., allow port 80 deny port 23.
- Stateful Inspection tracks connection state table remembers connection knows if packet part of existing connection more secure stateful keeps state table source dest IP port TCP sequence number checks if packet belongs to established connection if SYN without prior connection block e.g., allows incoming only if outgoing initiated.
- Application Gateway proxy firewall application level understands HTTP FTP proxy acts on behalf of client hides internal network application gateway understands application layer e.g., HTTP proxy FTP proxy inspects application data more secure slower.
- Next-Gen Firewall NGFW deep packet inspection IPS antivirus application control.
IDS Intrusion Detection System:
- NIDS Network IDS monitors network traffic NIDS watches network packets placed at network choke point e.g., Snort.
- HIDS Host IDS monitors host system logs files processes checks system calls file integrity e.g., OSSEC.
- Detection methods Signature based known attack patterns low false positive cannot detect new attacks database of signatures e.g., SQL injection signature, Anomaly based baseline normal behavior detects deviation may false positives can detect new attacks machine learning baseline if traffic deviates from normal alert.
- IDS only detects passive alerts admin does not block.
- IPS Intrusion Prevention System detection + prevention blocks active vs IDS only detects passive IPS blocks automatically IPS inline IDS passive.
VPN Virtual Private Network tunneling secure tunnel over public internet:
- Tunneling encapsulation encryption VPN creates encrypted tunnel over internet secure.
- IPSec network layer protocol suite AH Authentication Header ESP Encapsulating Security Payload tunnel vs transport mode.
- SSL VPN application layer browser based no client needed.
- Site-to-site connect two offices permanent tunnel office1 router to office2 router.
- Remote access individual user connect to office user laptop VPN client to office server.
- VPN creates encrypted tunnel over internet site-to-site vs remote-access.
NAT Network Address Translation private to public IP allows many private IPs to share one public IP:
- Private IPs not routable on internet 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 need NAT to go internet.
- Types Static one-to-one private→public fixed one private always same public e.g., 192.168.1.10→203.0.113.10 always.
- Dynamic pool of public IPs assign on demand pool e.g., pool 203.0.113.10-20 assign when needed.
- PAT Port Address Translation many-to-one using different ports most common home router PAT also called NAT overload many private share one public using port numbers e.g., 192.168.1.10:1234→203.0.113.10:1234 192.168.1.11:1235→203.0.113.10:1235 same public IP different ports.
- NAT hides internal network security benefit.
Proxy forward vs reverse:
- Forward proxy client side hides client servers don't know real client client→forward proxy→internet Forward proxy hides client caching filtering e.g., school proxy.
- Reverse proxy server side hides server clients don't know real server client→reverse proxy→servers Reverse proxy hides server load balancing caching security e.g., Cloudflare Nginx.
Network Devices OSI Layer:
- Hub Layer1 physical repeater broadcast all ports dumb hub repeater regenerates signal collision domain one hub one collision domain all ports same collision half-duplex.
- Switch Layer2 Data Link MAC table intelligent learns MAC addresses forwards only to destination port switch breaks collision domain each port separate collision domain full-duplex MAC address table.
- Router Layer3 Network IP routing path selection routing table router breaks broadcast domain connects different networks e.g., LAN to WAN.
- Gateway connects different protocols translates e.g., email gateway protocol conversion application layer highest layer device.
- Repeater Layer1 regenerates signal extends distance.
- Bridge Layer2 connects two LAN segments similar to switch old.
- Brouter both bridge and router.
Final Recap Unit 6 Ch3 Complete & Unit 6 Complete: Imagine internet is big city DNS Phonebook of city You know name google.com but postman needs IP 142.250.190.14 DNS translates name→IP hierarchical tree root .→com org→google.com→www.google.com Record Types A→IPv4 CNAME→alias MX→mail server NS→nameserver port 53 UDP default TCP zone transfer recursive query resolver does all work client gets final answer iterative resolver asks other servers step by step DNS resolver asks on behalf of client DNS server authoritative for domain DNS cache stores recent lookups speed up Record Types A record→IPv4 address CNAME→alias to another name MX→mail server NS→nameserver port 53 UDP default queries TCP zone transfer large responses DHCP Automatic house allotment When you enter city you need IP address automatically DHCP assigns IP automatically to clients DORA Process 1 Discover Client broadcast to find DHCP server 2 Offer Server offers available IP + subnet gateway DNS 3 Request Client requests that IP 4 Acknowledge Server acknowledges and leases IP for set time Lease temporary must be renewed before expiry HTTP Language of web browser and server Request/Response protocol for web Request Methods GET→retrieve data POST→create/send new data PUT→update/replace DELETE→remove Status Codes 200 OK→success 404 Not Found→resource not found 500 Server Error→server failure HTTP header format Request GET /index.html HTTP/1.1 Host www.example.com User-Agent... Response HTTP/1.1 200 OK Content-Type text/html HTTPS HTTP+TLS/SSL Encrypted connection via TLS/SSL lock icon port 443 HTTP port 80 unencrypted HTTPS port 443 encrypted certificate SNMP Simple Network Management Management Uses agent+manager model collects data devices traffic errors Application layer protocols run over TCP/IP transport TCP/UDP Email Post Office System SMTP Simple Mail Transfer Protocol port 25 send email push protocol MTA Mail Transfer Agent MUA Mail User Agent MDA Mail Delivery Agent Client MUA→MTA→MTA→MDA→MUA Receiver SMTP is push only sends POP3 Post Office Protocol port 110 download delete from server offline old phone downloads once deletes from server no sync POP3 commands USER PASS LIST RETR DELE IMAP Internet Message Access Protocol port 143 993 keeps copy on server synchronization folders modern phone laptop both see same emails IMAP keeps copy on server supports folders IDLE push Comparison POP3 vs IMAP POP3 offline download delete no folders single device vs IMAP online keeps copy synchronization folders multiple devices modern FTP Courier service for files Port 21 control 20 data Active mode server connects to client port 20 data connection from server to client problem with firewall PORT command Passive mode client connects to server both connections from client to server firewall friendly PASV command modern uses passive GET PUT LIST commands binary vs ascii mode Telnet port 23 unsecure plain text SSH port 22 secure encrypted remote login Security Locks and keys Symmetric SAME SECRET KEY for both encryption & decryption DES 56-bit old AES 128/192/256 modern FAST Efficient for large data Low cost CON Key Distribution Problem how to securely share key? Both parties must share same key beforehand risk! Plaintext --(same key)-->Ciphertext --(same key)-->Plaintext Asymmetric PUBLIC KEY & PRIVATE KEY pair RSA 1024/2048 Pros NO KEY DISTRIBUTION PROBLEM public key can be shared openly Cons SLOW more compute heavy used for small data Process Public key→encrypt Private key→decrypt Hashing One-way Irreversible Function checksum message digest Common Hashes MD5 SHA-1 SHA-256 Properties Deterministic fixed length output tiny change=very different hash avalanche Use Data integrity check password storage ensuring no tampering Message--hash-->Hash e.g., SHA-256=a3f1b9d... Digital Signature Purpose Verify AUTHENTICITY + NON-REPUDIATION How Sender hashes message→encrypts hash with their PRIVATE KEY Receiver decrypts hash using sender's PUBLIC KEY & compares to their own hash If match→Valid authentic untampered Proves message is from sender & not altered sender cannot deny Digital Certificate Issued by CA Certificate Authority Contains Public Key + Identity info domain/owner Signed by CA to verify legitimacy & trust SSL/TLS Handshake 1 Client→Server Hello supported ciphers random 2 Server→Client Certificate + chosen cipher 3 Client verifies Certificate via CA generates pre-master secret 4 Encrypt secret with Server's Public Key→send to server 5 Both derive same Session Key→now use Symmetric encryption for data Handshake uses Asymmetric for key exchange then Symmetric for fast data transfer Symmetric vs Asymmetric Comparison Table Symmetric Key Same key for both parties Speed Fast Use Case Bulk data encryption Problem Key distribution challenge Example DES AES 128/192/256 Asymmetric Key Public/Private key pair Speed Slow Use Case Key exchange Digital Signature Problem Slower larger key size Example RSA 1024/2048 Key Takeaway Use ASYMMETRIC to securely share key→then switch to SYMMETRIC for fast data transfer Firewalls Types Packet Filter stateless filter IP port Protocol stateless simple fast but no context Stateless filter IP port Protocol number Application Gateway proxy firewall application level understands HTTP FTP proxy acts on behalf of client hides internal network application gateway understands application Stateful Inspection tracks connection state table remembers connection knows if packet part of existing connection more secure stateful keeps state table source dest IP port IDS Intrusion Detection System NIDS Network monitors network traffic HIDS Host monitors host system logs files processes Signature based known attack patterns low false positive cannot detect new Anomaly based baseline normal behavior detects deviation may false positives can detect new attacks IPS Intrusion Prevention System detection + prevention blocks active vs IDS only detects passive IPS blocks automatically VPN Virtual Private Network tunneling secure tunnel over public internet IPSec network layer SSL VPN application layer site-to-site connect two offices remote access individual user connect to office tunneling encapsulation encryption VPN creates encrypted tunnel over internet site-to-site vs remote-access NAT Network Address Translation private to public IP allows many private IPs to share one public IP types Static one-to-one private→public fixed Dynamic pool of public IPs assign on demand PAT Port Address Translation many-to-one using different ports most common home router PAT also called NAT overload many private share one public using port numbers Proxy forward vs reverse Forward proxy client side hides client servers don't know real client client→forward proxy→internet Forward proxy hides client Reverse proxy server side hides server clients don't know real server client→reverse proxy→servers Reverse proxy hides server load balancing caching security Network Devices Hub Layer1 physical repeater broadcast all ports dumb hub repeater regenerates signal collision domain one hub one collision domain Switch Layer2 Data Link MAC table intelligent learns MAC addresses forwards only to destination port switch breaks collision domain each port separate collision domain Router Layer3 Network IP routing path selection routing table router breaks broadcast domain Gateway connects different protocols translates e.g., email gateway protocol conversion application layer If you remember DNS Hierarchical tree root .→com org→google.com→www.google.com FQDN www.google.com iterative vs recursive recursive resolver does all work client gets final answer iterative resolver asks other servers step by step DNS resolver asks on behalf of client DNS server authoritative for domain DNS cache stores recent lookups speed up Record Types A→IPv4 CNAME→alias MX→mail server NS→nameserver port 53 UDP default queries TCP zone transfer large responses DHCP Assigns IP automatically DORA Process 1 Discover Client broadcast to find DHCP server 255.255.255.255 2 Offer Server offers available IP + subnet gateway DNS 3 Request Client requests that IP broadcasts request 4 Acknowledge Server acknowledges and leases IP for set time lease granted Lease temporary must be renewed before expiry Ports 67 server 68 client HTTP Request/Response protocol for web stateless Request Methods GET→retrieve data safe idempotent POST→create/send new data e.g., form submit PUT→update/replace resource idempotent DELETE→remove resource idempotent PATCH partial update HEAD same as GET but only header Status Codes 1xx Informational 2xx Success 200 OK→success 201 Created 3xx Redirection 301 Moved Permanently 302 Found 4xx Client Error 400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found→resource not found 5xx Server Error 500 Server Error→server failure 502 Bad Gateway 503 Service Unavailable HTTP header format Request GET /index.html HTTP/1.1 Host www.example.com User-Agent Response HTTP/1.1 200 OK Content-Type text/html Content-Length HTTP port 80 unencrypted plain text can sniff HTTPS port 443 encrypted secure e-commerce HTTP+TLS/SSL Encrypted connection via TLS/SSL lock icon certificate encryption authentication SNMP Simple Network Management Protocol Ports 161 agent 162 trap Manages/monitor network devices routers switches Uses agent+manager model agent on device manager central Collects data devices traffic errors MIB Management Information Base Email MUA Mail User Agent client Outlook Gmail Thunderbird writes reads MTA Mail Transfer Agent server Sendmail Postfix transfers between servers SMTP MDA Mail Delivery Agent delivers to mailbox Dovecot Flow MUA→MTA→MTA→MDA→MUA Receiver SMTP Simple Mail Transfer Protocol port 25 send email push protocol 587 submission 465 SMTPS MTA MTA communication Commands HELO MAIL FROM RCPT TO DATA QUIT Push only client pushes to server server pushes to next POP3 Post Office Protocol port 110 plain 995 POP3S SSL download delete from server offline old phone downloads once deletes from server no sync single device offline POP3 commands USER PASS LIST RETR DELE QUIT IMAP Internet Message Access Protocol port 143 plain 993 IMAPS SSL/TLS keeps copy on server synchronization folders modern phone laptop both see same emails keeps copy supports folders IDLE push real-time modern Gmail Outlook POP3 vs IMAP POP3 offline download delete no folders single device old simple 1 device no sync download and delete low storage vs IMAP online keeps copy synchronization folders multiple devices modern keep on server supports folders IDLE push multi-device Gmail Outlook modern multi-device FTP File Transfer Protocol port 21 control 20 data Active mode server connects to client port 20 data connection from server to client problem with firewall PORT command client sends PORT IP+port server connects Passive mode client connects to server both connections from client to server firewall friendly modern uses passive PASV command server sends PASV IP+port client connects for data no incoming to client firewall friendly GET download PUT upload LIST list files Binary vs ASCII mode binary images exe ASCII text Anonymous FTP anonymous login public files Telnet port 23 unsecure plain text remote login no encryption password sniffable obsolete SSH port 22 secure encrypted remote login SFTP SCP over SSH secure file transfer modern replacement Telnet FTP secure shell encryption authentication Symmetric Encryption SAME SECRET KEY for both encryption & decryption same key both sides Algorithms DES 56-bit old broken 1970s Data Encryption Standard insecure brute force 3DES triple DES still slow AES 128/192/256 modern Advanced Encryption Standard Rijndael fast secure used today Pros FAST Efficient for large data Low computational cost high throughput CON KEY DISTRIBUTION PROBLEM how to securely share key? Both parties must share same key beforehand risk! If attacker intercepts key can decrypt Need secure channel to share key Process Plaintext --(same key)-->Ciphertext --(same key)-->Plaintext Encryption Decryption same key K Asymmetric Encryption PUBLIC KEY & PRIVATE KEY pair mathematically linked Algorithms RSA 1024/2048 Rivest Shamir Adleman based on factoring large primes Diffie-Hellman key exchange DSA Digital Signature Algorithm ECC Elliptic Curve Cryptography smaller key same security Pros NO KEY DISTRIBUTION PROBLEM public key can be shared openly anyone can have public key private key secret Cons SLOW more compute heavy used for small data not for bulk encryption Process Public key→encrypt Private key→decrypt confidentiality Sender encrypts with receiver's public only receiver private can decrypt Private key→encrypt Public key→decrypt authenticity digital signature Hashing One-way Irreversible Function checksum message digest fixed length output Common Hashes MD5 128-bit broken collision SHA-1 160-bit deprecated SHA-256 256-bit secure SHA-2 family SHA-3 Properties Deterministic same input always same output fixed length output regardless input size tiny change=very different hash avalanche effect e.g., hello→aaf4c61d... hello1→... completely different Use Data integrity check ensuring no tampering password storage store hash not plain text ensuring no tampering Message--hash-->Hash e.g., SHA-256=a3f1b9d... Digital Signature Purpose Verify AUTHENTICITY + NON-REPUDIATION + Integrity How Sender hashes message→encrypts hash with their PRIVATE KEY signature = Encrypt_private(hash) Receiver decrypts hash using sender's PUBLIC KEY & compares to their own hash calculated If match→Valid authentic untampered Proves message is from sender & not altered sender cannot deny non-repudiation If match→Valid = authentic + untampered + non-repudiation Proves message is from sender & not altered sender cannot deny Difference from encryption Encryption provides confidentiality Digital Signature provides authenticity non-repudiation integrity Digital Certificate Issued by CA Certificate Authority trusted third party VeriSign DigiCert Let's Encrypt Contains Public Key + Identity info domain owner expiry serial number Signed by CA to verify legitimacy & trust CA signs certificate with its private key browser has CA public key pre-installed verifies Chain of trust Root CA→Intermediate CA→Server Certificate If certificate invalid browser shows warning SSL/TLS Handshake Must know for DSSSB 1 Client→Server Hello supported ciphers random number client hello 2 Server→Client Certificate + chosen cipher server hello certificate 3 Client verifies Certificate via CA generates pre-master secret random 4 Encrypt secret with Server's Public Key→send to server 5 Both derive same Session Key→now use Symmetric encryption for data bulk transfer Handshake uses Asymmetric for key exchange then Symmetric for secure data transfer because Asymmetric slow Symmetric fast best of both hybrid Symmetric vs Asymmetric Comparison Table Symmetric Key Same key for both parties Speed Fast Use Case Bulk data encryption Problem Key distribution challenge Example DES AES 128/192/256 Asymmetric Key Public/Private key pair Speed Slow Use Case Key exchange Digital Signature Problem Slower larger key size Example RSA 1024/2048 Key Takeaway Use ASYMMETRIC to securely share key→then switch to SYMMETRIC for fast data transfer TLS does Firewalls Types Packet Filter stateless filter IP port Protocol number stateless simple fast but no context filter based on IP address source destination port number protocol TCP UDP stateless no memory of previous packets e.g., allow port 80 deny port 23 Stateful Inspection tracks connection state table remembers connection knows if packet part of existing connection more secure stateful keeps state table source dest IP port TCP sequence number checks if packet belongs to established connection if SYN without prior connection block e.g., allows incoming only if outgoing initiated Application Gateway proxy firewall application level understands HTTP FTP proxy acts on behalf of client hides internal network application gateway understands application layer e.g., HTTP proxy FTP proxy inspects application data more secure slower Next-Gen Firewall NGFW deep packet inspection IPS antivirus application control IDS Intrusion Detection System NIDS Network IDS monitors network traffic NIDS watches network packets placed at network choke point e.g., Snort HIDS Host IDS monitors host system logs files processes checks system calls file integrity e.g., OSSEC Detection methods Signature based known attack patterns low false positive cannot detect new attacks database of signatures e.g., SQL injection signature Anomaly based baseline normal behavior detects deviation may false positives can detect new attacks machine learning baseline if traffic deviates from normal alert IDS only detects passive alerts admin does not block IPS Intrusion Prevention System detection + prevention blocks active vs IDS only detects passive IPS blocks automatically IPS inline IDS passive VPN Virtual Private Network tunneling secure tunnel over public internet Tunneling encapsulation encryption VPN creates encrypted tunnel over internet secure IPSec network layer protocol suite AH Authentication Header ESP Encapsulating Security Payload tunnel vs transport mode SSL VPN application layer browser based no client needed Site-to-site connect two offices permanent tunnel office1 router to office2 router Remote access individual user connect to office user laptop VPN client to office server VPN creates encrypted tunnel over internet site-to-site vs remote-access NAT Network Address Translation private to public IP allows many private IPs to share one public IP Private IPs not routable on internet 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 need NAT to go internet Types Static one-to-one private→public fixed one private always same public e.g., 192.168.1.10→203.0.113.10 always Dynamic pool of public IPs assign on demand pool e.g., pool 203.0.113.10-20 assign when needed PAT Port Address Translation many-to-one using different ports most common home router PAT also called NAT overload many private share one public using port numbers e.g., 192.168.1.10:1234→203.0.113.10:1234 192.168.1.11:1235→203.0.113.10:1235 same public IP different ports NAT hides internal network security benefit Proxy forward vs reverse Forward proxy client side hides client servers don't know real client client→forward proxy→internet Forward proxy hides client caching filtering e.g., school proxy Reverse proxy server side hides server clients don't know real server client→reverse proxy→servers Reverse proxy hides server load balancing caching security e.g., Cloudflare Nginx Network Devices OSI Layer Hub Layer1 physical repeater broadcast all ports dumb hub repeater regenerates signal collision domain one hub one collision domain all ports same collision half-duplex Switch Layer2 Data Link MAC table intelligent learns MAC addresses forwards only to destination port switch breaks collision domain each port separate collision domain full-duplex MAC address table Router Layer3 Network IP routing path selection routing table router breaks broadcast domain connects different networks e.g., LAN to WAN Gateway connects different protocols translates e.g., email gateway protocol conversion application layer highest layer device Repeater Layer1 regenerates signal extends distance Bridge Layer2 connects two LAN segments similar to switch old Brouter both bridge and router DSSSB 10 marks fixed! Unit 6 Ch3 Complete & Unit 6 Complete!
DNS - Domain Name System Port 53
| Concept | Details |
|---|---|
| Hierarchy | root . (root) → com org → google.com → www.google.com FQDN www.google.com Fully Qualified Domain Name |
| Query Types | iterative vs recursive query recursive resolver does all work client gets final answer iterative resolver asks other servers step by step root→TLD→authoritative returns referral not final answer |
| Roles | DNS resolver asks on behalf of client local DNS ISP DNS server authoritative for domain holds records DNS cache stores recent lookups speed up TTL |
| Record Types | A record→IPv4 address e.g., google.com→142.250.190.14 CNAME→alias to another name e.g., www→google.com alias MX→mail server e.g., mail.google.com NS→nameserver authoritative name server for domain AAAA→IPv6 PTR→reverse IP→name |
| Port | port 53 UDP default queries fast small TCP zone transfer large responses 512 bytes limit UDP |
DHCP - DORA Port 67 Server 68 Client
| Step | Details |
|---|---|
| Assigns | Assigns IP addresses automatically to clients no manual configuration |
| 1 Discover | Client broadcast Discover packet to find DHCP server 255.255.255.255 |
| 2 Offer | Server offers available IP + subnet mask gateway DNS server IP |
| 3 Request | Client requests that IP broadcasts request |
| 4 Acknowledge | Server acknowledges and leases IP for set time lease granted Lease temporary must be renewed before expiry e.g., 24 hours after 50% renew Ports 67 server 68 client |
HTTP/HTTPS
| Concept | Details |
|---|---|
| HTTP Port 80 | Request/Response protocol for web stateless |
| Methods | GET→retrieve data safe idempotent POST→create/send new data e.g., form submit PUT→update/replace resource idempotent DELETE→remove resource idempotent PATCH partial update HEAD same as GET but only header |
| Status Codes | 1xx Informational 2xx Success 200 OK→success 201 Created 3xx Redirection 301 Moved Permanently 302 Found 4xx Client Error 400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found→resource not found 5xx Server Error 500 Server Error→server failure 502 Bad Gateway 503 Service Unavailable |
| Header Format | Request GET /index.html HTTP/1.1 Host www.example.com User-Agent Response HTTP/1.1 200 OK Content-Type text/html Content-Length |
| HTTPS Port 443 | HTTP+TLS/SSL Encrypted connection via TLS/SSL lock icon certificate encryption authentication HTTP port 80 unencrypted plain text can sniff HTTPS port 443 encrypted secure e-commerce |
| SNMP | Simple Network Management Protocol Ports 161 agent 162 trap Manages/monitor network devices routers switches Uses agent+manager model agent on device manager central Collects data devices traffic errors MIB Management Information Base |
Email - SMTP POP3 IMAP
| Protocol | Port/Details |
|---|---|
| MUA MTA MDA | MUA Mail User Agent client Outlook Gmail Thunderbird writes reads MTA Mail Transfer Agent server Sendmail Postfix transfers between servers SMTP MDA Mail Delivery Agent delivers to mailbox Dovecot Flow MUA→MTA→MTA→MDA→MUA Receiver |
| SMTP | Simple Mail Transfer Protocol port 25 send email push protocol 587 submission 465 SMTPS MTA MTA communication Commands HELO MAIL FROM RCPT TO DATA QUIT Push only client pushes to server server pushes to next |
| POP3 | Post Office Protocol port 110 plain 995 POP3S SSL download delete from server offline old phone downloads once deletes from server no sync single device offline POP3 commands USER PASS LIST RETR DELE QUIT |
| IMAP | Internet Message Access Protocol port 143 plain 993 IMAPS SSL/TLS keeps copy on server synchronization folders modern phone laptop both see same emails keeps copy supports folders IDLE push real-time modern Gmail Outlook |
| POP3 vs IMAP | POP3 offline download delete no folders single device old simple 1 device no sync download and delete low storage vs IMAP online keeps copy synchronization folders multiple devices modern keep on server supports folders IDLE push multi-device Gmail Outlook modern multi-device |
FTP & Remote Login
| Protocol | Details |
|---|---|
| FTP Active | File Transfer Protocol port 21 control 20 data Active mode server connects to client port 20 data connection from server to client problem with firewall PORT command client sends PORT IP+port server connects |
| FTP Passive | Passive mode client connects to server both connections from client to server firewall friendly modern uses passive PASV command server sends PASV IP+port client connects for data no incoming to client firewall friendly GET download PUT upload LIST list files Binary vs ASCII mode binary images exe ASCII text Anonymous FTP anonymous login public files |
| Telnet vs SSH | Telnet port 23 unsecure plain text remote login no encryption password sniffable obsolete SSH port 22 secure encrypted remote login SFTP SCP over SSH secure file transfer modern replacement Telnet FTP secure shell encryption authentication |
Cryptography - Symmetric vs Asymmetric
| Type | Details |
|---|---|
| Symmetric | SAME SECRET KEY for both encryption & decryption same key both sides Algorithms DES 56-bit old broken 1970s Data Encryption Standard insecure brute force 3DES triple DES still slow AES 128/192/256 modern Advanced Encryption Standard Rijndael fast secure used today Pros FAST Efficient for large data Low computational cost high throughput CON KEY DISTRIBUTION PROBLEM how to securely share key? Both parties must share same key beforehand risk! If attacker intercepts key can decrypt Need secure channel to share key Process Plaintext --(same key)-->Ciphertext --(same key)-->Plaintext Encryption Decryption same key K |
| Asymmetric | PUBLIC KEY & PRIVATE KEY pair mathematically linked Algorithms RSA 1024/2048 Rivest Shamir Adleman based on factoring large primes Diffie-Hellman key exchange DSA Digital Signature Algorithm ECC Elliptic Curve Cryptography smaller key same security Pros NO KEY DISTRIBUTION PROBLEM public key can be shared openly anyone can have public key private key secret Cons SLOW more compute heavy used for small data not for bulk encryption Process Public key→encrypt Private key→decrypt confidentiality Sender encrypts with receiver's public only receiver private can decrypt Private key→encrypt Public key→decrypt authenticity digital signature |
| Hashing | One-way Irreversible Function checksum message digest fixed length output Common Hashes MD5 128-bit broken collision SHA-1 160-bit deprecated SHA-256 256-bit secure SHA-2 family SHA-3 Properties Deterministic same input always same output fixed length output regardless input size tiny change=very different hash avalanche effect e.g., hello→aaf4c61d... hello1→... completely different Use Data integrity check ensuring no tampering password storage store hash not plain text ensuring no tampering Message--hash-->Hash e.g., SHA-256=a3f1b9d... |
| Digital Signature | Purpose Verify AUTHENTICITY + NON-REPUDIATION + Integrity How Sender hashes message→encrypts hash with their PRIVATE KEY signature = Encrypt_private(hash) Receiver decrypts hash using sender's PUBLIC KEY & compares to their own hash calculated If match→Valid authentic untampered Proves message is from sender & not altered sender cannot deny non-repudiation If match→Valid = authentic + untampered + non-repudiation Proves message is from sender & not altered sender cannot deny Difference from encryption Encryption provides confidentiality Digital Signature provides authenticity non-repudiation integrity |
| Digital Certificate | Issued by CA Certificate Authority trusted third party VeriSign DigiCert Let's Encrypt Contains Public Key + Identity info domain owner expiry serial number Signed by CA to verify legitimacy & trust CA signs certificate with its private key browser has CA public key pre-installed verifies Chain of trust Root CA→Intermediate CA→Server Certificate If certificate invalid browser shows warning |
| SSL/TLS Handshake | 1 Client→Server Hello supported ciphers random number client hello 2 Server→Client Certificate + chosen cipher server hello certificate 3 Client verifies Certificate via CA generates pre-master secret random 4 Encrypt secret with Server's Public Key→send to server 5 Both derive same Session Key→now use Symmetric encryption for data bulk transfer Handshake uses Asymmetric for key exchange then Symmetric for secure data transfer because Asymmetric slow Symmetric fast best of both hybrid |
| Feature | Symmetric | Asymmetric |
|---|---|---|
| Key | Same key for both parties | Public/Private key pair |
| Speed | Fast | Slow |
| Use Case | Bulk data encryption | Key exchange Digital Signature |
| Problem | Key distribution challenge | Slower larger key size |
| Example | DES AES 128/192/256 | RSA 1024/2048 |
Key Takeaway Use ASYMMETRIC to securely share key→then switch to SYMMETRIC for fast data transfer.
Firewalls, IDS, VPN, NAT, Proxy, Devices
| Concept | Details |
|---|---|
| Packet Filter | stateless filter IP port Protocol number stateless simple fast but no context filter based on IP address source destination port number protocol TCP UDP stateless no memory of previous packets e.g., allow port 80 deny port 23 |
| Stateful Inspection | tracks connection state table remembers connection knows if packet part of existing connection more secure stateful keeps state table source dest IP port TCP sequence number checks if packet belongs to established connection if SYN without prior connection block e.g., allows incoming only if outgoing initiated |
| Application Gateway | proxy firewall application level understands HTTP FTP proxy acts on behalf of client hides internal network application gateway understands application layer e.g., HTTP proxy FTP proxy inspects application data more secure slower Next-Gen Firewall NGFW deep packet inspection IPS antivirus application control |
| IDS NIDS HIDS | Intrusion Detection System NIDS Network IDS monitors network traffic NIDS watches network packets placed at network choke point e.g., Snort HIDS Host IDS monitors host system logs files processes checks system calls file integrity e.g., OSSEC Detection methods Signature based known attack patterns low false positive cannot detect new attacks database of signatures e.g., SQL injection signature Anomaly based baseline normal behavior detects deviation may false positives can detect new attacks machine learning baseline if traffic deviates from normal alert IDS only detects passive alerts admin does not block |
| IPS vs IDS | IPS Intrusion Prevention System detection + prevention blocks active vs IDS only detects passive IPS blocks automatically IPS inline IDS passive IDS only detects passive alerts admin does not block |
| VPN | Virtual Private Network tunneling secure tunnel over public internet Tunneling encapsulation encryption VPN creates encrypted tunnel over internet secure IPSec network layer protocol suite AH Authentication Header ESP Encapsulating Security Payload tunnel vs transport mode SSL VPN application layer browser based no client needed Site-to-site connect two offices permanent tunnel office1 router to office2 router Remote access individual user connect to office user laptop VPN client to office server VPN creates encrypted tunnel over internet site-to-site vs remote-access |
| NAT | Network Address Translation private to public IP allows many private IPs to share one public IP Private IPs not routable on internet 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 need NAT to go internet Types Static one-to-one private→public fixed one private always same public e.g., 192.168.1.10→203.0.113.10 always Dynamic pool of public IPs assign on demand pool e.g., pool 203.0.113.10-20 assign when needed PAT Port Address Translation many-to-one using different ports most common home router PAT also called NAT overload many private share one public using port numbers e.g., 192.168.1.10:1234→203.0.113.10:1234 192.168.1.11:1235→203.0.113.10:1235 same public IP different ports NAT hides internal network security benefit |
| Proxy Forward vs Reverse | Forward proxy client side hides client servers don't know real client client→forward proxy→internet Forward proxy hides client caching filtering e.g., school proxy Reverse proxy server side hides server clients don't know real server client→reverse proxy→servers Reverse proxy hides server load balancing caching security e.g., Cloudflare Nginx |
| Network Devices | Hub Layer1 physical repeater broadcast all ports dumb hub repeater regenerates signal collision domain one hub one collision domain all ports same collision half-duplex Switch Layer2 Data Link MAC table intelligent learns MAC addresses forwards only to destination port switch breaks collision domain each port separate collision domain full-duplex MAC address table Router Layer3 Network IP routing path selection routing table router breaks broadcast domain connects different networks e.g., LAN to WAN Gateway connects different protocols translates e.g., email gateway protocol conversion application layer highest layer device Repeater Layer1 regenerates signal extends distance Bridge Layer2 connects two LAN segments similar to switch old Brouter both bridge and router |