# Introduction to Network

###### tags: `network`
[TOC]
# Basic Knowledge
Take one IP as example in this subnet, 192.168.0.100/24
192.168.0.0 -> Subnet
192.168.0 -> Network ID
100 -> Host ID
192.168.0.255 -> Broadcast IP (used to broadcast msgs to usable ip address)
192.168.0.1~254 -> Usable IP address
192.168.0.254 -> Gateway
**/24** means it covers from 0~254.
# Different Cables

>Left is Copper Cross-Over, while Right is Copper Straight-Through (In Cisco Packet Tracer Software)[color=orange]
**Copper Cross-Over** (Used between same equipments):
1. PC to Router (Exception)
2. Router to Router
3. Switch to Switch

**Copper Straight-Through** (Used between different equipments):
1. Router to Switch
2. Switch to PC

**Having difficulty to differenciate Cross-Over and Straight Through Cables?**
**Firstly**, we need to identify two types of **Crystal Head (水晶頭)**

* **568A** begins with stripe green, all green, stripe orange, blue, stripe blue, orange, stripe brown and brown.
* **568B** begins with stripe orange, all orange, stripe green, blue, stripe blue, green, stripe brown and brown.
>In other words, green and orange are opposite in both Crystal Head! [color=red]
When we are done identifying these two, we can just check whether the cable has **two 568B (Straight Through)** or **one 568A and one 568B (Cross-Over)**.
# What is Router?
Router helps to do routing (connect different subnets).
Take below image as example, it will help 192.168.10.254 connect to 192.168.20.254 (which are from different subnets).

# What is Switch?
All equipment below same switch will share the same gateway and are in same subnet.
# Which port do we connect between Router and Switch?
Usually we connect from first port of Router to the last port in Switch.
>[color=orange]
# Set up PC static IP
For PC we have two options:
(1) Use DHCP
(2) Set Static IP
## DHCP Option
In this case you do not need any information, as everything will be automatically filled for you.
However, you need to be aware that, the IP may change from day to day. If you need to test something, it might as well be good to set a static IP.
## Static IP
As you can see below, you will be required to set **IPv4 Address**, **Subnet Mask**, **Default Gateway** and **DNS Server**.

# What is DNS?
DNS is used to convert domain name into IPs.
## What are domain name?
Usually we just open the computer, connect network cable or just link to wifi and just open a browser a type a url. Ex: "www.google.com.tw". This google.com.tw is the domain name.
**What do we need to know?**
Actually each part of the domain name, will be actually managed by a bunch of people/sector/department.
Let's take this url as example: cse.yzu.edu.tw
```=
root:
.tw
(managed by Taiwan Information center TWNIC 財團法人台灣網路資訊中心)
.com
.edu (managed by education department)
.yzu
.cse
.uk
.ar
...
```
# What is **ping** command?
We mostly use **ping ip** command to check whether IP can be reached or not in terminal.
Let's take below image as example:
>[color=orange]
## ping between PC's below same Switch
If we use **PC0** we can use terminal and check whether it can ping PC6's IP. That is because they are below same Switch, meaning they are in same IP range.
```=
ping 192.168.10.2
```
This will be a success, if the IP configuration was set correctly.
**Note:**
What if IP configuration in both PC are correct? This means that **ethernet card (網卡)** is probably broken.
## ping between PC's below same Router
If PC's configuration was set correctly and Router port to each PC gateway was set correctly, then you should be able to ping from PC0 or PC6 to PC1.
```=
ping 192.168.20.1
```
If it does timeout, it means something was not set correctly and needs revision.
# Network Layers
Network Layers is actually composed by 7 layers in total. These layers are what we call **osi model**.

## Physical Layer
We usually think about **Hubs**, which are mostly not used anymore.
# VPN
**VPN** also called **Virtual Private Network** is used to link to specific place **public IP** to create a **VPN tunnel** that lets your computer have a temporary IP below same subnet of specific place. Like this you can link to devices below that network.
**VPN** is described by 3 words: **private**, **anonymously** and **encripted**

![Uploading file..._70y5r0st8]()