VPS Networking Basics: DNS, Ports, and IP Configuration Explained

Published on | Updated

Essential networking knowledge for VPS owners. Covers DNS management, port configuration, IP addresses, reverse DNS, and common networking tasks.

VPS hosting

Running a VPS means managing network configuration. Here's what every VPS owner needs to know about DNS, ports, and IP addresses. The examples use 203.0.113.10, 198.51.100.7 and 2001:db8::10, which are reserved for documentation, and the domain example.com: replace them with your own.

IP Addresses

IPv4 vs IPv6

FeatureIPv4IPv6
Address size32 bits, about 4.3 billion addresses128 bits
Written asFour decimal numbers: 203.0.113.10Eight groups of hexadecimal in lowercase, with one run of zero groups shortened to ::: 2001:db8::10
Free addressesScarce: IANA's free pool ran out on 3 February 2011, and RIPE NCC, the registry for Europe, ran out on 25 November 2019Plenty: one standard /64 subnet alone holds 2^64 addresses
NATCommon: devices with private addresses (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) share one public addressNot needed to save addresses, and the IETF does not recommend it; the NPTv6 prefix translation of RFC 6296 is experimental
DNS recordAAAAA

Your provider decides which of these your VPS gets, so check with the commands below. Having both doesn't mean your software uses both: our IPv4 vs IPv6 guide shows how to check what listens on each address and when to add an AAAA record.

Check Your IPs

# Public IPv4 address, as the internet sees it
curl -4 ifconfig.me

# Public IPv6 address (fails if the VPS has no working IPv6)
curl -6 ifconfig.me

# All addresses on all network interfaces
ip addr show

-4 and -6 make curl use only IPv4 or only IPv6 addresses, and ip addr show lists the IPv4 and IPv6 addresses on every interface.

DNS Management

Record Types

RecordPurposeExample
APoints a name to an IPv4 addressexample.com A 203.0.113.10
AAAAPoints a name to an IPv6 addressexample.com AAAA 2001:db8::10
CNAMEMakes a name an alias of another namewww CNAME example.com
MXMail server for the domain, with a preference (lower wins)example.com MX 10 mail.example.com
TXTText data (SPF, DKIM, verification)v=spf1 mx -all
NSNameservers for the zoneexample.com NS ns1.example.net
SRVHost and port of a service_service._tcp.example.com SRV priority weight port target

A CNAME can't share its name with other records, and the bare domain always carries the zone's NS and SOA records, so point example.com itself with A and AAAA records and use the CNAME for www. For a worked SRV example, see our guide to putting a Minecraft server on your own domain.

Setting Up DNS for Your VPS

  1. Buy a domain from a registrar
  2. At your DNS host, point the domain's A record (and AAAA, if your VPS has IPv6) to your VPS
  3. Check the answers with dig (below)
example.com      A       203.0.113.10
www.example.com  CNAME   example.com

How Long DNS Changes Take

There is no fixed "propagation" time. A new record works as soon as your DNS host publishes it. A resolver that already looked the name up keeps its cached answer until the record's TTL (time to live, in seconds) runs out, so a changed record can take as long as its old TTL to reach everyone. If someone looked the name up before the record existed, resolvers can also cache that "no such name" answer, for as long as the zone's SOA record allows. Before a planned move, lower the TTL, wait for the old TTL to pass, and then change the address.

Changing nameservers at your registrar can take longer, because resolvers also cache the delegation from the top-level domain. dig +trace shows each step.

Verify DNS

# A record, short answer
dig example.com A +short

# One type at a time
dig example.com AAAA +short
dig example.com MX +short
dig example.com TXT +short

# Full answer line; the number after the name is the TTL in seconds
dig example.com A +noall +answer

# What two public resolvers have cached
dig @8.8.8.8 example.com A +short
dig @1.1.1.1 example.com A +short

# Follow the delegation from the root servers down
dig example.com +trace

Skip dig example.com ANY: RFC 8482 lets DNS servers answer an ANY query with a single record set instead of everything, so it doesn't show all your records. 8.8.8.8 is Google Public DNS and 1.1.1.1 is Cloudflare's resolver; if they disagree with your DNS host, wait for the TTL to run out.

Port Management

Common Ports

PortServiceProtocol
22SSHTCP
25SMTP (mail transfer)TCP
80HTTPTCP
443HTTPSTCP, plus UDP for HTTP/3
587Mail submissionTCP
3306MySQLTCP
5432PostgreSQLTCP
6379RedisTCP
8080HTTP alternateTCP

Firewall Rules

# See current rules
sudo ufw status verbose

# Before enabling UFW, allow SSH so the firewall doesn't cut your session
sudo ufw allow 22/tcp
sudo ufw enable

# Allow a port
sudo ufw allow 3000/tcp

# Allow one IP address only
sudo ufw allow from 198.51.100.7 to any port 3306 proto tcp

# Deny a port
sudo ufw deny 8080/tcp

# Delete a rule
sudo ufw delete allow 3000/tcp

If you run services in Docker, UFW does not cover the ports you publish with -p: Docker's documentation says traffic to a published container port "gets diverted before it goes through the ufw firewall settings". Publish a database port on the loopback address only, for example -p 127.0.0.1:5432:5432, or don't publish it at all. Keep Docker current as well: the same documentation warns that in releases older than 28.0.0, hosts on the same network segment can reach ports published to localhost.

Only Expose What's Needed

ServiceShould Be Public?Firewall Rule
Web server (80, 443)YesAllow from anywhere
SSHYes (restricted)Allow from your IP or all
DatabaseNoNo rule: listen on localhost only
RedisNoNo rule: listen on localhost only
Admin panelsNoAllow from your IP only

Binding to Localhost

On Debian 12 and Ubuntu 24.04, the packaged MariaDB and Redis (and MySQL 8.0 on Ubuntu) already listen only on the loopback address. Check that nobody changed these lines:

# MariaDB: /etc/mysql/mariadb.conf.d/50-server.cnf
bind-address = 127.0.0.1

# MySQL 8.0 on Ubuntu: /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 127.0.0.1

# Redis: /etc/redis/redis.conf (with the "-", Redis still starts when ::1 is not available)
bind 127.0.0.1 -::1
protected-mode yes

PostgreSQL's listen_addresses defaults to localhost. On Debian and Ubuntu it lives in /etc/postgresql/<version>/<cluster>/postgresql.conf.

Reverse DNS (rDNS)

Reverse DNS maps an IP address back to a name with a PTR record. It matters most for email: Google's sender guidelines tell every sender to make sure their sending domains or IPs "have valid forward and reverse DNS records, also referred to as PTR records". Point the PTR record of your sending IP to a name such as mail.example.com, and give that name an A record that points back to the same IP.

The reverse zone follows the IP address space, not your domain, so you set the PTR record through your VPS provider, in its control panel or through support. Check it with:

dig -x 203.0.113.10 +short

HTTPS with Let's Encrypt

On Debian 12 and Ubuntu 24.04 the web server plugins are separate packages:

# For Nginx
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com

# For Apache
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d example.com -d www.example.com

The certbot package installs a systemd timer, certbot.timer, that runs certbot renew twice a day, and renew only replaces certificates that are near expiry. See the timer with systemctl list-timers and test renewal with sudo certbot renew --dry-run, which uses Let's Encrypt's staging server.

Network Performance

TestCommand
Latency and lossping -c 10 google.com
Route, hop by hopmtr -rwc 10 google.com (package mtr-tiny)
DNS resolution speeddig google.com | grep "Query time"
Throughputiperf3 between two machines you control

Our guide to testing VPS network speed and latency shows how to read these results and run iperf3 in both directions.

Space-Node's VPS plans run in an EU data center with a 1 Gbps port, DDoS protection, and IPv4 and IPv6.

Sources

All opened on 31 October 2026: