VNC instructions (Pi remote desktop)

The Raspberry Pi Foundation's professional development course for teachers

6 posts
by Davespice » Wed Apr 16, 2014 3:06 pm

Hi folks;
Allen was just asking me about the VNC demo I gave at Picademy and I thought I would just do a follow up post here for everyone.

  • Step 1: Setup and install
    So the aim will be to install the VNC server software on Pi and the VNC viewer software on the host computer (which will show the Pi desktop).
    Read and follow the guide here: ... access/vnc
    The guide includes instructions to make the VNC server start automatically when the Pi boots up (recommended).
  • Step 2: If necessary, configure the Pi to give out an IP address
    This is the method you'll want to use if you have untrusting network administrators who refuse to allow a Raspberry Pi to be connected to the main school network.
    I know this looks like loads to do but I've just put a lot of detail so you can't go wrong :)

    This way each Raspberry Pi will be directly connecting to a host computer using a single Ethernet cable, thus making a completely isolated point to point network between the two and therefore your network administrators shouldn't have any cause to complain. Note: you don't need a cross over cable for this, a standard cable will work because the Pi Ethernet port auto-switches the transmit and receive pins.

    Firstly we'll need to install some software on the Pi, so for this first part you'll need to connect it to a LAN for Internet access. We’re going to make the Pi Ethernet port behave in a similar way to a home router. This means assigning a static IP address to it and installing a DHCP service (dnsmasq) that will respond to address requests from the host computer.

    From the command line or LXTerminal enter these commands:

    Code: Select all
    sudo apt-get update
    sudo apt-get install dnsmasq

    It’s a good idea to use an IP address range that is very different to your main network, so let’s use 10.0.0.X. To configure this we must edit the network interfaces file, enter the following command;
    Code: Select all
    sudo nano /etc/network/interfaces

    Find the following line;
    Code: Select all
    iface eth0 inet dhcp

    Add a hash symbol at the start of the line to disable it and then add the other four lines shown below.
    Code: Select all
    # iface eth0 inet dhcp
    auto eth0
    iface eth0 inet static

    Press Ctrl – X, y and enter to save and quit out of nano. The Raspberry Pi will now have a static address of

    Next we need to configure dnsmasq (that we installed earlier) to give out IP addresses. I am going to explicitly specify a configuration file for the dnsmasq service so let’s first make a backup of the default config file and then save my one in its place.
    Code: Select all
    cd /etc
    sudo mv dnsmasq.conf dnsmasq.default
    sudo nano dnsmasq.conf

    You should now be editing a blank file. Copy and paste the following into it.
    Code: Select all

    The first line tells dnsmasq to listen for DHCP requests on the Ethernet port of the Pi. The second line is specifying the range of IP addresses that can be given out. The third line provides the default gateway for the host computer (which won't actually be used here).

    Next disconnect the Pi from the LAN and reboot.
    Code: Select all
    sudo reboot

    After the Pi boots back up, give it a minute or so, and you can go ahead and plug in the single Ethernet cable directly from the Pi to the host computer.
    The host computer should then be given an IP address which will be 10.0.0.X where X is a random number between 2 and 250.

    One thing to try is to open up a command prompt on the host computer (a Terminal on OSX and Linux) and enter the following command;
    Code: Select all

    If you see reply, reply, reply then it's working. If you see request timed out then something is wrong and you'll need to go back and double check everything.
    You can now open up your VNC viewer on the host PC and connect it to the Pi. When prompted for the remote host enter: and click connect. It could also be depending on how you set it up in step 1.

    You'll be prompted for the password that you chose during step 1 and after that you'll see the Pi desktop and will be able to get going with Scratch or whatever. Remember that 3D games like Minecraft are not going to work using this method, those draw their image directly to the local screen memory and will be ignored by VNC. You'll just see an empty window.

I hope this helps, please point out any errors if you spot them. One thing to note is that this setup will not have internet access, since you're supposed to be on an isolated point to point network to keep the network administrators happy. If you want to reverse this setup and make the Pi go back to normal (so you can get online) you'll need to do three things:

  • Undo the change to /etc/network/interfaces (put hashes on the four lines you added and remove the hash from the original line).
  • Run sudo apt-get remove dnsmasq from the command line.
  • sudo reboot
User avatar
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 1441
Joined: Fri Oct 14, 2011 8:06 pm
Location: London, United Kingdom
by allenheard » Wed Apr 16, 2014 3:42 pm
Excellent, thanks for that! :)
User avatar
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 4
Joined: Tue Apr 15, 2014 1:45 pm
by Theladdie » Wed Apr 16, 2014 4:06 pm
Ha perfect I was just about to google this but you beat me too it
User avatar
Posts: 23
Joined: Mon May 14, 2012 11:38 am
Location: Berlin, Germany
by mrmandrill » Wed Apr 16, 2014 6:34 pm
Davespice, that's great. Using similar technique in school myself, we've switched on the Internet connection sharing option in windows PCs and left the Pi on dynamic IP. The Pi belong to our pupils so they go home each evening and static IP wouldn't always work on their home network.

We then use a combination of Avahi on the Pi to broadcast it's IP and Bonjour on the PC, this means the Pi can be addressed by name and consistently accessed with ease.
User avatar
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 25
Joined: Fri Jul 20, 2012 9:12 am
Location: Cambridge
by mrwalkerworld » Wed Jun 18, 2014 1:40 pm
Posts: 1
Joined: Wed Jun 18, 2014 12:55 pm
Location: Bury, UK
by MrsKSayers » Mon Jun 30, 2014 8:02 pm
Exactly what I needed thank you
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 12
Joined: Wed Jun 11, 2014 11:53 am
Location: Derby