3

I have a headless Windows 7 box I'm trying to access using VNC viewer from my Ubuntu Gnome Raring machine.

Previously, when I was running Linux mint, I could do this no problem... but I can't remember the IP of the windows box. When I try to browse the network in Nautilus, I can see the windows box hostname (e.g. Browse Network > Windows Network > WORKGROUP > hostname), but I can't figure out how to find its IP!

What's the best way?

Thanks.

1 Answers1

10

Assuming the Windows machine is still accessible over the network, you can use a port scanning program to scan for the VNC server it's running. If host name discovery is not working, it's often faster and easier to scan your network for the running server than to troubleshoot it.

This may seem complicated at first, but port scanning soon becomes a very quick and easy way to get otherwise difficult-to-access information about what machines are on your network and what servers they are running.

One excellent network scanner that can be used for this is Nmap. To install Nmap in Ubuntu, open a Terminal window (Ctrl+Alt+T) and run:

sudo apt-get update
sudo apt-get install nmap

Now, suppose for the sake of example-making that:

  • Your local network's IP addresses all start with 192.168.1.. (You can check this by running ifconfig or, if you can access it, by looking in your router's web-based setup.)
  • The Windows box's VNC server is running on port 5900. (This is quite common, but not universal--you can tell it to listen on just about any port.)

You'll have to replace the above values with whatever actually applies to your situation.

Then you can use Nmap to scan your LAN for the Windows box's VNC server by running:

sudo nmap -sS -sV 192.168.1.\* -p5900

(Why does nmap have to be run as root with sudo? This enables it to perform scans using techniques that are faster, more efficient, and even less consuming of network resources. As root, it can perform actions that are really only useful for network-scanning and other similarly interesting applications, and thus not made available for normal applications running as limited users. However, if you don't want to run it as root, you don't have to; it will just be a little slower. In that case, replace -sS with -sT, and remove sudo from the beginning. See man nmap for details.)

This may display a result for all of your computers, but the one you're interested in is the one that says open in the STATE column. For example, it could look like:

Nmap scan report for 192.168.1.105
Host is up (0.00011s latency).
PORT     STATE SERVICE     VERSION
5900/tcp open  vnc         ....

I don't have a VNC server running on my LAN so I'm not sure that's exactly what it will look like (and the ... will certainly be replaced by information about the server software that is running). But that's essentially what it looks like.

The IP address on the line that says Nmap scan report, at the top of the entry that shows port 5900 (or whatever port it's using) as "open," is the IP address of the Windows box.

If you prefer to use a graphical interface, then:

  1. You can install nmap in the Software Center. Install the zenmap package too; that's a graphical interface for nmap.

  2. Then open Zenmap and do your scan from there.

    To run Zenmap as root (see the note above about this, and the -sS vs. -sT flags), press Alt+F2 and run gksudo zenmap.

    If you don't have gksudo (some 13.04 systems do and some do not), you can install it (it is provided by the gksu package), or you can open a Terminal and run sudo -H zenmap or sudo -i zenmap.

    You should not run zenmap with straight sudo though, as you'd run a non-graphical program. That is, avoid sudo zenmap; running any but the most trivial graphical applications that way can cause annoying problems with an application's configuration files.

  3. When you use Zenmap, you don't have to escape *s with a \. That is, where you'd have something like 192.168.1.\* in the Terminal, just use 192.168.1.* in Zenmap.

Screenshot of Zenmap, showing a scan like what you may want to perform, with MAC addresses blurred out for privacy reasons.
Screenshot of Zenmap, showing a scan like what you may want to perform. On my network there are no VNC servers running, so nothing open is shown; just closed and filtered. On your network, you'd be looking for which IP has an open VNC port.

As you can probably see in the screenshot above, running Zenmap still involves composing an Nmap command, and in that way is command-line-like. But the output is shown graphically, and part of your command can be created automatically by using the interface provided.

Eliah Kagan
  • 117,780