5. Networking Services (I) Flashcards
Internet Protocol - IP
Acts as a computer “address” in the internet network, such that other PCs know where to send the information to.
Internal IPs + DNS
Internal IPs use DNS to translate all the different IP ranges into websites.
DNS types:
1. Zonal - recommended due to higher reliability
2. Global
- Each instance has a hostname (so like ‘printer-work’ rather than printer-work.us-central1-a.c.my-project-id.internal - FQDN (Fully Qualified Domain Name)
- For instance to be able to identify what’s its external IP, it creates like a lookup table using DHCP (Dynamic Host Configuration Protocol) - auto assignment of IPs rather than manual
Note: you can create alias IP ranges (so if the VM was assigned an IP, the services on the VM can have sub-IPs)
Note: having internal DNS for the instances allows us to ping the instances using their names rather than the internal IPs, the internal IPs may change, but the name won’t, so DNS helps us to have something ‘fixed’ we can refer to.
Note: it’s good to have instances in the same subnet because firewall rules can be then simply applied to that subnet rather than each instance individually.
- it’s RECOMMENDED to have just internal IP, not external, for the instances that need to communicate with the outside inet for updates, can use Cloud NAT or Private Google Access to access Google APIs and Services without external IPs.
Commands to create a new VPC network, make it custom and add subnets
gcloud compute networks create VPC-name –subnet-mode=custom
Adding firewall rules
-tcp: 22 (SSH) , 3389 (RDP)
gcloud compute firewall-rules create my-firewall-name –direction=INGRESS –priority=1000 –network=VPC-name –action=ALLOW –rules=tcp:22,tcp:3389,icmp –source-ranges=0.0.0.0/0
Pricing of ingress/egress traffic of VMs
- all ingress is FREE
- egress in the same zone and to internal IP/Google cloud service (youtube etc) is FREE
- egree to other zones/regions/external IPs is CHARGED
Lab: enable Private Google Access & Cloud NAT on instances without external IP
- if a VM instance has no External IP, we won’t be able to SSH into it, so use IAP (Identity-Aware Proxy) tunnel from the Cloud Shell to get the secure connection.
gcloud compute ssh vm-name –zone=us-central1-c –tunnel-through-iap
- when a VM has only internal IP, other instances within the same network can only reach it using a managed VPN gateway or Cloud IP tunnel
- Google Private Access is enabled at the subnet level, so to enable it, need to go to the VPCs and find our network, click on the subnet, edit, and then tick the Google Private access option.
To enable Cloud NAT:
- Go to Network Services –> Cloud NAT –> select my VPC, the region.
-Then need to create Cloud Router
Open Systems Interconnection Model (OSIM)
7 layer OSIM model:
- application (HTTP - HTTPS - DHCP - DNS - SSH - Telnet)
- presentation
- session
- transport (TCP - UDP , IP Packets)
- network (IPv4 - IPv6 , IP address Subnets)
- data link
- physical
Each layer has a protocol.
Internet Protocol: Network layer
IPv4 (came out in 1981) - 4 Bn possible combinations
IPv6 (came out in 2017) to tackle the problem of the amount of usable IPs being slowly used up by IPv4
Internet Protocol: Network layer
IPv4 notation (dotted decimal notation)
Each number ranges from 0 to 255
Each group contains 8 bits, so 1 byte
192.168.255.255
Private IP addresses were standardised by standard RFC1918
Internet Protocol: Network layer
IPv4: Classless Inter-Domain Routing (CIDR)
192.168.0.0/16
It means we are “sub-netting” the network
The bigger the /.. part, the smaller the network.
Internet Protocol: Network layer
IPv4: Classless Inter-Domain Routing (CIDR):
Helpful References
Note: bold parts are FIXED
192.168.0.0/8 - 16+ million IP addresses
192.168.0.0/16 - 65,536 IP addresses
192.168.0.0/24 - 256 IP addresses
192.168.1.2/32 - 1 IP address (good for your personal VPN network configuration)
0.0.0.0/0 - All IP addresses
Internet Protocol: Network layer
IPv6: Hexadecimal notation
Each grouping is a Hextet = 16 bits
1452:0db8:0000:0000:0000:fe02:0042:8452
1452:0db8:0:0:0:fe02:0042:8452 (same as above)
1452:0db8::fe02:0042:8452 (same as above)
The whole address is 128 bits
::/0 - All IP addresses
Internet Protocol: Transport layer (TCP/UDP)
IP Packet - unit of info
TCP - transmission control protocol
UDP - user datagram protocol
A typical IP Packet / datagram includes:
- Source IP address
- Destination IP address
- Protocol Port Number (source/destination)
- Data
Internet Protocol: Application layer (HTTP - HTTPS - DHCP - DNS - SSH - Telnet)
Used by applications that use the inet.
HTTP/HTTPS - used for Load Balancing
DHCP
DNS - uses UDP transport layer on port 53
SSH - on port 22
Telnet
Virtual Private Cloud (VPC)
- global resource
- virtualised Datacentre
- VPCs live within projects
- VPCs don’t have any IP address ranges associated with them
- resources within a VPC can communicate with one another using internal (private) IPv4 addresses
- IPv4 only
- VPC contains a default network
- 2 network types: Auto Mode or Custom Mode (no automatic creation of subnets or IP ranges)
Custom mode is RECOMMENDED
Different Networks = different VPCs (external IP required)
VPC peering or a VPN connection is required for the VMs from different networks to communicate with each other, even if they are located in the same zone
VPC default network
Within a default network:
- IPs with subnet in each region is created
VPC default network:
Command to change subnet
gcloud compute networks subnets expand-ip-range default –region=us-west1 –prefix-length=16
VPC Network Subnets
- the name or region of a subnet cannot be changed after it is created
Note: Google allows to increase the subnet IP space without any shut down time
Note: the addresses within THE SAME VPC NETWORK cannot overlap + they must be inside the RFC1918 address-space
Auto Mode network starts with /20 network range and can be expanded to /16
Note: network range can be expanded but cannot be reduced!
Note: There are some reserved IP addresses that I cannot choose (1st address - reserved for Network, 2nd - for Default Gateway, 2nd-to-last - for Google Cloud future use, last - for broadcast)