Quickie: Remote Desktop IP address
Because VNC is so slow, I often ssh into my work system when I work remotely. But I want to use Remote Desktop for my Windows work as well.
My Windows system has a dynamically-attributed IP address and no fixed name (it’s not “on the domain”). I also have a Remote Desktop session running on my work Mac.
lsof (list open files) not only lists open files by all processes, it also lists open ports. Once you know that the Windows Remote Desktop port is called
ms-wbt-server, all you need to do is:
% lsof | grep ms-wbt-server -> Remote 220 philippec 9u IPv4 0x8977e64 0t0 TCP 22.214.171.124:49161->126.96.36.199:ms-wbt-server (ESTABLISHED)
Voilà! The address of the remote Windows system is
Parsing this through awk to extract the IP address for scripting purposes is left as an exercise to the reader…