Comprehensive Networking Notes
Networking Fundamentals
- Server: A central computer providing information to multiple client computers.
- Client: A computer operated by a user that connects with a server to acquire information.
- Network: A group of interconnected computers exchanging information.
- HTTP/HTTPS: Standard protocols for web data transfer. HTTPS adds encryption for secure communication.
- Domain name: A unique name identifying a website and used to locate the website running on a server.
- TCP/IP: The foundational suite of protocols for the internet, responsible for reliable data transfer (TCP) and routing (IP).
- NIC (Network Interface Card): Direct connection to a local area network.
- HUB: A basic networking device that connects multiple devices in a network by broadcasting data to all ports without filtering.
- Switch: Connects devices within a network, especially in a LAN, to allow data exchange between specific devices using MAC addresses.
- Subnet: A smaller, segmented portion of a larger network, created to improve performance and security by grouping devices with similar IP addresses.
- LAN: Connects devices within a limited area like a building or campus, providing high-speed data transmission with low latency.
- WAN: Connects devices over large geographical areas, often using leased telecommunication lines, such as the internet.
- Firewall: Acts as a security device, monitoring and controlling incoming and outgoing network traffic based on predefined security rules.
Network Elements
- Network: A system of interconnected devices that communicate and share resources over wired or wireless connections.
- Node: Any device on a network (e.g., servers, switches, modems, computers, printers).
- Host: A node with a unique function; other devices connect to hosts to access data or services. A server is an example of a host.
- Client: A computer node device that accesses data or services managed by a server.
- Network elements: Essential components that enable data transmission, connectivity, and management within a network.
- Router: A network device that connects multiple network segments into one network.
- Switch: Connects devices within the same network and manages data flow by forwarding data to specific devices using MAC addresses between the transmitting and receiving devices.
- Hub: A basic device that connects multiple devices by broadcasting data to all ports. If one node sends data, all others receive it, but only the intended recipient listens.
- Cables: Physical cables (e.g., Ethernet) used for wired connections. Three commonly used types are coaxial, twisted-pair, and fiber-optic.
- NIC (Network Interface Card): Connects a computer to a computer network using a cable. Each NIC has its own media access control (MAC) address.
- The MAC address is a unique physical (hardware) identifier assigned by the manufacturer and used to identify the sender and receiver of data.
- Access Points: Allow wireless devices to connect to a wired network, often part of a Wi-Fi setup.
- Modems: Convert digital data to analogue for transmission over telephone lines or cable and vice versa.
- Firewalls: Monitor and control incoming and outgoing network traffic for security.
Network Concepts
- The most common types of networks are LANs and WANs.
- LANs connect devices within a small area, like a home or office.
- WANs connect multiple LANs over larger areas, such as cities or countries.
- Local-area network (LAN):
- Limited Range: Typically covers a small area, up to a few kilometres at most.
- High-Speed: LAN commonly uses the Ethernet standard for connecting devices, at a higher data-transfer rate.
- Wireless Option: Wireless technology is also commonly used for a LAN.
- Ownership: Often owned and managed by a single organization or individual, allowing greater security control.
- Low Latency: Quick response times because data does not travel far.
- Wide-area network (WAN):
- Wide Coverage: Can span cities, countries, or continents.
- Slower Speed: Typically slower than LANs due to the distances data must travel and reliance on public infrastructure.
- Higher Latency: Data packets travel over larger distances, which increases response times.
- Ownership: Usually involves collaboration with internet service providers (ISPs) or telecommunications companies.
- Complexity: Requires more complex infrastructure, including routers, switches, and leased lines.
| Feature | LAN | WAN |
|---|
| Geolocation | Small and local area | Wide area, cities, countries |
| Speed | High-speed data transfer | Slower than LAN |
| Latency | Low latency | High latency due to distance |
| Ownership | Single entity | Multiple entities |
| Cost | Low setup cost | Higher infrastructure cost |
| Security | Higher central control | Greater risk due to internet |
Network Architecture
- Network management models, such as Client-Server and Peer-to-Peer (P2P), define how data and resources are organized, accessed, and managed across networks.
- Client-Server Model: A centralized server hosts resources and data, while clients (PCs, laptops, mobile phones) request and access these resources, relying on the server for processing, storage, and authentication.
- Server: Hosts data, services, and applications.
- Client: Requests services or data from the server, often through a web interface or application.
- Communication: Occurs over a network protocol like HTTP, FTP, or SQL, depending on the service.
- Peer-to-Peer (P2P) Model: Devices act as both clients and servers, sharing resources directly without a centralized server, with each peer managing its own data and services.
- Peers: All devices are equal and can both request and provide resources.
- Communication: Is direct between peers, and there is no central coordination.
- Protocols: Like BitTorrent or Napster (historically) are used for file sharing, and blockchain networks use P2P for decentralized management.
Network Topologies
- Computer networks use different topologies to interconnect devices and share information. A topology is a pattern (or diagram) that shows how nodes connect to each other.
- Network topologies refer to the layout of the connected devices in a network.
- Physical: Refers to the physical layout of wires in the network
- Logical: Refers to how data moves through the network
- Each topology has its own advantages and disadvantages depending on the scale, cost, and fault tolerance required.
- Bus Topology: All devices are connected to a single central cable, called the bus. Data is sent along the bus, and all devices receive it, but only the intended recipient processes the data.
- Advantages:
- Simple and cost-effective: Requires less cable and hardware, making it an affordable option for small networks.
- Easy to implement: Setup is straightforward, especially for small networks.
- Disadvantages:
- Limited scalability: The bus can become overloaded with added devices, leading to data collisions and slower network.
- Data collisions: Devices share the same communication medium, causing data collisions in simultaneous data transfer.
- Network failure: If the bus cable fails, the entire network is disrupted.
- Star Topology: All devices in a star network are connected to a central hub or switch, which manages communication between devices.
- Advantages:
- Easy to manage: Since each device is connected to a central hub, it’s easier to isolate and fix problems.
- Scalable: New devices can be easily added without disrupting the network.
- Reduced risk of failure: If one device fails, it doesn’t affect the rest of the network, except for its communication with the hub.
- Disadvantages:
- Single point of failure: If the central hub or switch fails, the entire network goes down.
- Requires more cabling: Each device needs a direct connection to the hub, increasing cable usage.
- Cost: The central hub or switch can be expensive, especially for large networks.
- Mesh Topology: In a mesh network, each device is connected to every other device, creating multiple paths for data transmission.
- Advantages:
- High reliability: Multiple pathways for data ensure that if one connection fails, data can still be routed.
- Improved performance: With many connections, data can be transmitted more efficiently, as traffic can be routed via multiple paths.
- Scalable: New devices can be added without disrupting the network.
- Disadvantages:
- Complex to manage: The large number of connections can make it difficult to manage the network.
- Requires more hardware: Each device needs a connection to every other device, requiring more network interfaces and cables.
- Cost: The need for multiple connections between devices increases installation costs, especially in large networks.
- Hybrid Topology: A hybrid topology combines two or more different topologies, such as a star-bus or star-mesh design allowing for flexibility and optimization based on the specific needs.
- Advantages:
- Fault tolerance: By integrating fault-tolerant topologies (like mesh), hybrid networks can provide high reliability.
- Flexibility: Hybrid topologies are designed to meet specific needs by combining the strengths of different topologies.
- Scalable: It’s easier to expand a hybrid network by integrating different topologies as needed.
- Disadvantages:
- Complex to manage: The combination of different topologies can make the network more complex to implement and maintain.
- Troubleshooting difficulty: Diagnosing issues may be more difficult because the hybrid structure combines different topologies
- Cost: The multiple topologies infrastructure can increase setup and maintenance cost.
OSI Model
- The OSI (Open Systems Interconnection) model is a conceptual framework used to understand network interactions in seven distinct layers.
- Each layer performs specific functions in the process of communication and data transfer across a network.
Network Protocols
- Network protocols enable communication between devices over a network.
- Each protocol is designed for specific purposes.
- Protocols can be connection-oriented or connectionless.
- Connection-oriented: Establish a connection between sender and receiver before data transmission.
- Connectionless: Data is sent without setting up a connection, which can lead to faster transmission.
- TCP/IP:
- The fundamental suite for internet communication.
- Used for reliable data transfer in applications like web browsing, email, and file transfers.
- HTTP/HTTPS:
- HTTP is used to transfer web data.
- HTTPS encrypts data for secure communication.
- Core protocols for loading web pages.
- SMTP/POP/IMAP:
- SMTP sends emails.
- IMAP retrieves emails from the server; keeps and syncs emails on the server.
- POP retrieves emails from the server; downloads emails and deletes them from the server.
- RDP/SSH:
- RDP provides remote desktop access.
- SSH securely manages remote systems.
- RDP is used for Windows systems.
- SSH is widely used for secure command-line access.
- FTP/FTPS:
- FTP transfers files between client and server.
- FTPS encrypts these transfers using SSL/TLS.
- Used for uploading, downloading, and managing files on servers.
- UDP (User Datagram Protocol):
- Provides fast, low-overhead data transfer without ensuring delivery or order.
- Ideal for streaming audio/video, online gaming, and other real-time applications where speed is essential.
- DHCP:
- Assigns IP addresses and network configurations to devices on a network dynamically.
- Automatically configures device IP.
- ICMP:
- Sends error messages and network diagnostics, such as the well-known ping command.
- Used for troubleshooting and diagnosing network issues.
- DNS (Domain Name System):
- Translates human-readable domain names into IP addresses.
- Used for web browsing and internet functionality, allowing users to access websites via URLs instead of IP addresses.
Network Utilities
- Network utilities are fundamental tools for testing and diagnosing network connectivity and performance.
- Ping:
- Function: Checks if a device is reachable on the network by sending ICMP echo requests and measuring the response time.
- Usage: Commonly used to test network connectivity and latency between devices.
- CLI Example:
- Windows:
ping google.com - Unix/Linux:
ping google.com
- Explanation: Ping will send a series of packets to google.com and display the time taken for each response, confirming connectivity and indicating network latency.
- nslookup (Name Server Lookup):
- Function: Queries DNS records to find the IP address of a domain or verify DNS configurations.
- Usage: Helps diagnose domain resolution issues and confirm DNS settings.
- CLI Example:
- Windows:
nslookup google.com - Unix/Linux:
nslookup google.com
- Explanation: nslookup retrieves the IP address associated with google.com, which is useful for checking DNS resolution and verifying if a domain points to the correct IP.
- Traceroute:
- Function: Traceroute traces the route packets take to reach a destination, showing each hop and the delay at each point.
- Usage: Useful for diagnosing network routing issues, identifying delays, or pinpointing network bottlenecks.
- CLI Example:
- Windows:
tracert google.com - Unix/Linux:
traceroute google.com
- Explanation: This command displays each router (hop) between the source and google.com, along with the time it takes for each hop, helping locate points of delay or connection issues.
Network Segmenting
- Network segmentation is the practice of dividing a larger network into smaller, isolated subnetworks (or segments).
- Segmenting networks helps to control traffic flow, reducing congestion and potential points of failure, while also minimizing the risk of unauthorized access.
- Benefits of Network Segmentation:
- Enhanced Security: By isolating segments, sensitive information and critical systems can be restricted to certain parts of the network, making it harder for unauthorized users to access this data.
- Improved Performance: By reducing the number of devices on each segment, network congestion is minimized, leading to faster data transfer rates and overall improved network performance.
- Simplified Management: Network administrators can manage smaller segments more easily than a large, monolithic network, allowing for quicker identification and isolation of issues.
- Compliance: Segmenting a network can help organizations meet compliance requirements by creating designated secure areas within a network for sensitive data processing.
Internet Protocol (IP)
- The Internet Protocol (IP) is the foundational protocol that governs how data is sent, addressed, and routed across networks.
- IP operates at Layer 3 (the Network Layer) of the OSI model.
- A unique IP address is assigned to each device on a network
- IP supports subnetting to subdivide a network
- IP identifies a host and a network
- IP addresses are also used for location addressing
- IP addresses are represented by more readable URL
- DNS translates URL into IP address
- IP addressing is designed to accommodate different sizes of networks. Each class has a unique range of IP range.
- It is defined by the number of bits assigned for the network and host portions.
- Class A:
- Range: 0.0.0.0–127.255.255.255
- Used for extremely large networks, like networks built by (ISPs)
- Provides for up to 126 networks, which can each support up to 16,777,214 addresses
- Class B:
- Range: 128.0.0.0–191.255.255.255
- Suitable for medium to large networks, for example, for enterprises and organizations
- Provides for up to 16,384 networks, accounting for approximately 65,000 addresses each
- Class C:
- Range: 192.0.0.0–233.255.255.255
- Used for small networks, such as a home network or a small business network
- Provides for up to 2,097,150 networks that can each allow for up to 254 addresses each
- All networks, no matter their size, reserve some IP addresses for specific functions.
- Unknown IP:
- 0.0.0.0
- This IP can have different meanings, depending on context. It might be used to represent an unknown or un-routable request, or it might be used to represent any address on a server.
- Loopback IP:
- 127.0.0.1
- This IP returns a message back to its originating device and is used for testing and debugging purposes. It is also used to allow a specific configuration of inter-domain routing between network routers.
- Broadcast IP:
- 255.255.255.255
- This IP represents all devices that are connected to the network. The broadcast address is reserved so that information can be sent to every device on a network.
- IP addresses come in several types based on their scope, function, and allocation method, with each type playing a distinct role in network communication.
- IPv4 and IPv6:
- IPv4: the most widely used version, uses 32-bit addresses and provides about 4.3 billion unique addresses (limited address space).
- IPv6: uses 128-bit addresses, providing a nearly unlimited number of unique addresses. IPv6 addresses are written in hexadecimal format.
- Public and Private IP Addresses:
- Public IPs:
- Are assigned by Internet Service Providers (ISPs).
- Are globally unique and allow devices to communicate over the internet.
- Identify a device on the internet so it can send and receive data from other public IP addresses.
- Private IPs:
- Are used within private networks.
- Allow devices within a local network (such as a home or office) to communicate internally.
- Are not routable on the internet and are typically assigned by a local router or DHCP server.
- Common private IP ranges include:
- 10.0.0.0 to 10.255.255.255
- 172.16.0.0 to 172.31.255.255
- 192.168.0.0 to 192.168.255.255
- Static and Dynamic IP Addresses:
- Static IP:
- Is a permanent IP address manually assigned to a device.
- It is often used by servers, routers, or devices that require constant addressing.
- Are beneficial for hosting websites or services where consistency is essential.
- Dynamic IP:
- Temporary IPs assigned by a DHCP server each time a device connects to a network.
- Most consumer devices use dynamic IPs, which help conserve IP addresses and are easily managed by the network.
CIDR
- Classless Inter-Domain Routing (CIDR) is a method for allocating IP addresses and to specify subnet IP address ranges.
- CIDR provides a shorthand for describing the size of a network.
- CIDR notation: IP/suffix
- IP: Represents the network address, the base IP address of a network segment, defining the starting point for a range of addresses.
- suffix: (Prefix) Represents the subnet mask in CIDR format. It indicates how many bits of the IP address are used (fixed number of bits from the left) for the network portion
- Example: 192.168.1.11/24
- Here, the /24 means that the first 24 bits are used for the network.
- The remaining bits are for host addresses. This notation allows for variable-length subnet masks, making subnetting much more efficient.
- The remaining bits (32 – 24) = 8 bits can be used for subnetting and for hosts IP allocations.
Subnetting
- Subnetting the network address specifies the starting point of a network and identifies the range of IP addresses within a subnet.
- Key Elements of Subnetting in CIDR:
- Network Address: The base address that represents a network, typically shown as the IP address followed by a slash and a number (e.g., 192.168.1.0/24), where /24 indicates 24 bits are used for the network portion.
- Subnet Mask: The subnet mask is a 32-bit number that defines the division between the network and host portions of an IP address.
- Number of Hosts: The number of usable hosts in a subnet:
Hosts=2(32−prefix length)−2 - The subtraction of 2 accounts for the network and broadcast addresses.
- Number of Subnets: The number of subnets can be determined by the number of bits borrowed from the host portion of an IP address to create more subnets.
Subnets=2(borrowed bits) - Borrowed Bits are determined by how many subnets are required for the organization.
- Example: An organization with network CIDR
192.168.111.105/20 has 90 departments. Determine the number of hosts, the required number of subnets (sufficient for 90 departments) and the subnet mask.- Step 1: Understanding the Network address and Prefix
- Network address:
192.168.111.105 - Prefix
/20 indicates 20 bits from left are fixed for the network 32 – 20 = 12 indicates that the hosts allowable portion is 12 bits11000000.10101000.01101111.01100110/20 (192.168.111.105/20)20 fixed bits for the network; 12 available bits for the hosts
- Step 2: Subnet Mask Calculation
- Convert the network address to binary
- Revert Prefix
/20 first 20 bits from left to 1 - Revert 12 remaining bits to
0 - Convert the Subnet Binary Mask back to decimal
11000000.10101000.01101111.0110011011111111.11111111.11110000.00000000255.255.240.0
- Step 3: Number of Subnets
- Borrow enough bits for 90 departments
- Ensure: 2n≥90 (n borrowed bits)
- 26=64 (not enough)
- 27=128 (sufficient)
- Number of subnets = 128
- Step 4: New Subnet Mask Calculation
- With borrowed bits n = 7
- New Prefix = 20 + 7 = 27
- Convert 27 fixed bits from left to 1
- Convert the Subnet Binary Mask back to decimal
11111111.11111111.11111111.11100000255.255.255.224
- Step 5: Number of Hosts
- Subnet borrowed bits n = 7
- Hosts available bits h = 32 – 27 = 5
- Number of hosts:
2h−2 - 25−2=32–2=30
- Every subnet (of the 128) can have 30 hosts
File Sharing
- SSH (Secure Shell): A protocol that allows secure communication between a local machine (client) and a remote machine (host).
- SSH uses encryption to ensure that the data exchanged between the machines remains confidential and secure.
- SSH is commonly used for logging into remote Unix-like servers, executing commands, and transferring files.
- SSH Connection Formula:
ssh username@hostname_or_ip - SSH authentication is often required when connecting to remote Unix servers. In this case, a private RSA key is required in the formula with the
-i option. - SSH Connection Formula (authenticated):
ssh –i /path-to-local/private_key username@hostname_or_ip scp is a straightforward command-line tool for copying files between a local and a remote host. It uses SSH for secure file transfer.- Uploading a File Using SCP with Private Key (PK):
scp -i /path/to/PK /path/to/file username@hostname:/path/to/remote/directory - Downloading a File Using SCP with Private Key (PK):
scp -i /path/to/PK username@hostname:/remote/file /path/to/local/directory - Note: In both commands, specify precisely the location of the file on the local device and on the host device.
sftp is another way to transfer files securely over SSH. It offers a more interactive way to browse remote directories and transfer files.- After connecting (starting a session),
sftp enables users to download (using get command) and upload (using put command).- Step 1: Start sftp session
sftp -i /path/to/private_key username@hostname - Step 2: Upload using put
put /path/to/local/file /path/to/remote/directory - Step 3: Download using get
get /path/to/remote/file /path/to/local/directory - Step 4: End sftp session
exit