SAA Notes - Infra and Networking
SAA Notes - Infra and Networking
Let’s Cloud
What Exactly is AWS ?
It is one of the public cloud service provider which has more than 140+ services.
knowledge portal
Gartner’s Magic Quadrant
knowledge portal
AWS Services
AWS has broad range of services available for compute, storage, database, analytics,
encryption, deployment and many more.
With pay as you go model, it reduces the overall costs and help you scale your applications.
knowledge portal
AWS Services - Master Stroke
Real World Scenario - Storage :
Organizations used to invest tens of thousands of dollars in building their storage solutions
for backups. This used to take significant amount of time and high investment.
With AWS S3, in click of an upload button, you get 99.999999999% durability in little less
than a minute of work.
knowledge portal
Pay as you go Model
● Pay as you consume model allows organizations to scale their resources well and only
pay for what they have used.
knowledge portal
AWS Global Infrastructure
Public Cloud Solutions
AWS Data Centers
knowledge portal
Real World Scenarios
In Mumbai, there were very heavy rains in 2005.
knowledge portal
Availability Zone
● AWS Data Centers are organized into Availability Zones (AZ)
knowledge portal
Availability Zone - Part 2
knowledge portal
AWS Regions
● AWS has 22 number of regions worldwide and the number keeps increasing.
knowledge portal
AWS Global Infrastructure
AWS currently operates on 22 regions across the world with 69 availability zones.
knowledge portal
Setting up the Lab
Let’s start Rolling !
Let’s Start
knowledge portal
Registering an AWS Account
knowledge portal
Setting Up SSH Client
Let’s Begin our Journey
Connecting to a Server
After you have launched a server, you need to connect to it to perform administrative tasks.
Server
Definitely
knowledge portal
Connecting to a Server
For Linux Server, you will need a SSH Client to connect.
knowledge portal
Using MobaXterm
For our labs, we will be making use of MobaXterm which comes with SSH client.
Along with SSH client, it comes with various other useful commands like telnet, curl.
MAC and Linux comes with its own terminal which has SSH client. You can skip this step.
Key Based Authentication
Back to Security!
Password Based Authentication
There can be multiple methods for authentication against a system.
knowledge portal
Login with Credentials
Login successful.
Laptop Linux Server
knowledge portal
Challenges with Password Based Authentication
Password based authentication is generally considered to be less-secure.
Many users write down the passwords in notepad files or as part of sticky notes.
Most users would not create a complex password that is difficult to hack.
knowledge portal
Key Based Authentication
In this type of authentication, there are two special keys that are generated.
One key is called as Public Key and second key is called as Private key.
If public key is stored in server and is used as authentication mechanism, only the
corresponding private key can be used to successfully authenticate.
knowledge portal
Key Based Authentication
knowledge portal
Creating our First EC2 Instance
Let’s Start
Overview of EC2
EC2 stands for Elastic Compute Cloud.
knowledge portal
Important Configuration
There are certain important configuration that you need to know while launching a new
EC2 instance in AWS
EC2 Instance
knowledge portal
Connecting to a Server
After you have launched a server, you need to connect to it to perform administrative tasks.
Server
Definitely
knowledge portal
Browser Based SSH Connection
Browser Based SSH Connection allows you to directly connect to EC2 instance from
browser.
knowledge portal
MAC Terminal
knowledge portal
Creating our First Website
We have our EC2 instance up and running.
www.example.com
EC2 Instance
knowledge portal
Requirements for Website
1. Server.
www.example.com
EC2 Instance
knowledge portal
Understanding Firewalls
Firewall without a Fire !
Understanding Ports
A port is a logical entity which acts as a endpoint of communication to identify a given
application or process on an Linux operating system
Opening 22 SSH
Opening 80 HTTPD
knowledge portal
Understanding Firewall
Firewall is a network security system that monitors and controls incoming and outgoing
network traffic based on predetermined security rules.
Deny connect to 22
Allow connect to 80
Allow from Trusted Block from Hackers
knowledge portal
Firewall in AWS
A security group acts as a virtual firewall for your instance to control inbound and
outbound traffic.
Inbound Connection
EC2
Outbound Connection
knowledge portal
Understanding Firewalls
Firewall is a network security system that monitors and controls incoming and outgoing
network traffic based on predetermined security rules.
There can be both hardware based firewalls and software based firewalls.
knowledge portal
knowledge portal
How does it do that ?
ssh serverA
Apache 80
SSH 22
IP : 10.0.5.57 FTP 21
SMTP 25
MySQL 3306
IP : 112.20.50.60
AWS Budgets
Free Tier is Important
Overview of AWS Budgets
AWS Budgets gives you the ability to set custom budgets that alert you when your costs or
usage exceed (or are forecasted to exceed) your budgeted amount.
John has created a new AWS account and want to be under free tier.
knowledge portal
knowledge portal
Virtual Private Cloud
Do things the right way
Let’s understand with a use-case
John works as Finance manager. He is migrating to a new city because of his job and plans to live
in an apartment.
House 1 House 2
knowledge portal
Analogy in terms of servers
VPC VPC
knowledge portal
Let’s understand with a use-case
John has decided to buy a new house. For additional income, he has decided to rent part of hise
house .
Partition 1
Partition 2
knowledge portal
Let’s understand with a use-case
Among the 5 servers, we have decided following architecture:
Subnet 1
Subnet 2
Additional Layer of Security - Partition Wise
Partition 1
Partition 2
knowledge portal
Additional Layer of Security - Partition Wise
John decides to build two entrance so that individuals in partition 1 can directly go out of the
house.
Partition 1
Partition 2
knowledge portal
Additional Layer of Security - Partition Wise
Solutions Architect creates a route so that servers from subnet 1 can connect to the internet.
For subnet 2, no routes has been created hence servers cannot reach the internet.
Subnet 1
Subnet 2
knowledge portal
Inter-Communication
There can be a need for servers from two subnets to speak with each other.
So you can create a route that can allow communication between two subnets.
Subnet 1
Subnet 2
knowledge portal
Inter-Communication
There can be a need for servers from two subnets to speak with each other.
So you can create a route that can allow communication between two subnets.
Subnet 1
Subnet 2
knowledge portal
Important Learnings
EC2 instance launched in a VPC will be protected or not protected based on configuration of VPC.
Let’s start!
Revising Basics of VPC
Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a
virtual network that you've defined.
EC2 instances inside VPC will be able to communicate to each other using private network.
10.77.0.5 10.77.0.6
VPC - 10.77.0.0/16
knowledge portal
Today’s Practical
Name: demo-vpc
knowledge portal
Important Note
Every region in AWS has a default VPC with CIDR range of 172.31.0.0/16.
This allows customers to start launching EC2 without having to manually create a VPC.
knowledge portal
Creating Subnets
Let’s create Subnetworks
Creating Subnetworks - Analogy
Each subnet has its own set of range that is derived from the larger VPC range.
Subnet 1 (1-50)
VPC (0-100) 1 15
Subnet 2 (51-100)
55 84
knowledge portal
Creating Subnetworks - Technical
Subnet 1 (10.77.2.0/24)
10.77.2.5
VPC (10.77.0.0/16)
Subnet 2 (10.77.4.0/24)
10.77.4.5
knowledge portal
Creating Subnet Process
When you create a subnet, following are some of the important setting that need to be
configured.
Setting Description
IPv4 CIDR Block Smaller CIDR block from the Main VPC Range.
knowledge portal
knowledge portal
Internet Gateway
Connect to Internet
Simple Analogy
You have recently moved to a new house.
You have a laptop and you want to watch some Youtube videos.
knowledge portal
VPC Network
The EC2 instances inside VPC will be able to communicate with each other.
Internet
10.77.0.5 10.77.0.6
VPC - 10.77.0.0/16
knowledge portal
Internet Gateway
An internet gateway is a component that allows communication between your VPC and the
internet.
IGW
VPC - 10.77.0.0/16
knowledge portal
Route Tables
Let’s Route
Simple Analogy
Few years back, I had a trip from Coimbatore to Bangalore (~400 kms) in scooty.
knowledge portal
Direction Billboards
Direction Billboards are very useful to determine the next turning point to reach the
destination.
knowledge portal
Overview of Routers
A router is a networking device that forwards data packets between networks.
Each router has a route table that contains the routing rules.
Connect to 10.77.0.5
Internet
10.77.0.0/16 VPC
0.0.0.0/0 Internet
Route Table
Route Table in AWS
A route table contains a set of rules, called routes, that determine where network traffic from
your subnet or gateway is directed.
Towards Internet
VPN
VPC IGW
Route Table
High-Level Working - Internet Route
knowledge portal
High-Level Working - Local Route
10.77.2.5
knowledge portal
Public and Private Subnets
knowledge portal
Private Subnet
Private subnets are the ones that do not have an Internet Gateway attached to it.
No New connections from the Internet can reach to the EC2 instances within the private
subnet.
knowledge portal
Benefits of Private Subnet
Since internet connectivity is not present, it is much more difficult by an attacker to attack
the system in private subnet directly.
Attack Attack!
knowledge portal
Important Note
Even though the EC2 instance are in private subnet, the local level communication between
EC2 in public and private will still work using private IPs.
knowledge portal
The Network Architecture
knowledge portal
Configuring Public and Private Subnet
Better Architecture
Public Subnet Configuration
Following is true for Public Subnet:
Internet Gateway
Public Subnet
Destination Target
10.77.0.0/16 local
Internet Gateway
Private Subnet
Destination Target
10.77.0.0/16 local
Steps to Configure Public and Private Subnet
There will be 2 route tables: One for Public Subnet and Second for Private Subnet.
Destination Target
10.77.0.0/16 local
Public Subnet
Destination Target
10.77.0.0/16 local
Private Subnet
NAT Gateway
Allow Outbound Internet Connectivity
Challenge with Instance in Private Subnet
Since there is no Internet connectivity in Private subnet, the EC2 instance and application inside
it will not be able to perform any kind of patch updates, download new softwares etc.
Internet Gateway
Private Subnet
knowledge portal
Overview of NAT Gateways
NAT Gateway allows instances in the private subnet to initiate a new connection towards the
Internet.
NAT
Gateway
knowledge portal
Working of NAT Gateway
knowledge portal
Example 2 - NAT Gateway
knowledge portal
New VPC Create Experience
Create VPC Quickly
Understanding Challenge
If you want to create a new VPC setup, there are multiple components that you have to
configure:
knowledge portal
New VPC Create Experience
AWS has released a new VPC Create Experience that allows us to quickly setup entire VPC
infrastructure with click of just few buttons.
knowledge portal
VPC Peering
Let’s Route
VPC Peering
VPC peering is a network connection between two VPC that enables the communication
between instances of both the VPC.
172.31.0.0/16 10.77.0.0/16
knowledge portal
Today’s Architecture - 1
First VPC - 172.31.0.0/16
172.31.0.0/16 10.77.0.0/16
knowledge portal
Today’s Architecture - 2
10.66.0.0/16
172.31.0.0/16
10.77.0.0/16
Things to Remember
● VPC Peering is now possible between regions.
knowledge portal
Unsupported VPC Peering Configurations - 1
You cannot create a VPC peering connection between VPCs with matching or
overlapping IPv4 CIDR blocks.
knowledge portal
Unsupported VPC Peering Configurations - 2
You have a VPC peering connection between VPC A and VPC B (pcx-aaaabbbb), and
between VPC A and VPC C (pcx-aaaacccc).
There is no VPC peering connection between VPC B and VPC C. You cannot route
packets directly from VPC B to VPC C through VPC A.
knowledge portal
Network ACL
Multiple Layers for Defense
Understanding the Basics
A network access control list (ACL) is an optional layer of security for your VPC that acts as a
firewall for controlling traffic in and out of one or more subnets.
Public/Private Subnets
knowledge portal
Understanding with Use-Case
Company XYZ is getting lot of attacks from a random IP 128.190.12.32. The company has
more than 500 servers and Security team decided to block that IP in firewall for all the servers.
250 EC2
Network ACL
250 EC2
DENY 128.190.12.32
Important Pointers
Each subnet in your VPC must be associated with a network ACL. If you don't explicitly
associate a subnet with a network ACL, the subnet is automatically associated with the
default network ACL.
Default NACL allows all inbound and outbound IPv4 traffic and, if applicable, IPv6 traffic.
You can associate a network ACL with multiple subnets. However, a subnet can be
associated with only one network ACL at a time.
knowledge portal
Amazon Machine Image
Let’s Image
Overview of AMI
Amazon Machine Image (AMI) is the master image from which new EC2 instances can be
launched.
Security Hardening
Configure SELinux
Configure firewalld
Install IPS agent
Configure Auditd
Create Security user Amazon Linux
knowledge portal
Hardened AMI
EC2 Instances
knowledge portal
Launch Templates
● AMI ID
● Instance Type
● Security Group
● Key Pair
● Storage
● IAM Role
● VPC
Everytime when you intend to launch instance, going through process is time consuming,
knowledge portal
Introduction to Launch Templates
Launch templates enable you to store launch parameters so that you do not have to specify
them every time you launch an instance.
knowledge portal
EC2 Pricing
Cost Optimization
Paying for EC2 Instances
There are fives primary ways in which we can pay for EC2 instance usage.
1. On-Demand
2. Savings Plan
3. Reserved Instances
4. Spot Instances
5. Dedicated Hosts
knowledge portal
On-Demand Pricing
With On-demand instances, we pay for compute capacity per hour or per second
depending on the instances which is being run.
No upfronts payments are needed and we can increase or decrease the capacity whenever it
is needed.
knowledge portal
On-Demand Can Lead to Unexpected Issues
A “Cloud Service Provider” will not have a clear picture on how many servers should the
provision. Too high → resources might unused and too low → money loss
knowledge portal
Reserved Instance
Reserved instance are assigned to a specific availability zone and provides capacity
reservation for AWS EC2 instances.
Example :
You know you will always be running 20 servers of m4.2xlarge type of 1 year, then buy
reserved instances for them.
knowledge portal
Reserved Instance - Part 2
Example: g4dn.8xlarge instance type
Savings ~62%
knowledge portal
Spot Instance
Spot instances allows us to bid on spare Amazon EC2 computing capacity for up to 90%
of the on-demand cost.
Such instances are recommended for applications that can have flexible start and end times
knowledge portal
Savings Plans
Savings Plans are a flexible pricing model that offer low prices on EC2 and Fargate usage,
in exchange for a commitment to a consistent amount of usage (measured in $/hour) for a
1 or 3 year term.
knowledge portal
Dedicated Host
A dedicated host is a physical EC2 server dedicated for your use.
knowledge portal
Join us in our Adventure
kplabs.in/twitter
Be Awesome
kplabs.in/linkedin