AWS SAA-C02_networking

VPC

Default setup

Subnet has name and CIDR address

Subnets

CIDR blocks

Subnet splits a CIDR block into subsets. e.g. 10.0.0.0/16 means 65k hosts. Could subnet, e.g. /17

When set up VPN, specify the CIDR block. Max /16, min /28

Can specify in ipv6 format

Example CIDR setup

5 addresses you can't use for hoist resources: 1st 4, last one.

Why subnet

Subnet architecture

Have subnets in multiple AZs for resilience.

Subnet setup

Public vs Private

IP addressing

By default all subnets have auto assignment of public IP addresses disabled. Switch on with tick box in subnet. Can disable an instance. The IP address comes from AWS bank, not your list. Can't get the same address again. Use EIP (elastic IP address) if you need a static IP address

Public / Private / Elastic IP addresses

Public IP addresses: released when instance stopped, and lost. free. Private IP: used by the operating system. Retained when stopped. Always have one. The other IP addressed are associated to this. Private IP comes from range assigned to the subnet CIDR block range. Elastic: also public. static, retained on stop. Can move it between instances. Charged when not used. Need to associate with an instance (or a network interface).

Internet gateway does the IP swapping from public to private.

Elastic network interface: can set up a network interface.
E.g. used for fail over to a second interface.
Like a virtual network card that you can move between instances.

Routing

Fundamentals

Routing tables allow packets to the forwarded to the correct destination. So don't need to configure routers. AWS adds implicit router to VPC

The packet has an IP address, needs to know how to get to it. Destination is the place you want the packet to get to, target is how to get there. E.g. internet gateway.

Main route table:

Route table setup

  1. Summary
  1. Routes
  1. Subnet associations: shows implicit and explicit

  2. Route propagation: propagation of VPG attached to VPC. Can automatically attach VPG to all subnets.

Routing priorities

The packet has an IP address, needs to know how to get to it. May match multiple routes, so uses the most precise route available in the route table. Longest prefix match.

0.0.0.0 is the most generic destination, matches any IP address

Exceptions:

Routing limits

limit of 200 routes per VPC Default limit of 50 non propagated routes Limit of 100 propagated routes

Virtual private gateways (VGW)

Routing for internet gateways

Routing VPC endpoints

VPC security and control

Network access control list (NACL)

Default rules applied at end, have no rule number. For traffic not meeting any other rule. Inbound restricts based on source, outbound based on destination. NACLs stateless. Can share NACLs between subnets, but each subnet has one. When set up a custom NACL, it starts with deny rules so you need to change it.

Security groups

Rules evaluated until finds one that allows traffic, if not found then not allowed. specify IP ranges, specific IP address with /32, or the ID of a source.

Example setup:

Inbound and outbound rules For inbound, specify the source and protocol When you set up a custom security group.

NAT gateways

NAT instance:

Bastion host (for maintenance SSH access to private subnet instances)

Not possible to access instances on private subnet directly. Use bastion host running in public subnet to give this access

To add a key file permanently so it's accessible:

ssh-add -c jer.pem Configure agent forwarding: get to the public ip: ssh -A ec2-user@1231 get to the private subnet: ssh ec2-user@private ip

Search for agent forwarding on EC2 ssh

On windows for agent forwarding use "pagent" tool

VPC Connections

VPN

Direct Connect

Direct connect gateway

Use when have multiple regions, and you want to connect to all of them.
Like Direct Connect, but a Global service. Use if you need a fast connection using private connection globally

VPC peering

Route table setup for peered connection

Transit gateway

Multiple VPCs and customer sites are complex to manage. Transit gateway allows all your data centres and all VPCs to connect via a central hub. Quite new.

Endpoint services

Allow you to connect from one VPC to services in another, using AWS backbone, not via internet. E.g. someone elses S3.

Flow logs

Capture IP traffic in and out Use to record accepts or rejects.
Can have at VPC, subnet, network interface level. Even if traffic rejected by security groups, can see in here. If you modify a flow log you need to delete and recreate, you can't amend.

VPC wizard

Simplifies setup. Get a public and private subnet with a NAT gateway etc.

Site to site

Network adaptors

  1. ENI: Elastic network Interface

Virtual network card. Has MAC address, IP address etc. Eth0 is primary ENI

  1. ENA: Elastic network Adaptor

Enhanced networking. Lower latency, higher bandwidth.

  1. EFA: Elastic Fabric adaptor

Like ENA with better performance. High performance compute with tightly coupled application with internode comms needing high bandwidth and low latency.

Networking fundamentals

OSI and TCP models

Headers added at each level as you go down, and used on the receiving side as you go up. E.g. source and destination IDs, destination MAC address. Does things like decide is needs to be split into packets.

IPV4 IP addresses

IPv6

Network address translation: source and destination IP addresses translated at boundary of private network.

Netmask

Each bit that is relevant to the network portion gets a binary 1.
So if first 3 octets are network, net mask is 255.255.255.0

CIDR

Reserved IP addresses

Reserving of 3 address ranges using NAT: port forwarding of a single public facing address to internal private network. Addresses in these ranges can't be reached from the internet, but can can be reached via router or each other.
10.0.0.0 172.16.0.0 192.168.0.0

Protocols

Defines how packets, encryption, routing work.

Ports

Allow single IP address used for multiple purposes ports 1 to 1023 are well known. Ports go up to 65k. When you send to a non standard port, need to specify the port after address with colon.

commands

ip a
route
ping 192....

DNS

DNS translation between ip address and hostname.