When working with VPS (Virtual Private Servers) or cloud-based servers, you’ll often encounter two types of IP addresses: public and private. While public IPs allow access over the internet, private IPs are used for internal communication within a network. Understanding how to connect to a server using its private IP is essential for developers, sysadmins, and cybersecurity professionals.
A private IP address is an IP that is restricted to an internal network and is not directly accessible from the internet.
Private IPs are commonly used in:
Office networks
Cloud VPCs (Virtual Private Clouds)
Home lab setups
Private IP ranges (as per RFC 1918) include:
10.0.0.0 – 10.255.255.255
172.16.0.0 – 172.31.255.255
192.168.0.0 – 192.168.255.255
Key point: If a server only has a private IP, you cannot access it directly from the internet.
Private IPs are crucial for:
Internal server communication: Servers in the same network can talk to each other without using public bandwidth.
Enhanced security: By avoiding exposure to the public internet, private IPs reduce attack surfaces.
Cost efficiency: Data transfer between private IPs is often free within cloud providers, unlike public IP traffic.
There are multiple ways to connect to a private IP, depending on whether you are inside the network or working remotely.
If your computer is in the same local network or VPC, connecting to a server via private IP is simple:
ssh [email protected]Replace username with your server’s user (often root or ubuntu).
Replace 10.0.5.12 with the server’s private IP.
If you are working from home or outside the cloud network, you cannot directly use the private IP. You need one of the following methods:
Connects your home machine to the server’s internal network.
Once connected, your computer behaves as if it’s inside the same network.
You can then SSH using the private IP:
ssh [email protected]A bastion host is a server with a public IP that acts as a gateway.
Steps:
SSH to the bastion host using its public IP.
From the bastion, SSH to the private IP of the target server.
Example command using SSH agent forwarding:
ssh -J user@bastion-public-ip user@private-ipCreates a secure tunnel from your local machine to the server’s private IP through an intermediate server.
Useful when you don’t want full VPN access.
Even when using a public IP to access a private server:
Use SSH keys instead of passwords.
Restrict access to specific IP addresses in your firewall.
Keep the public IP private and share only with authorized personnel.
Think of it as a “private door to a private room”: the address exists publicly, but only those with the key can enter.
Connecting to a server via its private IP is a core skill for developers, sysadmins, and cloud engineers. Whether you’re working inside the network or remotely via VPN or bastion host, understanding the role of private IPs enhances both security and network efficiency.
Tip for Cyberin Readers: Always combine private IP connections with strong authentication methods and firewall rules to maximize security while maintaining convenience for remote work.