
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: https://github.com/raspberrypi/document ... 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:
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 apt-get update sudo apt-get install dnsmasq
Find the following line;Code: Select all
sudo nano /etc/network/interfaces
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
Press Ctrl – X, y and enter to save and quit out of nano. The Raspberry Pi will now have a static address of 10.0.0.1Code: Select all
# iface eth0 inet dhcp auto eth0 iface eth0 inet static address 10.0.0.1 netmask 255.255.255.0
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.You should now be editing a blank file. Copy and paste the following into it.Code: Select all
cd /etc sudo mv dnsmasq.conf dnsmasq.default sudo nano dnsmasq.conf
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).Code: Select all
interface=eth0 dhcp-range=10.0.0.2,10.0.0.250,255.255.255.0,12h dhcp-option=3,10.0.0.1
Next disconnect the Pi from the LAN and 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.Code: Select all
sudo reboot
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;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.Code: Select all
ping 10.0.0.1
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: 10.0.0.1:1 and click connect. It could also be 10.0.0.1:0 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.
- 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