The problem: There's a service on server with changing IP address, but constant host name (Dyndns or similar). But the client device that wants to use the service can access it only by IP, not host name. How to solve the problem?

The easy part is that device is in the local network with Windows server (constant IP) and Mikrotik router (also constant IP). So I am thinking about two possible solutions: Mikrotik magic port forwarding to external host (is there anything like this?) or a small application on a Windows machine that forwards a port to a known host (does it exist?). Please advise.

  • What device is this that it can't use a hostname? – Dessa Simpson Mar 27 '18 at 1:46
  • Also why can't the server have a constant IP? This reeks of XY. – Dessa Simpson Mar 27 '18 at 1:47
  • Implement a manual dns. If the app can connect to ip, then it can connect to dns by ip, and get by name. Port forwarding apps do exist on windows. – Robert Andrzejuk Mar 28 '18 at 16:30
  • @DuncanXSimpson it's Logitech Squeezebox player. See here: tomstek.us/…. The server can't have static IP because it's my home and for static IP i would have to pay additionally – tutejszy Mar 29 '18 at 9:28
  • Oh I completely misunderstood the network topology. – Dessa Simpson Mar 29 '18 at 15:11

After few evenings of digging it appears easier than i thought: good'ol socat on windows machine is the answer. So the windows machine becomes port forwarder (and its IP can be used in the device):

socat tcp-l:local-port,fork,reuseaddr tcp:remote-host:remote-port

for example:

socat tcp-l:80,fork,reuseaddr tcp:google.com:80

Socat in tcp-listen mode establishes connection on demand, apparently every time resolving host name into address (checked modifying hosts file). The fork and reuseaddr options to tcp-listen are not hardcore needed, make the command more smooth-working in case of problems.

Socat for windows is here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.