Custom DNS Record Includes Port Number: A Solution for IoT Server Multiples Services

Abstract: Resolve IoT service access by using a reverse proxy to map distinct subdomains to internal ports instead of embedding port numbers in DNS records.

Created: 2026-10-22 by
You cannot embed port numbers directly inside standard DNS A or AAAA records because the Domain Name System is designed solely for name-to-address resolution. To access multiple services on your IoT server using memorable hostnames without typing ports, you must use a reverse proxy like Nginx or Apache to map specific subdomains to different internal ports. The core limitation lies in how DNS functions. When you query a domain like myserver.local, the DNS server returns an IP address, such as 192.168.1.50. The client (your browser or application) then attempts to connect to that IP on a default port, typically 80 for HTTP or 443 for HTTPS. There is no mechanism in the DNS protocol itself to say "connect to port 8080." If you try to force this by appending a port to the hostname, like myserver.local:8080, the DNS resolver will fail because colons are not valid characters in standard domain names for resolution purposes. This architectural separation means that while DNS handles the "where" (the location), the application layer handles the "which service" (the port). For OpenWRT users managing IoT devices, relying on IP addresses and manual port entry is error-prone and insecure. Instead, you should configure a reverse proxy on your router or server. This setup allows you to define distinct hostnames for each service. For example, you can assign camera.mylocal.net to port 8080, nas.mylocal.net to port 5000, and router.mylocal.net to port 80. The reverse proxy listens on standard web ports and inspects the Host header of incoming requests to route traffic to the correct internal backend service. This approach simplifies user experience significantly, as users only need to remember simple names rather than complex port combinations. To implement this solution effectively, you need to ensure your local DNS environment resolves these custom hostnames to your server's IP address. This often involves configuring your DHCP server or editing the local hosts file on clients. Once the names resolve correctly, the reverse proxy takes over the heavy lifting of connection management. You can use lightweight software like Nginx, which is available via Opkg on many OpenWRT installations, or Apache if you prefer traditional configuration methods. Both tools support virtual hosting based on domain names, making them ideal for this scenario. It is also important to consider security implications when exposing multiple services through a single entry point. While a reverse proxy abstracts the ports from the user, it does not automatically encrypt traffic unless you configure SSL/TLS certificates. For local networks, self-signed certificates may suffice, but for remote access, proper certificate management becomes critical. Additionally, ensuring that your firewall rules allow traffic to the proxy ports while blocking direct access to the backend services adds a layer of defense. This strategy aligns with best practices discussed in broader network troubleshooting guides, such as those found in our Name Server Troubleshooting guide, which emphasizes the importance of clear DNS resolution before applying application-layer fixes. Another common pitfall is neglecting to update the DNS entries when the server's IP address changes. In dynamic environments, static DNS records might become stale. Using a local DNS forwarder like dnsmasq, which is built into OpenWRT, allows you to create persistent static mappings that survive reboots. This ensures that printer.local always points to the correct MAC address or IP, regardless of lease renewals. By combining stable DNS resolutions with a robust reverse proxy configuration, you create a reliable infrastructure for managing diverse IoT services. This method scales well, allowing you to add new services simply by adding a new server block in your proxy configuration and a corresponding DNS entry, without needing to expose new ports to the external network or confuse users with non-standard URLs.

Configuring Local DNS Resolution

Before setting up the proxy, your network must know how to translate your custom hostnames into IP addresses. On OpenWRT, this is typically handled by dnsmasq. You can add static leases or custom DNS entries in the /etc/dnsmasq.conf file or through the LuCI interface under Network > DHCP/DNS. Ensure that every hostname you plan to use has a corresponding entry pointing to your server's local IP. Without this step, browsers will fail to connect even if the proxy is running perfectly.

Setting Up the Reverse Proxy

Install Nginx using the command opkg install nginx. Create a new server block configuration file in /etc/nginx/conf.d/. Inside this file, define a server block that listens on port 80. Use the server_name directive to specify your custom hostname, such as camera.local. Then, use the location / block with the proxy_pass directive to forward traffic to http://127.0.0.1:8080. Repeat this process for each service, changing the server_name and proxy_pass target port accordingly. This structure allows one listening port to serve multiple distinct applications.

Testing and Verification

After saving your configurations, restart both the DNS and Nginx services. Test connectivity by accessing your custom hostname from a device on the same network. If the page loads, the proxy is working. If it fails, check the Nginx error logs located at /var/log/nginx/error.log for clues. Common issues include incorrect file permissions, typos in the proxy_pass URL, or firewall rules blocking the connection. Resolving these errors ensures smooth operation.

Security Considerations

While local access is generally safer, exposing these services requires caution. Avoid forwarding all proxied services directly to the internet. Instead, use a VPN or restrict access to trusted IPs. Regularly update your Nginx package to patch security vulnerabilities. Monitoring logs helps detect unauthorized access attempts early, maintaining the integrity of your IoT ecosystem.

Frequently Asked Questions

Can I use SRV records instead of a reverse proxy?

SRV records allow clients to discover the port number for a service, but most modern web browsers do not support automatic redirection via SRV records. They require explicit user input or plugin support, making them impractical for general web service access compared to the seamless experience provided by a reverse proxy.

Does this solution work for non-web protocols like MQTT?

Standard HTTP reverse proxies cannot handle raw TCP streams used by protocols like MQTT directly. You would need a specialized proxy like HAProxy or Mosquitto's bridge capabilities to route non-HTTP traffic based on hostnames, which adds complexity compared to the straightforward HTTP mapping shown here.

What happens if my IoT server changes its IP address?

If your server obtains a new IP via DHCP, your static DNS entries will become invalid until updated. To mitigate this, configure a static DHCP reservation in your router settings to ensure the server always receives the same IP, keeping your DNS records accurate and preventing connection failures.

Is it safe to run a reverse proxy on an OpenWRT router?

Running a reverse proxy on OpenWRT is safe and efficient due to the low resource footprint of Nginx. However, ensure your router has sufficient RAM and CPU headroom, especially if handling many concurrent connections, to avoid impacting other routing tasks like packet filtering and NAT.

How do I handle SSL certificates for multiple subdomains?

You can use Let's Encrypt with Certbot or acme.sh to obtain a wildcard certificate for your local domain. Configure Nginx to reference this single certificate for all subdomain server blocks, simplifying management and avoiding the overhead of generating separate certificates for each individual service.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More