⚡ Ubuntu Remote Access · No Static IP
Only hostname.local — no router config, no IP chasing.
hostname.local — static IP, DHCP reservations, router config → NOT REQUIRED. Works with dynamic IP, survives reboots.
🏗️ Architecture
✅ What will be used
- normal DHCP (automatic)
- hostname (machine identity)
- mDNS / Avahi (Zero-configuration)
hostname.localresolution
🚫 What will NOT be used
- static IP configuration
- DHCP reservation (router)
- any router port forwarding / config
- remembering IP addresses
📋 Complete Setup Steps
All steps performed on your Ubuntu server (22.04 / 24.04+). Replace server-hp with your desired hostname.
Remove any static IP leftovers. Identify your active connection and reset to DHCP.
# Show available connections & find active WiFi/Ethernet name (e.g., "MyWifi" or "MyLab")
nmcli connection show
# Modify your connection to use DHCP (auto)
nmcli connection modify "MyWifi" ipv4.method auto
# Clear any static addresses, gateway, DNS
nmcli connection modify "MyWifi" ipv4.addresses ""
nmcli connection modify "MyWifi" ipv4.gateway ""
nmcli connection modify "MyWifi" ipv4.dns ""
# Restart NetworkManager and reconnect
sudo systemctl restart NetworkManager
nmcli connection down "MyWifi" && nmcli connection up "MyWifi"
nmcli connection show and replace MyWifi accordingly.Delete the old WiFi profile completely and reconnect via GUI (clean DHCP).
nmcli connection delete "MyWifi"
sudo systemctl restart NetworkManager
# Now reconnect via Ubuntu GUI: click WiFi → select network → enter password
# DO NOT set static IP anywhere.
ip addr # Look for "inet 192.168.x.x" or 10.x.x.x
ip route # Should show default via gateway (e.g., 192.168.1.1)
ping google.com -c 4
# Check current
hostname
# Set new hostname
sudo hostnamectl set-hostname server-hp
# Verify
hostnamectl
sudo nano /etc/hosts
# Find line: 127.0.1.1 old-hostname
# Replace with: 127.0.1.1 server-hp
# Example /etc/hosts entry:
127.0.0.1 localhost
127.0.1.1 server-hp
sudo apt update
sudo apt install avahi-daemon -y
sudo systemctl enable avahi-daemon
sudo systemctl start avahi-daemon
systemctl status avahi-daemon # must show active (running)
server-hp.local on the local network. No router changes needed.ping server-hp.local -c 3
# Should resolve to your current DHCP IP (e.g., 192.168.1.112)
sudo systemctl restart avahi-daemon and ensure hostname is correctly set.From any laptop/computer on the same local network, reach your Ubuntu server using server-hp.local (replace with your actual hostname).
ssh username@server-hp.local💡 Ensure openssh-server installed:
sudo apt install openssh-server -y
Add to your SSH config (
~/.ssh/config on client):Host myserver HostName server-hp.local User your_usernameThen connect: Remote-SSH: Connect to Host → myserver
Access web apps:
http://server-hp.local:8080 (or any port like 3000, 5000). Works with Jupyter, Flask, Node, etc.
RDP: Install xrdp on server (
sudo apt install xrdp -y). Connect using Remmina or Windows Remote Desktop → server-hp.local.VNC: Install TigerVNC server, then VNC Viewer →
server-hp.local:5901.🧠 No IP tracking – just use the .local address.
Windows does not natively support mDNS. Install Bonjour Print Services (Apple) or iTunes (includes Bonjour).
👉 Download: Bonjour Print Services for Windows (official Apple)
After install, open cmd and test: ping server-hp.local
sudo ufw allow 5353/udp comment 'mDNS Avahi'
sudo ufw reload
Also open services ports if needed (SSH:22, RDP:3389, VNC:5900+, etc).
🎉 FINAL RESULT
✅ Server stays on DHCP · No static IP · No router configuration
IP can change daily/hourly · Remote access remains flawless using
server-hp.local
ssh user@server-hp.local
🖥️ RDP → server-hp.local:3389
🌍 Browser → http://server-hp.local:PORT
🧪 Verification & advanced notes
🔍 Verify mDNS from another Linux/macOS device
ping server-hp.local
avahi-resolve -n server-hp.local # if avahi tools installed
📌 Hostname convention:
Use lowercase, no underscores. Example: server-nuc, ubuntu-workstation. Access via server-nuc.local.
🔥 What if .local stops working after network changes?
Restart avahi: sudo systemctl restart avahi-daemon. Also ensure no firewall blocks UDP 5353 multicast.
🔄 Reboot resistance
After completing steps 1-6, everything persists. No matter how many times your router renews IP, .local name resolution works across the LAN.
📎 Quick command recap (server side)
# Set hostname & Avahi (core)
sudo hostnamectl set-hostname server-hp
echo "127.0.1.1 server-hp" | sudo tee -a /etc/hosts
sudo apt install avahi-daemon -y
sudo systemctl enable --now avahi-daemon
# Ensure DHCP mode
nmcli connection modify "YourWifi" ipv4.method auto
sudo systemctl restart NetworkManager
Comments