TLDR: How do I forward traffic from one hostname on my LAN to another?
I have multiple servers set up on an old computer. When I'm setting a device on my LAN to access them, I enter oldcomputer.mydomain.com:port with the port number of the server I want.
But In the future I'm planning to move them to different hardware. I'd like to set my various devices in a way that won't have to be changed in the future. I'd like them to be pointed to serverone.mydomain.com:port, servertwo.mydomain.com:port, etc. with the router knowing that the hostnames serverone, servertwo, etc are alias for oldcomputer or newserver or raspberrypi or whatever and forwarding all the traffic. That way if I move a server in the future, I just change the setting on the router and don't have to change every device.
I'm guessing it's a simple thing to do in OpenWRT; I just don't know how. Any help would be appreciated.
Is there a way to set/edit cnames in the GUI or do I need to enter the uci commands through SSH? Also, what about when I want to change them later? Is there a UCI command for that or should I just edit /etc/config/dhcp ?
Yeah, that's basically what I've done based on trendy's suggestion above. In my case I didn't use static leases because it seems to work fine without them, but I'd be curious to hear if you found you needed them or just wanted the extra stability?
Also, I've mainly been using this for accessing web GUIs on the servers, but was wondering what you've found regarding whether this works with other protocols (SSH, Samba, FTP, etc.) as well?
Very true, but the CNAME is forwarding from hostname to hostname, so it doesn't seem to matter what the machine's IP address is. The dynamic IP doesn't seem to have any effect on what hostname is assigned, as I'm assuming OpenWRT assigns whatever hostname the machine reports.
Don't get me wrong, I agree that setting a static IP is a simple step that's helpful in adding stability. I was just inquiring (mainly for reference) whether or not it's absolutely necessary. Hasn't seemed so in my case, but I've only been using it for a few days.
No, I do not think it is technically necessary to use static leases: the alias will point to the real name, and this to the current address.
Some device might cache the address, instead of resolving the name each time, and use wrong information for some time. And I think it is a best practice to use static leases for machines that must receive connections.