Basic Networking Terms
LAN(Local Area Network)
Collection of devices connected together in one physical location. Each device has a unique IP(Internet Protocol) address. Devices communicate via these IP addresses.
IP(Internet Protocol)
It's a 32-bit value.
For example, 172.16.0.0
IP addresses can range from 0.0.0.0 to 255.255.255.255
IP address range
Switch
It sits within the LAN and facilitates the connection between all the devices within the LAN.
Gateway is the IP address of the router.
Router
It sits between LAN and outside networks (WAN: Wide Area Network).
It connects devices on LAN and WAN and allows networked devices to access the Internet.
A subnet is the logical subdivision of an IP network.
How to know whether the other device is inside or outside the LAN?
It knows because of the IP address of the target device.
Devices in the LAN belong to the same IP address range.
Subnetting is the process of dividing a network into two or more networks.
CIDR(Classless Inter-Domain Routing) block
It is a subnet mask that dictates how many bits are fixed.
255.255.0.0 => means that 16 bits are fixed
255.255.255.0 => means that 24 bits are fixed
Any device needs 3 pieces of data for communication:
IP address
Subnet
Gateway
NAT(Network Address Translation)
It's the IP address range chosen by an administrator.
Each device gets a unique IP from that range.
How to make sure that IP addresses don't overlap?
IP addresses within LAN are not visible to the outside network or internet.
Your laptop's private IP address is replaced by the router.
Benefits of NAT
Security and Protection of devices within LAN.
Reuse IP addresses.
There are a limited no. of IPv4 addresses available - 4,294,967,296 public addresses.
Firewall
A system that prevents unauthorized access from entering a private network.
Using Firewall Rules you can define, which requests are allowed.
What are these firewall rules?
-
It defines which IP address in your network is accessible and which IP address can access your server.
- For example, you can allow any device to access your server.
It allows the device's IP address at the port to be accessed.
This is also called Port Forwarding.
What is a Port?
Port => every device has a set of ports.
You can allow specific ports(doors).
You can allow specific ports(doors) AND specific IP addresses (guests).
Different Applications listen to specific ports.
Standard Ports for many applications
Port 80 => Web Servers
Port 3306 => MySQL DB
Port 5432 => PostgreSQL DB
For every application, you need a port!
Each port is unique on a device.
DNS or Domain Name Service
It translates domain names to IP addresses.
Why do we use names instead of IP addresses?
- Humans are better at remembering words & names instead of numbers.
For example, www.facebook.com is converted to 69.63.176.13 (Mapping IP addresses to names).
How does DNS manage all these IP addresses?
- Domain Names have a hierarchical structure.
Root Domains (there are 13 root domains named from a to m)
Top Level Domain
There are also geographical domains that were added later.
Who manages these names?
Who can keeps the track of the availability of names?
This is all regulated by a dedicated organization called Internet Corporation for Assigned Names & Numbers*(ICANN)*.
This organization manages the TLD development and architecture of the internet domain space and authorizes Domain Name Registrars, which register and assign domain names.
Each domain name can have a subdomain name with an IP address range of the domain name.
How does the DNS Resolution work?
DNS entries are cached for efficiency.
Networking Commands
ifconfig
=> shows all network details.netstat
=> shows an active connection on your machine.ps -aux
=> shows currently running applications on which port they are listening, computer resources they are consuming, etc.nslookup
=> you can get the IP address of any domain name.ping
=> checks whether a service/application is accessible.
These are used to troubleshoot your network.
- And of course, there are parameters for all those commands.