Network¶
System Administration - Network¶
Table of Contents¶
What is what?¶
IP ?
Each NIC card is defined by it’s
IP. There are two defined IPs; Private and Public.IP is consist of 4
octet[octet.octet.octet.octet]Private IP: {
10.0.0.0/8,192.168.0.0/16,172.16.0.0 : 172.32.0.0}.
Mask ? /8, /16, or /32
It’s the ip’s mask.
The mask define the range of ips.
How to calculate the IPs range?
Mask defines the fixed
octetin the IP.e.g.,
/8means 8 bits = (255.0.0.0) Decimal = (11111111.00000000.00000000.00000000) Binary.e.g.,
/16means 16 bits = (255.255.0.0) Decimal = (11111111.11111111.00000000.00000000)You can consider that the mask is bitwise add (logically operation) with the IP.
Subnet is a range of IP addresses: (Network Address + Mask) e.g., (
192.168.1.0/24)Accordingly, for example:
Each IP
10.x.x.x (/8)means that the Network address for this IP range all have a 1 fixed octet; all start with 10.x.x.x, starting from10.0.0.0till10.255.255.255.Each IP
192.168.x.x (/16)means that the Network address for this IP range all have a 2 fixed octet; all start with 192.168.x.x, starting from192.168.0.0till192.168.255.255.
IP: 192.168.1.130 Mask: 255.255.255.0 (/24) IP: 11000000.10101000.00000001.10000010 Mask: 11111111.11111111.11111111.00000000 ----------------------------------------- AND: 11000000.10101000.00000001.00000000 Result: 192.168.1.0 ← network address
Note:
Octet means 8 bits. Each 8 bits can represent values from 0 to 255. We can’t name it digit; A digit is a single symbol from (0 to 9)
The reason AND works (logical necessity, not convention); as mask bits {
1-> keep the IP bit,0-> Zero it out}. This guarantees that All hosts in the same subnet produce the same network address, and Hosts in different subnets do not.Mask
/32means 4 Octet, so there is only one 1 IP assigned in the range.
Switch¶
graph TD
SW[Switch]
SW --> D1["NIC eth0"]
SW --> D2["NIC eth1"]
SW --> D3["NIC eth2"]
Each device connected to the a
switchthroughport, can reach neighboring devices in the sameswitch; They share the same subnet.
Recall:
layers: Physical Layer -> Data Link Layer -> Network Layer -> Transport Layer ….
Data Link Layer deals with MAC addresses only, it is responsible for setting [Source: Device MAC address, Destination: Device MAC address].
How in Data Link Layer we know the destination MAC address? using ARP “Address Resolution Protocol”; It check the target IP, the source checks its ARB cache for that target IP, if found, then it returns the associated MAC address, it not, then ARB request broadcast; it asks the switch to scan all related ports for that IP in order to learn target [IP:MAC address].
Router¶
graph TD
R[Router]
R --> SW1[Switch 1]
R --> SW2[Switch 2]
SW1 --> D1["NIC eth0"]
SW1 --> D2["NIC eth1"]
SW2 --> D3["NIC eth0"]
SW2 --> D4["NIC eth1"]
In order to access a device that is not on the same
switch, it has to reach out to therouter, that connects to otherswitch.
VLAN¶
graph TD
SW[Switch]
subgraph VLAN_A
A1[NIC eth0]
A2[NIC eth1]
end
subgraph VLAN_B
B1[NIC eth0]
end
SW --> A1
SW --> A2
SW --> B1
The idea here is to separate NIC/devices from each other, so they can’t reach each other directly.