🌐 Networking Basics for Cloud & DevOps – Part 2: Public vs Private IP, NAT, Ports, and More

Harshal SonarHarshal Sonar
4 min read

πŸ‘‰ In Part 1 of our Networking series we learned the fundamentals of IP addresses, Subnetting, and CIDR notation.
Now, let’s take a step further into cloud networking concepts that every beginner in Cloud, DevOps, and Docker must know.

Most students and professionals get confused about IP types, NAT, gateways, and ports – so in this blog, we’ll break everything down with simple explanations and examples.


πŸ”Ή 1. Public vs Private IP

πŸ“Œ Private IP

  • Used inside local/private networks.

  • Not routable on the internet.

  • Common ranges:

    • 10.0.0.0 – 10.255.255.255

    • 172.16.0.0 – 172.31.255.255

    • 192.168.0.0 – 192.168.255.255

πŸ’‘ Example:

  • Your home Wi-Fi router assigns devices IPs like 192.168.1.10.

  • These can only communicate within your local network unless translated by NAT.

πŸ“Œ Public IP

  • Globally unique IP, used to access resources on the internet.

  • Assigned by Internet Service Providers (ISP) or Cloud Providers (AWS, Azure, GCP).

πŸ’‘ Example:

  • If your VM in Azure has Public IP 20.50.100.25, you can SSH into it from anywhere in the world.

πŸ”Ή 2. Static vs Dynamic IP

  • Dynamic IP (Default): Assigned automatically by DHCP. May change if VM restarts.

  • Static IP: Reserved and fixed. Useful for databases, DNS servers, or load balancers.

πŸ’‘ Example in Azure:

  • A VM by default gets a Dynamic private IP.

  • You can change it to Static to avoid IP changes when restarting.


πŸ”Ή 3. NAT (Network Address Translation)

  • NAT allows devices with Private IPs to connect to the internet using a Public IP.

  • It hides internal IPs for security.

πŸ’‘ Example:

  • Laptop: 192.168.1.10 β†’ NAT Gateway β†’ Public IP 49.205.120.15 β†’ Google.com

  • Google only sees the public IP, not your private one.

πŸ“Œ In cloud:

  • Azure NAT Gateway or AWS NAT Gateway is used for private VMs that need internet access.

πŸ”Ή 4. VPC / VNet Basics

  • VPC (Virtual Private Cloud – AWS) or VNet (Virtual Network – Azure) = A virtual private network in the cloud.

  • You can divide it into subnets (smaller networks).

πŸ’‘ Example:

  • VPC CIDR: 10.0.0.0/16

    • Public Subnet: 10.0.1.0/24 β†’ Internet access

    • Private Subnet: 10.0.2.0/24 β†’ Internal only

πŸ“Œ In DevOps, you often deploy Jenkins, Databases, or K8s clusters inside VNets/VPCs.


πŸ”Ή 5. Default Gateway & Routing

  • A Gateway connects your subnet to another network (like internet).

  • Usually, the first IP in a subnet is reserved as the Gateway.

πŸ’‘ Example:

  • Subnet: 192.168.1.0/24

  • Gateway: 192.168.1.1

  • Devices in subnet send external traffic to this gateway.


πŸ”Ή 6. Ports & Protocols (TCP vs UDP)

πŸ“Œ TCP (Transmission Control Protocol)

  • Reliable, connection-based.

  • Ensures data reaches destination correctly.

  • Used for web traffic, SSH, email.

πŸ“Œ UDP (User Datagram Protocol)

  • Faster, connectionless.

  • No error-checking, often used in streaming/gaming.

πŸ’‘ Common Ports in DevOps/Cloud:

  • 22 β†’ SSH (secure login to servers)

  • 80 β†’ HTTP (websites)

  • 443 β†’ HTTPS (secure websites)

  • 1433 β†’ SQL Server

  • 3306 β†’ MySQL

  • 53 β†’ DNS


πŸ”Ή 7. Practical Cloud Example

Imagine you deploy a VM in Azure:

  • Private IP: 10.0.0.5 (inside VNet, accessible only internally)

  • Public IP: 20.50.100.25 (accessible from internet)

  • NAT Gateway: Translates 10.0.0.5 β†’ 20.50.100.25 for outbound traffic

  • Port 22 (SSH): Open in NSG (firewall) so you can log in remotely

Same in AWS:

  • Inside VPC β†’ VM gets 172.31.20.15 (private).

  • Attach Elastic IP β†’ VM gets 52.15.220.55 (static public).


🎯 Interview Questions & Answers

Q1. Difference between Public and Private IP?
πŸ‘‰ Private IP works only within internal networks, Public IP is globally routable on internet.

Q2. What is NAT and why is it used?
πŸ‘‰ NAT converts Private IPs into Public IPs for internet access and hides internal IPs for security.

Q3. Static vs Dynamic IP in Cloud?
πŸ‘‰ Dynamic = default, may change; Static = reserved, does not change.

Q4. What is VPC/VNet?
πŸ‘‰ A logically isolated private network in the cloud where you can create subnets.

Q5. Difference between TCP and UDP?
πŸ‘‰ TCP = reliable, connection-oriented. UDP = faster, connectionless.

Q6. What is a Gateway?
πŸ‘‰ A gateway is the router connecting subnet to another network (e.g., internet).

Q7. Which ports are commonly used in DevOps setups?
πŸ‘‰ 22 (SSH), 80 (HTTP), 443 (HTTPS), 3306 (MySQL), 53 (DNS).


πŸš€ Wrapping Up

In this Networking Part 2 blog, we covered:
βœ” Public vs Private IP
βœ” Static vs Dynamic IP
βœ” NAT & its role in cloud
βœ” VPC/VNet basics
βœ” Gateway & routing
βœ” TCP vs UDP with common ports

πŸ‘‰ With this, you now understand how cloud networking actually works.
In the next blog, we’ll connect these concepts with Docker Networking to see how containers talk to each other and the outside world.

πŸ“Œ In case you missed it, check out Networking Part 1 where we explained IP addresses, subnetting, and CIDR with examples.

0
Subscribe to my newsletter

Read articles from Harshal Sonar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Harshal Sonar
Harshal Sonar