IP Addressing, Subnets, Gateway, NAT & Routing
This lesson goes one level deeper into networking.
We already know:
Browser
↓
DNS
↓
Public IP
↓
Internet
↓
VPS
↓
Port 443
↓
Nginx
Now we need to understand:
How does the packet know where to go?
1. IP Address = Address
Think of an IP address like an address used for network delivery.
Example:
192.168.1.20
But an IP address has two conceptual parts:
Network portion
+
Host portion
2. Example
Consider:
192.168.1.20/24
The /24 tells us that the first 24 bits are the network prefix.
Conceptually:
192.168.1 | 20
network | host
3. Why Do We Need a Network Portion?
Suppose a computer wants to communicate with:
192.168.1.30
and its own address is:
192.168.1.20/24
They belong to the same /24 network.
The computer can communicate with the destination through the local network rather than sending the traffic to its default gateway.
4. Different Network
Now suppose the destination is:
10.0.0.20
The source:
192.168.1.20/24
and destination:
10.0.0.20
are on different networks.
The computer needs a router.
Usually that means:
Computer
↓
Default Gateway
↓
Router
↓
Destination network
5. Subnet
A subnet is a defined IP network.
Example:
192.168.1.0/24
This represents the network.
Hosts can use addresses within the usable host range, depending on the addressing model.
6. /24 in Binary
IPv4 has:
32 bits
A /24 means:
11111111.11111111.11111111.00000000
The first:
24 bits
are the network prefix.
The remaining:
8 bits
are host bits.
7. Why 256 Addresses?
With 8 host bits:
2⁸ = 256
possible bit combinations exist.
So:
192.168.1.0/24
contains:
256 IPv4 addresses
Some addresses have special roles in traditional IPv4 subnetting, so the number of ordinary assignable host addresses is lower.
8. Network Address
For:
192.168.1.0/24
the network address is:
192.168.1.0
It identifies the subnet itself.
9. Broadcast Address
Traditionally, the /24 broadcast address is:
192.168.1.255
It is used for IPv4 broadcast within that subnet.
Cloud networking environments can impose their own rules around which addresses are usable.
10. Host Addresses
The traditional usable host range for:
192.168.1.0/24
is:
192.168.1.1
–
192.168.1.254
Again:
network address
and:
broadcast address
are not ordinary host assignments.
11. CIDR
CIDR means:
Classless Inter-Domain Routing
Instead of only using old fixed classes such as:
Class A
Class B
Class C
CIDR allows flexible prefix lengths.
Examples:
/8
/16
/24
/25
/26
/27
and many others.
12. Smaller Prefix = Larger Network
Compare:
10.0.0.0/24
with:
10.0.0.0/16
A /16 has more host bits:
32 - 16 = 16 host bits
Therefore:
2^16 = 65,536
addresses.
13. /24
32 - 24 = 8
host bits.
Therefore:
2^8 = 256
addresses.
14. /25
32 - 25 = 7
host bits.
Therefore:
2^7 = 128
addresses.
15. /26
32 - 26 = 6
host bits.
Therefore:
2^6 = 64
addresses.
16. Subnetting
Suppose you have:
10.0.0.0/24
You can divide it into smaller networks.
For example:
10.0.0.0/26
10.0.0.64/26
10.0.0.128/26
10.0.0.192/26
Each /26 contains:
64 addresses
17. Why Subnet?
Cloud networks use subnets to organize systems.
For example:
VCN
│
├── Public subnet
│ └── Web server
│
└── Private subnet
└── Database
This creates logical network separation.
18. Your Oracle Cloud Example
Conceptually:
Oracle Cloud
│
▼
VCN
│
▼
Subnet
│
▼
VNIC
│
▼
Ubuntu VM
The subnet determines the VM’s private IP network.
19. Private IP
Your VM may have a private IP such as:
10.0.0.10
This address is used inside the VCN.
It is not normally directly reachable from the public Internet.
20. Public IP
Your VM can also have a public IP.
For example:
203.0.113.25
The public Internet uses that address to reach your Internet-facing endpoint when the cloud networking configuration permits it.
21. Public-to-Private Mapping
Conceptually:
Internet
│
▼
Public IP
│
▼
Cloud networking
│
▼
Private IP
│
▼
VNIC
│
▼
VM
The exact implementation is controlled by the cloud platform.
22. NAT
NAT means:
Network Address Translation
It changes network addressing information as traffic crosses a boundary.
A common concept:
Private IP
↓
NAT
↓
Public IP
23. Why Private IPs Exist
Private address ranges are designed for internal networks.
Common IPv4 private ranges include:
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
These are not globally routable Internet addresses.
24. Home Network Example
Your home network may look like:
Laptop
192.168.1.20
│
▼
Wi-Fi Router
192.168.1.1
│
▼
Public Internet
The router performs NAT for outbound traffic in the common home-network setup.
25. Hosting Example
Your cloud VM can have:
Private IP
10.x.x.x
and a public Internet-facing address.
The cloud networking infrastructure handles the relationship between the public endpoint and the VNIC/private address according to its configuration.
26. Routing
Now we reach:
Routing
Routing answers:
Where should this packet go next?
Linux has a routing table.
Run:
ip route
27. Example Routing Table
You might see:
10.0.0.0/24 dev ens3
default via 10.0.0.1 dev ens3
Interpretation:
10.0.0.0/24
↓
directly reachable through ens3
and:
everything else
↓
10.0.0.1
28. Default Gateway
The:
10.0.0.1
in this example is the:
Default Gateway
Traffic for destinations that don’t match a more specific route goes there.
29. Routing Decision
Suppose the server wants to reach:
10.0.0.50
and has:
10.0.0.0/24
The route matches.
Therefore:
server
↓
ens3
↓
local network
30. Another Destination
Suppose the server wants:
8.8.8.8
That doesn’t belong to:
10.0.0.0/24
So:
server
↓
default route
↓
gateway
↓
Internet
31. Longest Prefix Match
When multiple routes match, the router generally chooses the:
Most specific route
Example:
10.0.0.0/8
and:
10.1.0.0/16
Destination:
10.1.5.20
The /16 is more specific than /8.
Therefore it wins.
32. Why This Matters
Routing can become complicated when your server has:
multiple interfaces
multiple subnets
VPN
private networks
public networks
But the basic principle remains:
destination
↓
routing table
↓
best matching route
↓
next hop/interface
33. ARP
Now we go one level deeper.
On an IPv4 Ethernet-style network, a machine needs to discover the hardware-layer address associated with a local IP.
That mechanism is:
ARP
Address Resolution Protocol.
34. IP vs MAC
An IP address is a network-layer address.
A MAC address identifies a network interface at the link layer.
Example:
IP:
192.168.1.20
and:
MAC:
aa:bb:cc:dd:ee:ff
35. ARP Question
Suppose:
Computer A
192.168.1.20
needs to send to:
192.168.1.30
It may need to discover:
Which MAC address owns 192.168.1.30?
ARP performs this mapping.
36. ARP Cache
Linux keeps recently learned mappings.
Check:
ip neigh
You may see:
192.168.1.1 dev ens3 lladdr aa:bb:cc:dd:ee:ff REACHABLE
37. Important Cloud Difference
In cloud networks, you should not assume everything works exactly like a physical Ethernet LAN.
The cloud provider virtualizes and controls the underlying networking.
So:
ARP concepts
remain useful for understanding networking, but the cloud platform may implement virtual networking behavior differently from a traditional physical LAN.
38. Packet Journey to Your VPS
Let’s imagine a user opens:
https://learn.cresignsys.com
39. Step 1 — DNS
Browser needs the IP address.
learn.cresignsys.com
↓
DNS
↓
Public IP
40. Step 2 — TCP
Browser connects to:
Public-IP:443
using TCP.
41. Step 3 — Internet Routing
The packet travels through multiple networks:
User
↓
ISP
↓
Internet routers
↓
Oracle Cloud
You don’t normally control the intermediate Internet routers.
42. Step 4 — OCI Network
Inside OCI:
Internet
↓
Internet Gateway / appropriate path
↓
VCN
↓
Subnet
↓
VNIC
The exact route depends on your OCI configuration.
43. Step 5 — Security
Security rules determine whether the connection is permitted.
Conceptually:
TCP
443
↓
OCI security rules
↓
ALLOW?
If not:
connection blocked
44. Step 6 — Ubuntu
If the packet reaches the VM:
VNIC
↓
Linux network interface
Linux then processes the packet.
45. Step 7 — TCP Port 443
Linux checks whether a process is listening on:
TCP 443
If Nginx is listening:
TCP
↓
Nginx
46. Step 8 — TLS
Nginx performs the TLS handshake.
It presents the appropriate certificate.
Then:
encrypted HTTPS connection
is established.
47. Step 9 — HTTP
The browser sends an HTTP request such as:
GET /
Host: learn.cresignsys.com
Nginx uses:
Host
to select the appropriate virtual server configuration.
48. Step 10 — Website
Nginx maps the request to:
/storage/websites/learn.cresignsys.com/public
Then:
static file
may be served directly.
Or:
PHP request
↓
PHP-FPM
↓
WordPress
49. Step 11 — Database
WordPress may request:
MySQL
The database responds.
Then:
PHP
↓
Nginx
↓
TLS
↓
Browser
50. The Full Journey
Browser
│
▼
DNS
│
▼
Public IP
│
▼
Internet routers
│
▼
OCI Internet connectivity
│
▼
VCN
│
▼
Subnet
│
▼
VNIC
│
▼
Linux interface
│
▼
TCP 443
│
▼
Nginx
│
▼
TLS
│
▼
HTTP
│
▼
PHP-FPM
│
▼
WordPress
│
▼
MySQL
51. How to Troubleshoot Each Layer
This is where your learning becomes practical.
DNS
dig +short learn.cresignsys.com
Interface
ip addr
Route
ip route
Port
sudo ss -ltnp | grep ':443'
Nginx
sudo systemctl status nginx
Firewall
sudo ufw status
HTTP
curl -I https://learn.cresignsys.com
52. ip route get
One especially useful command is:
ip route get 8.8.8.8
Linux tells you which route it would use to reach that destination.
For example:
8.8.8.8 via 10.0.0.1 dev ens3
Conceptually:
8.8.8.8
↓
gateway 10.0.0.1
↓
interface ens3
53. ip neigh
You can inspect neighbor information:
ip neigh
This is useful when investigating local network connectivity.
54. ss
Use:
sudo ss -lntup
You can inspect:
TCP listeners
UDP listeners
ports
processes
55. TCP vs UDP
You should now distinguish:
TCP
connection-oriented
reliable
ordered
UDP
connectionless
no built-in delivery guarantee
low protocol overhead
56. Why Websites Use TCP
Traditional HTTP/1.1 and HTTP/2 over TLS commonly use:
TCP
HTTP/3 instead uses:
QUIC
↓
UDP
This is a more advanced topic.
For your current Nginx/WordPress stack, TCP is the primary concept to understand first.
57. Port 443 Doesn’t Mean HTTPS Automatically
This is important.
A port is just a number.
You can configure:
some application
↓
TCP 443
But that doesn’t automatically make it HTTPS.
HTTPS requires:
TLS
+
HTTP
58. Port 80 Doesn’t Force HTTP Either
Likewise:
port 80
is conventional for HTTP, but software can listen there using other protocols.
The port number is a convention.
59. IP + Port
Think of:
IP
as identifying the machine/network endpoint.
And:
Port
as identifying a service endpoint on that host.
Together:
203.0.113.25:443
identify a TCP endpoint.
60. Socket Connection
A TCP connection is identified by endpoints.
Conceptually:
Client IP:client-port
↕
Server IP:443
For example:
192.168.1.20:51832
↕
203.0.113.25:443
The client-side port is usually dynamically selected.
61. Ephemeral Ports
Client applications usually use temporary:
Ephemeral ports
For example:
51832
Then:
client
192.168.1.20:51832
connects to:
server
203.0.113.25:443
62. Why the Server Can Handle Many Users
The server isn’t limited to one connection on port 443.
A single listening port can have many simultaneous TCP connections.
Conceptually:
Nginx :443
│
┌──────────┼──────────┐
▼ ▼ ▼
Client A Client B Client C
:50001 :50002 :50003
Each connection has a distinct client endpoint.
63. This Connects to RAM
Now combine networking with your previous lesson.
More simultaneous requests can mean:
more TCP connections
↓
more Nginx work
↓
more PHP requests
↓
more PHP workers
↓
more RAM
Therefore:
NETWORK
↓
APPLICATION
↓
CPU/RAM
are connected.
64. Traffic → PHP → MySQL
A busy website can generate:
1000 requests
↓
Nginx
↓
PHP
↓
MySQL
If caching is poor:
database workload increases
Then:
CPU
RAM
storage I/O
can all increase.
65. Why Caching Is So Important
With page cache:
Request
↓
Nginx/cache
↓
HTML
Without it:
Request
↓
Nginx
↓
PHP
↓
WordPress
↓
MySQL
Caching can therefore reduce work throughout the stack.
66. Your Hosting Architecture Is Becoming Clear
You can now see:
INTERNET
│
▼
DNS
│
▼
PUBLIC IP
│
▼
OCI VCN
│
▼
SUBNET
│
▼
VNIC
│
▼
UBUNTU
│
┌──────┴──────┐
▼ ▼
NETWORK STORAGE
│ │
▼ ▼
NGINX /storage
│ │
▼ ▼
PHP-FPM WordPress
│
▼
MySQL
And security surrounds it:
Cloud security
+
Linux firewall
+
Users
+
Groups
+
Permissions
67. Lesson 056 — Core Principle
The most important idea:
Routing determines where traffic goes; ports determine which service receives it.
For your WordPress server:
learn.cresignsys.com
↓
DNS
↓
Public IP
↓
OCI routing
↓
VNIC
↓
TCP 443
↓
Nginx
↓
PHP-FPM
↓
WordPress
If you understand that chain, you can troubleshoot most basic hosting connectivity problems systematically.
Next Lesson — 057
DNS Deep Dive — How learn.cresignsys.com Finds Your VPS
We will go deeper into:
Domain
↓
DNS hierarchy
↓
Root DNS
↓
TLD
↓
Authoritative nameserver
↓
A record
↓
AAAA record
↓
CNAME
↓
TTL
↓
DNS cache
↓
Recursive resolver
↓
Your VPS
Then we will connect it directly to your CresignSys domains and explain why:
domain works
domain doesn't work
www works
root domain doesn't work
IPv4 works
IPv6 doesn't work
can all happen even when the WordPress installation itself is perfectly correct.
Leave a Reply