# Network Interface Fundamental Knowledges
[TOC]
## Subnet
**introduction**
A subnet, or subnetwork, is a segmented piece of a larger network. More specifically, subnets are a logical partition of an IP network into multiple, smaller network segments. The Internet Protocol (IP) is the method for sending data from one computer to another over the internet. Each computer, or host, on the internet has at least one IP address as a unique identifier.
**Subnets work**
Each subnet allows its connected devices to communicate with each other, while routers are used to communicate between subnets. The size of a subnet depends on the connectivity requirements and the network technology employed. A point-to-point subnet allows two devices to connect, while a data center subnet might be designed to connect many more devices.

**Subnet segmentation**
The example below uses an 8-bit Subnet ID. The number of bits in the subnet mask depends on the organization's requirements for subnet size and the number of subnets. Other subnet mask lengths are common. While this adds some complexity to network addressing, it significantly improves the efficiency of network address utilization.

A subnet can be delegated to a suborganization, which itself may apply the subnetting process to create additional subnets, as long as sufficient address space is available. Subnetting performed by a delegated organization is hidden from other organizations. As a result, the Subnet ID field length and where subnets are assigned can be hidden from the parent (delegating) organization, a key characteristic that allows networks to be scaled up to large sizes.
## VLAN
A LAN is a grouping of two or more devices on a network. A VLAN is a virtual LAN, a subgroup within a local network. VLANs make it easy for network administrators to separate a single switched network into multiple groups to match the functional and security requirements of their systems.

For multiple VLANs to communicate with each other, a router is required. Routers between VLANs filter broadcast traffic, enhance Network security, perform address summarization, and mitigate network congestion.

The two types of VLANs are port-based (untagged) and tagged. For tagged VLANs, a special “tag” is inserted into packets so that switches and routers will forward those packets correctly. The standard supported by most networking devices for supporting VLANs on Ethernet networks is IEEE 802.1Q. This standard adds a tag of four bytes to an Ethernet frame. This extra information identifies the frame as belonging to a VLAN, and contains the VLAN ID number (up to 4094 VLANs are possible on the same network). Multiple tagged VLANs can use the same port on a switch, called a trunk port.
Untagged VLANs are based on the physical ports on a switch (called **access ports**). There is no extra information added to the Ethernet frame. Instead, each port on the switch is defined as belonging to a specific VLAN. This approach divides a single physical switch into multiple logical switches. If a device is connected to a port in a single VLAN only, then the port should be untagged.
**Port-based VLAN**

**Tagged VLAN**

There is a third type of VLAN port called a hybrid port. This option allows for both devices and trunking to occur. Wireless access points are often configured using **hybrid ports**.
## Netmask
When you apply a netmask to an internet protocol (IP) address, each bit in the netmask indicates whether the corresponding bit in the IP address belongs to the network or host portion. A netmask consists of consecutive 1s followed by consecutive 0s. The 1s represent the network bits, while the 0s represent the host bits. By performing a bitwise logical AND operation between the IP address and the netmask, you isolate the network portion of the address.
## ipv4 / ipv6
IPv4 addresses are 32-bit numbers that are typically displayed in dotted decimal notation and contains two primary parts—the network prefix and the host number. IPv6 is a 128-bits address and consists of eight groups of four hexadecimal digits.
**ipv4**
IPv4 addresses are 32-bit numbers that are typically displayed in dotted decimal notation. A 32-bit address contains two primary parts: the network prefix and the host number.
All hosts within a single network share the same network address. Each host also has an address that uniquely identifies it. Depending on the scope of the network and the type of device, the address is either globally or locally unique. Devices that are visible to users outside the network (webservers, for example) must have a globally unique IP address. Devices that are visible only within the network must have locally unique IP addresses.
**ipv6**
The ongoing expansive growth of the Internet and the need to provide IP addresses to accommodate it—to support increasing numbers of new users, computer networks, Internet-enabled devices, and new and improved applications for collaboration and communication—is escalating the emergent use of a new IP protocol. IPv6, with its robust architecture, was designed to satisfy these current and anticipated near future requirements.
## Route Table
A router is a device that acts as a gateway to a network and is also responsible for forwarding packets or messages to destination addresses. In addition, a router determines the best routes for forwarding packets based on the information stored in its routing table:

A routing table is a table or database that stores the location of routers based on their IP addresses. This table acts as an address map to various networks, and is usually stored in the RAM of most routers or forwarding devices. As such, a routing table contains information about various networks, and how to get to them.
We can generate routing tables dynamically or statically. We usually achieve dynamic generation with the help of routing protocols. In contrast, we achieve static generation by manually entering routes into a routing table. With the dynamic generation of entries, the routing protocols share information with different routes on how to get to different networks.

## Reference
* https://www.techtarget.com/searchnetworking/definition/subnet
* https://www.etherwan.com/support/featured-articles/brief-introduction-vlans
* https://www.baeldung.com/cs/routing-table-entry