Public vs Private IP Address Explained
Let's start. In the previous chapter we learnt what an IP address is, how to count IPv4 addresses, and the difference between static and dynamic IP. Now we answer one simple question: if there are only about 429 crore IPv4 addresses, how is the whole world still online? On the way we will see your home router, ports, the web server, SSH, IP classes, localhost, and why free WiFi is never really free. We finish with the reason every part of an IP stops at 255. Don't worry, you will get it slowly.
In this class
- Recap: 4,294,967,296 IPv4 addresses
- Why dynamic IP alone is not enough
- Public IP and private IP
- Talking without internet, by distance
- How your router does NAT
- Why IPv4 has not run out yet
- Router public IP: static or dynamic?
- WiFi and mobile data together
- Mobile hotspot: your phone as a router
- Ports, and the default ports 80 and 443
- Web server and
/var/www/html - SSH on port 22
- URL syntax: protocol rules
- IP classes A to E, and CIDR
- How many devices fit in a network
- Private ranges and cloud work
- Who hands out IP addresses
- Loopback,
127.0.0.1and localhost - HTTP vs HTTPS, and free WiFi
- Binary: why each part stops at 255
- Homework
Classroom line
Does anyone have a question on what we did yesterday?
Class मधलं वाक्य
"Kaal jevdha zalay tyachyat kunala kay question aahe ka?"
काल जेवढं झालंय, त्यात कोणाला काही question आहे का?
Classroom line
Does anyone have a question on what we did yesterday?
1. Recap: IPv4 and the 4,294,967,296 problem
Everything in this chapter grows from one problem, so first we restate that problem.
An IPv4 address has 4 parts, each from 0 to 255, so it runs from 0.0.0.0 to 255.255.255.255.
- One part: 256 values (0 to 255).
- Two parts: 256 × 256 = 65,536.
- Three parts: 256 × 256 × 256 = 16,777,216.
- Four parts: 256 × 256 × 256 × 256 = 4,294,967,296, about 429 crore.
The world has 800+ crore people, and each person uses more than one device. So IPv4 addresses are short.
How we handled it so far.
| Who gets it | Why | |
|---|---|---|
| Static IP | servers | clients must find the server at the same address every time; the domain name (bought from a registrar such as GoDaddy) points to it through DNS |
| Dynamic IP | clients: phones, laptops | given while you are online, taken back when you disconnect, then given to someone else |
The app on your phone does not keep the server's IP inside it. It keeps a domain name, and DNS turns that name into the server's static IP.
2. Why dynamic IP alone is not enough
Even if every phone gives its IP back at night, there are still far more devices online at the same moment than 429 crore addresses. Reuse over time is not enough.
Classroom line
Dynamic IP does not completely solve the IP problem... so IPs were again split into two types: Public IP and Private IP.
Class मधलं वाक्य
"Dynamic IP completely IP cha jo problem ahe to solve karat nahi... tyasathi IP che parat don types aale, ek Public IP aani ek Private IP."
Dynamic IP मुळे IP चा problem पूर्ण solve होत नाही... म्हणून IP चे परत दोन types आले: एक Public IP आणि एक Private IP.
Classroom line
Dynamic IP does not completely solve the IP problem... so IPs were again split into two types: Public IP and Private IP.
So now we have two pairs of words. Static and dynamic tell you how long an address stays with a device. Public and private tell you where the address works.
3. Public IP and private IP
If every phone, laptop and TV in every home needed its own public IP, IPv4 would have finished long ago. Private IPs let a whole house share one public IP.
Two independent choices for one address
Think of two questions you can ask about an address. Can it be used on the public internet? Who decides when the device gets a different one? For example, your laptop can get a private, dynamic address from the router. Your home printer can have a private, reserved address so other people in the house can keep finding it. A single lab EC2 server can use a public, fixed address allocated to the AWS account.
Take the same example address, 192.168.0.20, in two houses. Each local network knows its own device with that address. If the two houses later join their networks through a VPN, a router may have no way to know which house you intended. Cloud engineers plan different private ranges before joining networks for exactly this reason.
| Public IP | Private IP | |
|---|---|---|
| Works where | on the whole internet | only inside your own network (home, office, AWS VPC) |
| Who gives it | your internet provider (ISP) | your router (or AWS inside a VPC) |
| Unique? | unique in the whole world | the same numbers are reused in every home |
| Example | 3.3.3.3 |
192.168.0.2, 192.168.0.3 |
How it looks at home.
- The ISP line (Jio Fiber, Airtel Fiber, or a local cable operator) comes into your home router.
- For this example, the ISP gives the router one public IPv4 address, say
3.3.3.3. - Inside the house, the router is the gateway at
192.168.0.1. - The router gives your devices private IPs: phone
192.168.0.2, second phone192.168.0.3, laptop192.168.0.4, TV192.168.0.5. 192.168.0.0is the network address. It names the whole network and is never given to a device or the router.- The circle around the router and the devices is your private network.
Figure 1. Your home: the ISP gives the router one public IP (3.3.3.3). Inside the private network the router is 192.168.0.1 and the devices are .2, .3, .4, .5.
Do devices on a private IP get internet? Yes. Your phone on 192.168.0.2 watches reels every day. A private IP cannot travel on the public internet by itself, so the router swaps it for its own public IP on the way out (this swap is called NAT) and swaps it back on the way in. We trace that swap step by step in section 5.
Ravindra Bagale's Tip
Many beginners write the router as 192.168.0.0. .0 is the network address. The router is usually 192.168.0.1 (some brands use 192.168.1.1), and devices start from .2.
4. Talking without internet: it depends on distance
Before we see how the internet works, ask a smaller question: suppose the ISP cable is cut. Can two devices still talk?
A question. Two friends sit in the same room. One wants to send a file to the other. There is no internet and no data pack. How?
- SMS? No. SMS needs a recharge and a mobile network.
- Bluetooth, mobile hotspot, or file-sharing apps like ShareIt? Yes, these work without internet.
How far each one reaches (rough typical values):
| Distance | What works | Note |
|---|---|---|
| about 1 m | infrared | old phones and TV remotes; must point at each other |
| about 10 m | Bluetooth | file sharing, earphones |
| about 100 m | WiFi, mobile hotspot, LAN | a local network; devices get private IPs |
| 500 m to 1 km | walkie-talkie | radio voice only, no files; it is not IP networking |
| several km | your own cable | copper LAN cable runs about 100 m per run; for longer, fibre cable |
| anywhere in the world | the internet | when laying your own cable is not possible |
Classroom line
If you are rich, you can lay a cable even 10 kilometres long.
Class मधलं वाक्य
तुम्ही श्रीमंत असाल तर 10 kilometer पर्यंत पण cable टाकू शकता.
Classroom line – हिंदी
"Agar aap amir ho toh aap 10 kilometer tak bhi cable daal sakte hai."
Figure 2. How far devices can talk without internet: infrared about 1 m, Bluetooth about 10 m, WiFi about 100 m, your own cable for longer, and the internet when you can't lay a cable.
So what is the internet? It is mostly cables: fibre cables on land and under the sea, joining the networks of ISPs, companies and cloud providers. The mobile tower or your WiFi is only the last wireless hop to your phone.
5. How your phone reaches Google through the router (NAT)
Your phone has a private IP, yet it gets answers from Google. Something has to translate. That something is the router, and the trick is NAT (Network Address Translation).
Inside the home, devices talk to each other directly over WiFi. Anything going outside stops at the router first. When you search "weather Pune" on Google, the packet does not go straight to Google. It goes to the router.
Step by step (suppose numbers):
- Your phone
192.168.0.2searches "weather Pune". It builds a packet: From192.168.0.2:50001, To8.8.8.8:443(here, suppose Google is8.8.8.8). - The packet goes to the router,
192.168.0.1. Inside the house, the router finds your phone by its MAC address; the MAC is used only inside the local network. - The router writes one line in its NAT table: inside
192.168.0.2:50001↔ outside3.3.3.3:40001. - The router changes the From address to its public IP: From
3.3.3.3:40001, To8.8.8.8:443. - The packet travels over the internet to Google.
- Google answers: From
8.8.8.8:443, To3.3.3.3:40001. Google only ever sees3.3.3.3. - The router looks up
3.3.3.3:40001in the NAT table and finds192.168.0.2:50001. - The router changes the To address back to
192.168.0.2:50001and hands the answer to your phone.
Two people searching at the same time. Your sister on 192.168.0.3 searches "cricket score" at the same moment. The router writes a second line: 192.168.0.3:50001 ↔ 3.3.3.3:40002. Both answers come back to the same public IP 3.3.3.3, but on different ports, so the router never mixes up your weather with her cricket score.
| Inside (private IP:port) | Outside (public IP:port) | Search |
|---|---|---|
192.168.0.2:50001 |
3.3.3.3:40001 |
weather Pune |
192.168.0.3:50001 |
3.3.3.3:40002 |
cricket score |
Figure 3. The router's NAT table: each private IP:port is swapped for the public IP 3.3.3.3 with its own port. The answer from 8.8.8.8 comes back to that port and is handed to the right phone.
Figure 4. Animation: the packet leaves the phone From 192.168.0.2, the router swaps it to From 3.3.3.3, it reaches 8.8.8.8, and the answer comes back the same way.
Ravindra Bagale's Tip
In interviews many candidates say "the router remembers a request ID". Say it correctly: the router keeps a NAT table that maps private IP and port to public IP and port. This same idea comes back in AWS as the NAT Gateway for private subnets.
6. Why IPv4 has not run out yet: every home reuses the same private IPs
429 crore addresses, 800+ crore people, many devices each, and still everyone is online. Here is the trick.
- In my home, the router has public IP
3.3.3.3, and my devices are192.168.0.2,192.168.0.3, … - In your home, the router has public IP
5.5.5.5, and your devices are also192.168.0.2,192.168.0.3, … - There is no clash, because private IPs never leave their own network. Only the routers' public IPs go on the internet.
- So crores of homes use the same
192.168.0.xnumbers again and again. - Mobile companies do the same at a bigger scale: many phones share one public IP (carrier-grade NAT).
Figure 5. Two homes use the same private IPs 192.168.0.2 and .3 without any clash. On the internet only their public IPs, 3.3.3.3 and 5.5.5.5, are seen.
How you can see it yourself. On the same Wi-Fi, compare the public IPv4 seen by the same test service. Devices using the same IPv4 NAT path usually share the same outward address. A VPN, mobile data or an IPv6 result can make the comparison look different. You will test this in the homework.
How many devices fit on one home router? A home network like 192.168.0.x (in AWS terms, a /24) has 256 addresses, .0 to .255:
192.168.0.0is the network address. Not usable.192.168.0.255is the broadcast address. Not usable.- That leaves 254 usable addresses,
.1to.254. - The router takes one (
.1), so about 253 devices can join.
7. Is the router's public IP static or dynamic?
A common question: is the router's public IP static or dynamic?
- Most home routers get a dynamic public IP. Today it may be
3.3.3.3; after a restart or a few days, it may change. - The main reason: ISPs save scarce IPv4 addresses, and dynamic is cheaper for everyone.
- If you need a fixed one (for example, to run a server from home), you can buy a static IP from your ISP.
- Being a client does not force an IP to be dynamic. Dynamic is simply the cheaper and more common choice for homes.
8. WiFi and mobile data, both on
Everyone keeps both on. Which one does the phone use?
- If WiFi is connected and working, the phone prefers WiFi.
- If the WiFi has no internet, the phone falls back to mobile data.
- On mobile data alone, your phone gets its address from the mobile company. Often this is also a private address behind a shared public IP (carrier-grade NAT).
9. Mobile hotspot: your phone becomes a router
When you turn on hotspot for a friend, your phone does exactly what the home router does.
- Your phone broadcasts its own WiFi name.
- It gives private IPs to the devices that connect.
- It sends their traffic out through its own mobile-data address, using NAT, just like the home router.
- If your friend searches "cricket score", the website sees your phone's public address, not your friend's private IP.
How many devices? A hotspot allows only a few devices, often about 5 to 10, set by the phone maker. A phone's CPU, battery and RAM are not built to serve many devices like a real router.
Privacy on someone's hotspot. The hotspot owner's phone carries all your traffic. On plain HTTP they could read what you send. On HTTPS the content is encrypted. We come back to this in section 20.
10. Ports: the IP reaches the server, the port reaches the app
One server can run many programs at once: a website, a database, a remote-login service. The IP only takes you to the machine. Something must say which program inside it.
A listening port and a connection are different
Picture one lab Linux server running a website on TCP 80 and SSH on TCP 22. When the web process starts, it tells the operating system where to accept incoming web connections. We call that listening. Linux uses the protocol, address and port to hand the connection to the right program. A browser can fail to open the site while SSH still works. The server is reachable, but the two connections ask for different services.
Two students can visit the same website at the same time. Both connections use destination port 80. Their devices choose source ports for their own connections, so the operating system can distinguish their traffic. TCP and UDP also have separate port spaces. When you write a cloud rule, say TCP 80 so both parts are clear.
A port is a number from 0 to 65,535 (that is 65,536 ports) that the operating system gives to a program on the network.
- The browser opens
http://3.3.3.3/login.html(orhttps://instagram.com/login.html; suppose this as an example). - If you typed a name, DNS first turns the name into the IP.
- The request reaches the server
3.3.3.3. The IP's job is done here. - The port number says which program on
3.3.3.3should get the request.
Building and flat. The IP is the building address; the port is the flat number inside the building. The courier needs both.
Ravindra Bagale's Tip
A network port is not a hardware pin on the CPU and not the USB port on your laptop. It is a logical number in the operating system (TCP or UDP). Think building = IP, flat number = port.
11. Default ports: 80 and 443
Nobody types :80 in the browser, yet it works. The browser adds it for you.
| You type | The browser actually uses |
|---|---|
http://3.3.3.3 |
http://3.3.3.3:80 |
https://3.3.3.3 |
https://3.3.3.3:443 |
http://3.3.3.3:8080 |
port 8080, because you typed it |
So http://3.3.3.3:80 and http://3.3.3.3 open the same page.
Common ports you will use in this course:
| Port | Program |
|---|---|
| 22 | SSH (remote login to the server) |
| 80 | HTTP (website) |
| 443 | HTTPS (secure website) |
| 3306 | MySQL database |
| 9000 | php-fpm (PHP behind Nginx) |

Whiteboard: Default ports to remember: HTTP uses 80, HTTPS uses 443 and SSH uses 22.
12. The web server: who listens on 80 and 443?
Opening port 80 is not enough. A program must be running and listening on it, or the browser gets nothing.
That program is the web server. Examples: Apache, Nginx, Tomcat, IIS, Gunicorn, Uvicorn.
How a request for login.html is served (Apache):
- The browser asks
http://3.3.3.3/login.html. - The request reaches port 80 on
3.3.3.3. - Apache is listening on port 80.
- Apache's default web folder (document root) is
/var/www/html. - Apache sends back the file
/var/www/html/login.html.
On Amazon Linux, Nginx's default web folder is /usr/share/nginx/html instead.
You will do this yourself in the lab:
sudo yum install httpd -ysudo service httpd start- Put your page at
/var/www/html/login.html. - Open
http://<your-server-IP>/login.htmlin the browser.
13. SSH on port 22: managing the whole server
Visitors only need your website files. You, the admin, need the whole server: install software, create folders, read logs.
SSH stands for Secure Shell. It runs on port 22 and gives you a command line on the server from your laptop.
How the drawing works:
- The server
3.3.3.3is a big box. The website is one small folder inside it,/var/www/html. - Visitors come through port 80 or 443 and only reach that folder.
- The admin opens PowerShell on the laptop and connects with SSH on port 22.
- Now the admin is inside the whole server and can run commands, for example
mkdir ravi.
Figure 6. One server, 3.3.3.3. Visitors reach only the website folder through ports 80 and 443. The admin reaches the whole server through SSH on port 22.
Why SSH needs extra care.
| What was hacked | What is affected |
|---|---|
| The website | that site and its data |
| SSH | the whole server: every file, every site on it, every setting |
That is why a hacked SSH login is the most dangerous kind. In AWS, protect it:
- In the security group, allow port 22 only from My IP, not from everywhere (
0.0.0.0/0). - Log in with a key pair, not a password.
- Keep the private key file safe and never share it.
Classroom line
Any question here?
Class मधलं वाक्य
"Ithe kai question?"
इथे काही question?
Classroom line
Any question here?
14. URL syntax: a protocol is a set of strict rules
A protocol is a set of rules both sides follow exactly. One wrong character and the browser does not understand you.
Read http://3.3.3.3:80/login.html piece by piece:
httpis the protocol. Notfttp, nothtp.://is a colon and two slashes.3.3.3.3is the server's IP (or a domain name).:separates the IP from the port.80is the port./login.htmlis the file you want.
Figure 7. Every piece of a URL has a fixed place: protocol, colon and two slashes, IP or name, colon, port, then the file path.

Whiteboard: Reading a URL piece by piece: protocol (http), then ://, then the IP address (3.3.3.3), then : and the port (80), then / and the path (login.html).
Classroom line
After HTTP you must write a colon... a semicolon won't work, a comma won't work... you must write two slashes.
Class मधलं वाक्य
HTTP नंतर colon च लिहायचा... semicolon लिहिला तर नाही चालणार, comma लिहिला तर नाही चालणार... दोन slash लिहायलाच पाहिजेत.
Classroom line – हिंदी
"HTTP ke baad colon hi likhna hai... semi-colon likha, nahi chalega. Comma likha, nahi chalega... do slash likhna hi hai."
15. IP classes A to E
In the early internet, IPs were handed out in fixed-size blocks called classes. The first part of the IP tells you the class. You will still hear these names in interviews and at home routers.
Look only at the first part of the IP:
| Class | First part | Network and host parts | Used for |
|---|---|---|---|
| A | 0 to 127 (usable 1 to 126) | N.H.H.H | very large networks |
| B | 128 to 191 | N.N.H.H | medium networks |
| C | 192 to 223 | N.N.N.H | small networks, like a home |
| D | 224 to 239 | – | multicast (one sender, many receivers) |
| E | 240 to 255 | – | reserved, experimental |
N is the network part (same for every device in that network). H is the host part (different for each device).
0.x.x.xis reserved, and127.x.x.xis inside class A but reserved for loopback (section 19). So class A hosts use 1 to 126.- Only classes A, B and C are given to normal devices.
Worked examples:
| IP | First part | Class |
|---|---|---|
10.0.0.5 |
10 | A |
127.0.0.1 |
127 | A range, but reserved for loopback |
172.16.4.20 |
172 | B |
192.168.0.2 |
192 | C |
224.0.0.5 |
224 | D (multicast) |
Figure 8. The first part of the IP decides the class: A 0 to 127 (127 is loopback), B 128 to 191, C 192 to 223, D 224 to 239 multicast, E 240 to 255 reserved.
How it is done today: CIDR. Classes are history. Modern networks, and AWS VPC, use CIDR: a slash number says how many bits are the network part. /8 is like class A, /16 like class B, /24 like class C, but you can choose any size, for example /20.
16. How many devices fit in a network
When you make a network in AWS you choose its size. So you must know how many devices each size holds.
Count the addresses that an AWS subnet can use
Modern network ranges use a slash such as /24, called a CIDR prefix. IPv4 has 32 bits. If 24 bits name the network, eight bits remain, giving 2^8 = 256 addresses in the block. A /28 leaves four bits, so its block has 2^4 = 16 addresses.
AWS reserves the first four and the last IPv4 addresses in each normal VPC subnet. For 10.0.2.0/28, the whole block runs from 10.0.2.0 to 10.0.2.15. AWS reserves .0 through .3 and .15. The usable addresses are .4 through .14, which is 11 addresses. Keep two numbers in your notebook: the block has 16 addresses and EC2 can use 11 of them. This avoids carrying the home-network subtraction rule into AWS.
- A home router uses a class C style network,
192.168.0.x. Only the last part changes, 0 to 255: 256 addresses, 254 usable (.0network,.255broadcast). - A class B style network changes the last two parts: 256 × 256 = 65,536 addresses.
- A home router is not built for that many devices. Big offices and malls use enterprise network equipment.
- In AWS, a
/24subnet has 256 addresses, and AWS keeps 5 of them in every subnet, so 251 are usable for your servers.
| Network | Addresses | Usable |
|---|---|---|
192.168.0.0/24 (home) |
256 | 254 (253 devices plus the router) |
AWS subnet /24 |
256 | 251 (AWS keeps 5) |
/16 (class B style) |
65,536 | 65,534 |
17. Private IP ranges, and why cloud work is mostly private
You must recognise a private IP on sight, because in AWS almost every server you build will have one.
These three ranges are private (RFC 1918). Everything else, except the reserved blocks, is public and handed out through ISPs and cloud providers.
| Range | Class style | Example |
|---|---|---|
10.0.0.0 to 10.255.255.255 |
A | 10.0.1.25 |
172.16.0.0 to 172.31.255.255 |
B | 172.31.5.10 |
192.168.0.0 to 192.168.255.255 |
C | 192.168.0.2 |
Watch out: 172.15.0.1 and 172.32.0.1 are not private. Only 172.16 to 172.31 is.
Classroom line
Our whole working life goes in private IPs... most of our work stays in private IPs.
Class मधलं वाक्य
आपलं पूर्ण आयुष्य private IP मध्ये जातं... आपलं जास्त काम private IP मध्येच असतं.
Classroom line – हिंदी
"Apna jo poora life hai, yeh private IP mein jata hai... Apna zyada kaam private IP mein rehta hai."
How a big app uses them. Suppose an app like Instagram runs on 100,000 servers (a "suppose" number to learn with):
- Only the front-door servers and load balancers face the internet with public IPs.
- The app servers and databases talk to each other on private IPs.
- In AWS this becomes a VPC with public subnets (front door) and private subnets (everything else).
18. Who hands out IP addresses?
If every country or company just picked any IP, two machines could get the same address and the internet would break.
Classroom line
These IPs don't belong to any one country... they are the whole world's property.
Class मधलं वाक्य
हे IPs कोणत्या एका देशाचे नाहीत... ही पूर्ण जगाची property आहे.
Classroom line – हिंदी
"Ye IPs kisi ek desh ke nahi hai... poori world ki property hai."
The chain:
- IANA manages the whole IP address space for the world.
- IANA gives large blocks to five regional registries. For India and the Asia-Pacific region it is APNIC.
- APNIC gives blocks to ISPs and cloud providers (Jio, Airtel, AWS and others).
- The ISP gives one IP from its block to your router or phone.
- IPv4 has run out at the registries, so IPv4 blocks are now also bought and sold between companies on a transfer market.
Does an IP tell your location? The numbers inside an IP do not mean ISP, state or district. But because registries record which ISP got which block, location services map whole blocks to a rough city and ISP. So your public IP can reveal roughly where you are and which ISP you use.
19. Loopback and localhost: 127.0.0.1
On one server, programs often need to talk to each other: the web server to PHP, PHP to the database. Sending that out to the internet and back would be slow and unsafe.
Test the service from the right machine
On the EC2 server, localhost means the EC2 server. In a terminal on your laptop, localhost means the laptop. If the website opens from curl http://127.0.0.1/ in SSH but you cannot open the public address from your browser, you have proved that the web process answered locally. Now check which address the program listens on, then its port, the instance’s security group and the public route. If the local request fails too, start with the web service itself.
Read the two prompts before doing the test. One is your laptop and the other is inside EC2. Label your results with the machine and address you used so you can repeat the same check later.
The whole range 127.0.0.0 to 127.255.255.255 is loopback: traffic sent there never leaves the machine. 127.0.0.1 is the one everyone uses, and localhost is its name.
How it works on one server:
- A visitor reaches Nginx on port 80.
- Nginx passes PHP work to php-fpm at
127.0.0.1:9000. (On Amazon Linux php-fpm may use a socket file instead of port 9000; the idea is the same.) - php-fpm asks MySQL at
127.0.0.1:3306. - All of this stays inside the server. Same IP, different ports.
- You could use
127.0.0.2or127.0.0.3, but normally everyone uses127.0.0.1and separates programs by port.
Figure 9. Inside one server, Nginx (80), php-fpm (9000) and MySQL (3306) talk to each other on 127.0.0.1. That traffic never leaves the machine.
Try it on your server: curl http://localhost shows the page your web server is hosting, without going through the internet.
20. HTTP vs HTTPS: what others can see
On someone's hotspot or a cafe's WiFi, every packet of yours passes through their device. What they can read depends on HTTP or HTTPS.
Have the browser verify the site before sending a login
HTTPS uses TLS, the protocol that sets up an encrypted connection. A website certificate names the host it is valid for. The browser checks that name and whether the certificate is trusted. If the lab service has a certificate for shop.example.com and you enter the raw IP, the browser can see a name mismatch even though the server and port are correct. If a warning appears, stop and check the name and certificate before entering a password.
After the secure connection is established, details such as the HTTP request path and the submitted form are protected in transit. The network can still observe where traffic goes at the IP level and when it moves. In the browser, compare the addresses of a test page loaded over HTTP and HTTPS. Use a public practice page or your own lab and keep real passwords out of the exercise.
| HTTP | HTTPS | |
|---|---|---|
| Data travels as | plain text | encrypted |
| Port | 80 | 443 |
| Needs | nothing extra | an SSL/TLS certificate on the server |
| WiFi owner can read your password? | yes | no, only scrambled data |
Example. You log in to a site on cafe WiFi.
- On
http://example.com, your username and password travel as plain text. The WiFi owner could read them. - On
https://example.com, the same login travels encrypted. The WiFi owner sees only scrambled data. - Payment and shopping apps (PhonePe, Paytm, Flipkart, Amazon) use HTTPS, so public WiFi is far safer than it used to be. Still, be careful.
Figure 10. Animation: on HTTP the password crosses the cafe WiFi as readable text; on HTTPS it crosses as scrambled data, and the WiFi owner sees only the site name.
21. Free WiFi in the mall: who is paying?
Classroom line
Nobody buys anyone tea or vada pav for free, so who gives free WiFi without any benefit?
Class मधलं वाक्य
कोणी कोणाला फुकट चहा पाजत नाही, वडापाव खाऊ घालत नाही, मग फायदा नसताना free WiFi कोण देतंय?
Classroom line – हिंदी
"Koi kisi ko chai nahi pilata, vada pav nahi khilata, toh kaun Wi-Fi free mein de raha hai bina fayde ka?"
What the free WiFi owner can see, even with HTTPS:
- The From and To IPs of every packet, because the router needs them to deliver it.
- Which sites you visit, mainly from your DNS lookups and from the site name your browser sends at the start of an HTTPS connection.
- When and how much you use.
What they cannot see with HTTPS: your messages, passwords and page content.
An IP alone does not always tell the app, because many sites share the same big content-delivery servers. The lesson stays: free WiFi can see which sites, not what you send.
22. See your own phone's traffic
Seeing your own packets makes all of this chapter's ideas real.
Packet-capture apps on Android (for example "PCAPdroid" or older "Packet Capture" apps) create a local VPN on your phone and show your own phone's connections: which apps talk to which servers, and on which ports.
- Install a packet-capture app from the Play Store on your own phone.
- Start a capture.
- Open a few apps.
- See which IPs and ports each app uses, and which connections are HTTP or HTTPS.
Use it only on your own phone. Watching other people's traffic without their permission is not okay.
23. Why each part of an IP stops at 255: binary
So far we have said "no part goes above 255". Now we see why.
Humans count in decimal (0 to 9). Machines understand only binary: 0 and 1. So every IP is stored in binary.
The question: how many zeros should each part use? 4, 8, 16 or 32? The answer is 8 bits (8 binary digits) for each part. 8 bits = 1 byte.
0.0.0.0in binary is00000000.00000000.00000000.00000000.- The next IP,
0.0.0.1, is00000000.00000000.00000000.00000001. - An IPv4 address is 4 parts × 8 bits = 32 bits.
Classroom line
This is the quality of our studying... this all happens because of rote learning. If you understand it, this never happens.
Class मधलं वाक्य
"He aahe aaplya abhyasachi quality... He ratta marlyamule asa hota sagla. Samjhun ghetla tar asa kadhi hotach nahi."
ही आहे आपल्या अभ्यासाची quality... हे सगळं रट्टा मारल्यामुळे होतं. समजून घेतलं तर असं कधी होतच नाही.
Classroom line
This is the quality of our studying... this all happens because of rote learning. If you understand it, this never happens.
Counting in binary, 0 to 15:
| Decimal | Binary | Decimal | Binary |
|---|---|---|---|
| 0 | 0 | 8 | 1000 |
| 1 | 1 | 9 | 1001 |
| 2 | 10 | 10 | 1010 |
| 3 | 11 | 11 | 1011 |
| 4 | 100 | 12 | 1100 |
| 5 | 101 | 13 | 1101 |
| 6 | 110 | 14 | 1110 |
| 7 | 111 | 15 | 1111 |

Whiteboard: Counting in binary: decimal 0 to 15 next to their binary forms, from 0, 1, 10, 11 up to 1111. Four bits give 16 values, 0 to 15.
The biggest 8-bit number. Fill all 8 bits with 1: 11111111. Each place has a value, starting from the right: 1, 2, 4, 8, 16, 32, 64, 128.
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

Whiteboard: One IP part is 8 bits, with place values 128, 64, 32, 16, 8, 4, 2, 1. Set every bit to 1 and add them: 128+64+32+16+8+4+2+1 = 255. That is why each part stops at 255.
Figure 11. Animation: eight bits, place values 128 to 1. When all eight are 1, they add up to 255. 256 would need a 9th bit.
So:
- One part has 8 bits, so it can hold 0 (
00000000) to 255 (11111111). - 256 in binary is
100000000. That needs a 9th bit, which an IPv4 part does not have. - That is why
256.0.7.8is never an IP address.
24. Homework: try at home
Try at home
Test 1: many devices, one public IP
- Turn on the mobile hotspot on your phone.
- Ask 2 or 3 friends to connect to it.
- Everyone opens Google and searches "my IP".
- Compare the public IPv4 results using the same test service. On the same translated IPv4 path the outward address can be shared. Check for IPv6, a VPN or a separate cellular path if the answers differ.
- That is NAT: private IPs behind one public IP.
Test 2: find your own private IP
- On a Windows laptop, open Command Prompt and run
ipconfig. - Look for IPv4 Address (for example
192.168.0.4) and Default Gateway (for example192.168.0.1). - On Linux, run
ip addrand look at the line starting withinet. - Check: does your IP fall in one of the three private ranges?
- Now search "my IP" on Google. The public IP you see is different from your private IP.
Test 3 (optional): localhost
- If a web server is running on your laptop or server, open
http://localhost. - On your AWS server you can run
curl http://localhost. - The page comes from the same machine, through
127.0.0.1.
Ravindra Bagale's Tip
Many beginners search "my IP" and write down the 192.168.x.x address from ipconfig as their public IP. They are two different things: ipconfig shows the private IP your router gave you; Google shows the public IP of your router.
Common errors and fixes
| Error / symptom | Fix |
|---|---|
| I put a private IP in the browser from outside | Private ranges (10.x, 172.16–31.x, 192.168.x) are not reachable from the internet. Use the instance public IP or a VPN/bastion. |
| SSH times out but ping works | Port 22 is closed in the Security Group, or you are using the wrong IP/user. |
| Two apps on the same server fight | They need different ports (or different hostnames). Only one process can listen on a given IP:port. |
| I opened port 80 but https fails | HTTPS is port 443. Open 443 too, or stay on http for practice. |
| Class A/B/C confusion | For modern work, think CIDR and private ranges first; classful names are history for interviews. |
FAQ
Q. Why do we still use IPv4?
NAT and private ranges let many devices share few public addresses. IPv6 exists, but most labs still start on IPv4.
Q. What is localhost / 127.0.0.1?
It always means this same machine. Traffic never leaves the computer.
Q. Public IP vs Elastic IP?
Public IP can change on stop/start. Elastic IP is a static public IPv4 you allocate in AWS.
Q. Which ports must I remember?
22 SSH, 80 HTTP, 443 HTTPS, 3306 MySQL/MariaDB are the ones you meet first.
Recap
In short
- IPv4 has 4,294,967,296 addresses, about 429 crore, for 800+ crore people. Dynamic IP alone does not solve it.
- Public IPs work on the internet; private IPs work only inside your network and are reused in every home.
- Your router is
192.168.0.1, devices start at.2, and.0is the network address. - The router does NAT: private IP:port ↔ public IP:port, so private devices still reach the internet.
- A
/24home network has 254 usable addresses; with the router, about 253 devices. - Without internet, distance decides: infrared, Bluetooth, WiFi, your own cable. The internet itself is mostly fibre.
- The IP reaches the server; the port (0 to 65,535) reaches the program. 80 HTTP, 443 HTTPS, 22 SSH, 3306 MySQL, 9000 php-fpm.
- SSH is Secure Shell; a hacked SSH login exposes the whole server.
- Classes: A, B, C for hosts, D multicast, E reserved. Today AWS uses CIDR (
/16,/24). - Private ranges:
10.x,172.16to172.31,192.168.x. IANA → APNIC → ISPs hand out IPs. 127.0.0.1(localhost) never leaves the machine.- HTTPS hides content, not which sites you visit. Free WiFi is never fully free.
- 8 bits of 1 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. That is why no part goes above 255.
Samjla ka? Do the hotspot "my IP" test tonight. Kalel tumhala, halu halu kalel. In the next chapter we go deeper.
Ravindra Bagale, trainer: linkedin.com/in/ravindra-bagale. All IPs on this page are dummy numbers for learning. Instagram on 100,000 servers is a "suppose" example, not a fact about Instagram.
Worked example: two homes can have the same private address
Picture two students with the same roll number in different classes. The number works when you know which classroom you are in. A private address works the same way inside a network.
- Write down two homes, each with a laptop at
192.168.1.20. Each laptop can browse because its own router forwards and translates traffic for it. - Now suppose one router shows
100.72.4.9as its WAN IP. That falls inside the shared100.64.0.0/10range. The ISP can be translating again between the router and the public internet. This is carrier-grade NAT. - Compare the router's WAN address with the address reported by a trusted IP-check service. A mismatch suggests an upstream translation or proxy. Check with your ISP before expecting inbound access.
Interview question: is every non-private address publicly reachable?
No. Some ranges have special purposes, and routing and firewall rules still decide reachability. In this example the ISP shared range is separate from the three private ranges you learned in this chapter.
Practise this chapter
Interview questions and answers
Why can both a private address and a public address be dynamic?
Dynamic describes how the address is assigned and when it might change. Private describes a reserved address range used inside networks. A home router can lease a private address to your phone; the provider can also assign a changeable public address on the outward path.
SSH opens but the website times out. Does SSH prove the web port is open?
SSH proves its own service and network path work on its port, typically TCP 22. Check whether the web process listens on the intended interface and port. Then check the rule for that web port and whether local HTTP works.
Check your understanding
Choose an answer, then compare your reasoning with the explanation.
Apply the concepts
Imagine two devices share one home Wi-Fi connection. Sketch their two private addresses and the public-facing side of the router.
Check your result
The sketch uses two different local addresses and shows how the public side can be shared. You can explain why replies still reach the right device.
In your notebook classify 10.20.0.3, 172.20.0.4 and 172.32.0.4 against the private IPv4 ranges from the lesson.
Check your result
The first two are RFC 1918 private addresses. 172.32.0.4 is outside the RFC 1918 172.16–172.31 block.
On your lab host, suppose the local website gives 200 but the public request times out. Explain what you have already verified and what you inspect next.
Check your result
You identify a working local listener and then check public addressing, listening interfaces and network permissions for the chosen port.
Practice Tasks
Practice checks run in your browser. They check the answer for this exercise; they do not create resources or connect to your AWS account.
About this scenarioLondon Legal LLP is a law business in London. Oliver Hughes looks after its IT and cloud work. They count money in GBP and run their AWS resources in the eu-west-2 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.
0 / 12
Easy How many addresses in a /16?
Picking a VPC size needs this count.
London Legal LLP plans the VPC 10.49.0.0/16. How many IP addresses does it hold in total?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Easy Create a VPC
A VPC is your own private network in AWS. Everything else lives inside it.
Create a VPC with the CIDR block 10.5.0.0/16.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium First usable IP for a server
The first 4 addresses are reserved by AWS.
What is the first IP address a server can get in 10.49.20.0/24 on AWS?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Do these VPCs overlap?
Peering fails when ranges overlap.
Can VPC 10.49.0.0/16 peer with VPC 10.49.128.0/17? Answer yes or no.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Find the VPC router address
AWS reserves base+1 for the router.
Which address does AWS reserve for the VPC router in subnet 10.49.4.0/24?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Usable IPs in an AWS /24 subnet
AWS keeps 5 addresses in every subnet.
How many addresses can London Legal LLP use for servers in subnet 10.49.1.0/24 on AWS?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Usable IPs in a /28
/28 is the smallest AWS subnet.
Subnet 10.49.9.0/28 on AWS. How many usable IPs?
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Medium Create a subnet in one AZ
Subnets split the VPC range and each one lives in exactly one AZ.
In vpc-05432ea314deadbee, create subnet 10.5.1.0/24 in eu-west-2a.
- Read the task and decide which AWS service it is about.
- Write aws, then the service name, then the operation (the action word).
- Add each needed flag (--name) followed by its value from the task.
- Flags can be in any order. Click Check answer.
Medium CloudFormation: web security group
Opening only 443 keeps the server safer.
Template with an AWS::EC2::SecurityGroup that allows TCP 443 from 0.0.0.0/0. Add a GroupDescription.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Fill in each property with the value from the task.
- Click Check answer. Key order does not matter.
Hard Range of a /26
Knowing the range stops subnets from overlapping.
Write the first and last address of 10.49.3.64/26 (like a.b.c.d - e.f.g.h).
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Hard Pick the smallest prefix
Right-sizing saves address space.
A subnet must hold 100 servers on AWS. What is the largest prefix number (smallest subnet) that fits? Answer like /25.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Hard Split a /24 into two
Public and private subnets often split one block.
Split 10.49.8.0/24 into two equal subnets. Write both CIDRs separated by a comma.
- Write down the numbers the task gives you.
- Work it out step by step on paper.
- Type only the final answer in the box.
- Click Check answer.
Quick revision cards
Revise this lesson in two minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens its lesson.










More cards: Ravi Sir's Cards.