Fix Server Connectivity on Debian 12 with Routing Tests

What this Debian 12 connectivity check solves
When a fresh VPS drops SSH, rejects a service port, or reaches the internet but not a private network, the problem is usually not “the network” in general. It usually comes down to one of four things: the host address, the route table, the firewall, or a service that is not listening where it should.
This tutorial shows you how to fix server connectivity on Debian 12 with command-based checks, careful firewall changes, and a rollback path you can use on a live VPS.
The workflow fits Hostperl VPS customers who need a clean launch, a migration check, or a post-change recovery runbook. If you are planning a wider rollout, keep Hostperl VPS in mind for workloads that need stable routing, predictable bandwidth, and fast support.
We will stay on Debian 12, use systemd-managed services, and keep every step copy-pasteable. You will verify connectivity from the server itself, from a second SSH session, and from a client machine.
First login, OS detection, and a safe admin user
On your local computer:
ssh root@203.0.113.10203.0.113.10 is a documentation example. Replace it with the public IP assigned to your server. If your Hostperl plan uses a default non-root login, connect with that account first and keep the original root session open until the new user works.
On the VPS as root:
cat /etc/os-releaseThis confirms you are on Debian 12 before you use Debian-specific commands. You should see ID=debian and a Debian 12 release line.
Create a non-root sudo user named deploy, then give it a locked password so SSH keys are the only login method for now:
adduser deploy --disabled-password --gecos ""
usermod -aG sudo deploy
install -d -m 700 -o deploy -g deploy /home/deploy/.sshNow copy your public key into place. Replace the key text with your real public key from your local computer.
cat > /home/deploy/.ssh/authorized_keys <<'EOF'
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMockKeyExampleReplaceThisWithYourRealKey user@local
EOF
chown deploy:deploy /home/deploy/.ssh/authorized_keys
chmod 600 /home/deploy/.ssh/authorized_keysKeep the root session open. Open a second terminal on your local computer and test the new account before changing any SSH policy.
On your local computer:
ssh deploy@203.0.113.10After you connect, confirm sudo works:
On the VPS as the non-root sudo user:
sudo -v
whoami
idYou should see deploy as the user and the sudo group in the id output. If this fails, stop here and fix the key or group membership before continuing.
Check the network stack before changing anything
Most server connectivity issues become obvious when you inspect addresses, routes, and sockets together. Start with the current state.
On the VPS as the non-root sudo user:
ip addr show
ip route show
ss -tulpnip addr show confirms the server has an IPv4 and, if enabled, IPv6 address. ip route show shows the default gateway and any static routes. ss -tulpn lists listening ports so you can confirm whether SSH, Nginx, or another service is actually bound to the address you expect.
If you want a quick gateway test, run:
ping -c 3 203.0.113.1
ping -c 3 1.1.1.1Do not change these commands while testing the logic; they are safe examples. If the gateway ping fails but 1.1.1.1 works, your route or local network attachment is the issue. If both fail, the problem is likely host-level or provider-side.
Repair DNS and name resolution if lookups fail
Some “network” incidents are really resolver problems. If package installs hang or hostnames do not resolve, check the resolver file and verify a known lookup.
On the VPS as the non-root sudo user:
cat /etc/resolv.conf
getent hosts deb.debian.org
getent hosts example.comSuccessful output should show at least one nameserver in /etc/resolv.conf and IP addresses for the two lookups. If lookups fail, restart the systemd resolver stack if you use it, or correct the DNS server settings supplied by your provider.
Open the right ports with nftables and keep SSH safe
On Debian 12, nftables is the cleanest base firewall for a small server. The safe rule is simple: allow the new port first, test it, and only then remove anything old. Do not close your current SSH path until the new one works.
First, inspect the current ruleset.
On the VPS as root:
nft list rulesetIf no ruleset exists yet, create one that allows SSH, HTTP, and HTTPS. This example keeps TCP port 22 open. If you already moved SSH to another port, add that port before removing 22.
cat > /etc/nftables.conf <<'EOF'
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0;
policy drop;
ct state established,related accept
iif "lo" accept
ip protocol icmp accept
ip6 nexthdr icmpv6 accept
tcp dport 22 accept
tcp dport 80 accept
tcp dport 443 accept
}
}
EOF
nft -c -f /etc/nftables.conf
systemctl enable --now nftables
nft -f /etc/nftables.confnft -c -f /etc/nftables.conf checks syntax before the live reload. You should see no errors. If you do, fix the file before loading it. systemctl enable --now nftables makes the ruleset survive reboot.
Confirm the active ruleset after loading:
nft list rulesetIf you manage Ubuntu or use UFW elsewhere in your fleet, use the equivalent firewall workflow from your standard baseline. For Debian 12, keep the rules in nftables so the server state remains explicit and supportable.
Test listener ports and bind addresses
A server can have good routing and still fail connectivity if the service binds only to localhost. Check the listener and the process together.
On the VPS as the non-root sudo user:
ss -ltnp
systemctl status ssh --no-pagerIf SSH is not listening on 0.0.0.0:22 or [::]:22, inspect /etc/ssh/sshd_config before touching the firewall. If your application uses port 8000, confirm that the service is listening on the correct address and not only on 127.0.0.1.
For a quick localhost test on the server, run:
curl -I http://127.0.0.1:8000If this works locally but fails remotely, the issue is almost always firewall policy, NAT, or the service bind address.
Use routing and packet-path diagnostics when traffic still fails
If the server can reach the internet but clients cannot reach it, use path tests to see where packets stop. This is especially useful after provider-side network changes, IP swaps, or migrations.
On the VPS as the non-root sudo user:
tracepath 1.1.1.1
traceroute -n 1.1.1.1tracepath is often available by default and shows MTU issues. If the path breaks at the first hop, check the host route and gateway. If the path works outbound but inbound traffic never arrives, check the provider firewall and any security group in front of the VPS.
For interface counters, use:
ip -s link show
ethtool eth0Replace eth0 with your actual interface name from ip addr show. The counters help you spot dropped packets, link problems, or negotiated speed that does not match the plan.
IPv6 checks for dual-stack servers
If your Hostperl server has IPv6 enabled, test it separately. Dual-stack failures are common when IPv4 works and IPv6 is half-configured.
On the VPS as the non-root sudo user:
ip -6 addr show
ip -6 route show
ping -6 -c 3 2606:4700:4700::1111
curl -6 -I https://example.comIf the IPv6 address exists but the route is missing, the server will not answer inbound IPv6 correctly. If IPv6 works locally but not from a client, make sure your firewall allows ICMPv6 and the service listens on the IPv6 socket as well as IPv4.
WireGuard as a controlled fallback path
When SSH is exposed to the public internet, a WireGuard tunnel gives you a second management path. That matters during migrations, firewall resets, and remote recovery. This does not replace your production firewall; it gives you a private path for admin access.
Install the package and generate keys.
On the VPS as root:
apt update
apt install -y wireguard
umask 077
wg genkey | tee /etc/wireguard/server.key | wg pubkey > /etc/wireguard/server.pub
cat /etc/wireguard/server.pubCopy the public key value somewhere safe. Next, create a minimal tunnel config. Replace the peer public key and the client tunnel address with your own values.
cat > /etc/wireguard/wg0.conf <<'EOF'
[Interface]
Address = 10.44.0.1/24
ListenPort = 51820
PrivateKey = REPLACE_WITH_SERVER_PRIVATE_KEY
PostUp = nft add rule inet filter input udp dport 51820 accept
PostDown = nft delete rule inet filter input udp dport 51820 accept
[Peer]
PublicKey = REPLACE_WITH_CLIENT_PUBLIC_KEY
AllowedIPs = 10.44.0.2/32
EOF
chmod 600 /etc/wireguard/wg0.confEdit the file and replace both placeholders with real keys before starting the interface. Then enable IP forwarding if you need routed access through the tunnel.
sysctl -w net.ipv4.ip_forward=1
printf 'net.ipv4.ip_forward=1\n' > /etc/sysctl.d/99-ip-forward.conf
systemctl enable --now wg-quick@wg0
systemctl status wg-quick@wg0 --no-pagerUse WireGuard as a recovery path, not as a reason to leave SSH hardening unfinished. Once you verify the tunnel works, you can restrict public admin access further if your workflow requires it.
Safe SSH hardening after you confirm access
Only after the new login works should you tighten SSH. Keep a root session open while you test each change. The goal is to reduce risk without locking yourself out.
Edit the SSH daemon config:
On the VPS as root:
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
nano /etc/ssh/sshd_configSet or confirm these lines inside the file:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AllowUsers deploySave and exit nano with Ctrl+O, Enter, then Ctrl+X. Before you reload, test syntax.
sshd -t
systemctl reload sshIf sshd -t returns nothing, syntax is valid. Now open a fresh terminal and confirm you can still log in as deploy.
On your local computer:
ssh deploy@203.0.113.10If this fails, revert immediately with the backup config:
cp /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
sshd -t
systemctl reload sshFinal verification from the server and a client
Use these checks to prove the server is reachable, services are listening, and the changes survive a reboot.
On the VPS as the non-root sudo user:
systemctl status nftables --no-pager
systemctl status ssh --no-pager
ss -tulpn
ip route show
nft list rulesetYou should see active services, the correct routes, and the firewall rules you loaded.
On your local computer:
ssh deploy@203.0.113.10
curl -I http://203.0.113.10If you are testing HTTPS behind a reverse proxy, replace the second command with your live HTTPS URL. A valid response should return headers, not a timeout.
For reboot persistence, restart the VPS during a maintenance window:
On the VPS as root:
rebootAfter the server comes back, confirm access again from your local computer and repeat the service checks. If SSH comes up and the firewall still permits your approved ports, the recovery is complete.
Troubleshooting the most likely failures
SSH works on the console but not from your laptop. Check whether the firewall still allows port 22 and whether the server has the correct public IP. Run:
nft list ruleset
ip addr show
ss -tulpn | grep ':22'If port 22 is missing from the ruleset, add it back and reload /etc/nftables.conf.
The server reaches the internet but cannot resolve names. Run:
cat /etc/resolv.conf
getent hosts deb.debian.orgIf the lookup fails, fix the nameserver configuration supplied by your provider or local resolver service.
An app port responds locally but not remotely. Check the bind address and firewall:
ss -ltnp | grep ':8000'
nft list rulesetIf the app listens only on 127.0.0.1, change the service to bind on 0.0.0.0 or the server’s public address, then restart it.
IPv6 fails while IPv4 works. Check the v6 route and firewall allowance:
ip -6 route show
ip6tables -SOn nftables systems, make sure ICMPv6 is allowed and the service binds on [::] as well as IPv4.
If you want a VPS that stays predictable during migrations, firewall changes, and dual-stack testing, Hostperl VPS gives you a solid base for production networking work. For customers who need more control over routing, bandwidth, or regional placement, Hostperl VPS is a practical fit.
When your workload needs stronger isolation or higher throughput, compare it with dedicated server hosting for the next step.
Related Hostperl guides
- Linux package upgrades that keep servers stable in 2026
- Systemd service troubleshooting on Linux servers
- SSH lockout recovery plan for server security teams
- DNS TTL changes for safer domain migrations in 2026
FAQ
Why does SSH work locally but not remotely?
Usually because the firewall does not allow port 22, or the service is bound only to localhost. Check nft list ruleset and ss -ltnp.
Should I disable root login immediately?
No. Verify the new sudo user in a second terminal first. Then change SSH policy and keep a backup config ready for rollback.
What if I need IPv6 too?
Test it separately with ping -6, ip -6 route show, and curl -6. IPv4 working does not prove IPv6 is healthy.
Is WireGuard required?
No, but it gives you a safer fallback path for admin access during recovery or maintenance.
What is the fastest way to confirm the server is healthy after reboot?
Check systemctl status ssh, systemctl status nftables, ip route show, and SSH in again from your local computer.
