My BLOG

IP Addresses

IP addresses operate at Layer 3 of the OSI model, handling logical addressing and routing.
Use ifconfig to view network interfaces and their IP addresses.
IPv4: A 32-bit address used in most networks today.
IPv6: A 128-bit address designed to replace IPv4, offering a vastly larger address space.


MAC Addresses

MAC addresses are 48-bit, hardware-specific addresses used for communication within a network's Layer 2.
Each MAC address consists of four octets, with the first three identifying the vendor. You can look up the vendor using online tools.
MAC addresses are crucial for local network communication and are used by switches to direct traffic.


Layer 4 - TCP/UDP

Transmission Control Protocol (TCP): A connection-oriented protocol ensuring reliable data transfer.
User Datagram Protocol (UDP): A connectionless protocol offering faster, but less reliable, communication.

TCP works by establishing a connection through a three-way handshake:

  • Send SYN packet.
  • Receive SYN-ACK packet.
  • Send ACK packet to establish the connection.

Common Ports and Protocols

TCP:

  • FTP: Port 21 - File Transfer Protocol for file sharing.
  • SSH: Port 22 - Secure Shell for remote system control.
  • Telnet: Port 23 - Unsecured remote login.
  • SMTP: Port 25 - Simple Mail Transfer Protocol for sending emails.
  • DNS: Port 53 - Domain Name System, resolves domain names to IP addresses.
  • HTTP: Port 80 / HTTPS: Port 443 - Web traffic, with HTTPS providing encrypted communication.
  • POP3: Port 110 - Post Office Protocol for retrieving emails.
  • SMB: Ports 139, 445 - Server Message Block for file sharing on networks.
  • IMAP: Port 143 - Internet Message Access Protocol for email retrieval and storage.

UDP:

  • DNS: Port 53 - Domain Name System, similar to TCP but with faster, connectionless requests.
  • DHCP: Ports 67, 68 - Dynamic Host Configuration Protocol for assigning IP addresses automatically.
  • TFTP: Port 69 - Trivial File Transfer Protocol, a simple file transfer protocol with minimal overhead.
  • SNMP: Port 161 - Simple Network Management Protocol for network management and monitoring.

The OSI Model

Layers:

  • Physical: Manages the transmission of raw data over physical media like cables and wireless.
  • Data Link: Handles data transfer between adjacent network nodes, using MAC addresses.
  • Network: Manages logical addressing and routing, using IP addresses.
  • Transport: Ensures reliable data transfer through protocols like TCP and UDP.
  • Session: Manages and controls the connections between computers.
  • Presentation: Translates data between the application layer and the network, including encryption and formatting.
  • Application: Provides network services directly to end-user applications, like HTTP and SMTP.

When troubleshooting, always start from the physical layer and move up to the application layer to identify the issue.


Subnetting

Subnetting divides a network into smaller, more manageable sub-networks to optimize routing and improve security. Use tools like:
IP Address Guide Website for subnet calculations and CIDR notation guidance.

Useful Linux Commands


  • locate X - Locates X in the filesystem.
  • passwd - Changes the root password.
  • man X - Shows instructions for command X.
  • apropos - Similar to `man` but provides shorter descriptions.
  • chmod rwx X - Changes mode (rwx, 777) for file X.
  • adduser X - Adds new user X.
  • su X - Switches to user X.
  • apt update && apt upgrade - Updates the package list and upgrades installed packages.
  • python3 -m venv X - Creates a virtual environment in directory X.
  • source activate - Activates the virtual environment.
  • gedit, mousepad, nano - Text editors.
  • grep "X" - Searches for the string X.
  • whoami - Displays the current username.
  • id - Returns the user's identity.
  • hostname - Sets or prints the name of the current host system.
  • uname - Prints basic information about the operating system and system hardware.
  • pwd - Returns the current working directory name.
  • ifconfig - Assigns or views an address to a network interface and/or configures network interface parameters.
  • ip - A utility to show or manipulate routing, network devices, interfaces, and tunnels.
  • netstat - Shows the network status.
  • ss - Another utility to investigate sockets.
  • ps - Shows the process status.
  • who - Displays who is logged in.
  • env - Prints the environment or sets and executes a command.
  • lsblk - Lists block devices.
  • lsusb - Lists USB devices.
  • lsof - Lists open files.
  • lspci - Lists PCI devices.

Useful Network Commands


  • ifconfig - Displays network interface configuration.
  • iwconfig - Displays wireless interface details.
  • ping - Tests network connectivity with ICMP.
  • arp - Displays the ARP table (IP to MAC mapping).
  • netstat -ano - Shows active network connections and PIDs.
  • route - Prints the routing table.
  • ip - Manages network interfaces and routing.
  • traceroute - Traces the path to a destination.
  • nslookup - Queries DNS for domain information.
  • dig - Performs DNS lookups.
  • tcpdump - Captures and analyzes network packets.
  • nmap - Scans networks for hosts and services.
  • curl - Transfers data with various protocols.
  • wget - Downloads files from the web.
  • whois - Retrieves domain registration details.
  • hostname - Prints or sets the system hostname.