2014年9月6日 星期六

Control Raspberry Pi via VNC and setup virtual server on router/AP

The setup concept is like following diagram

VNC client<-->Internet<-->router<-->Raspberry Pi
  1. Setup VNC server
    • sudo apt-get install tightvncserver
    • vncserver -geometry 1024x768 -depth 24 and set password, this password is only used for VNC login
    • You will require a password to access your desktops.

      Password: 
      Warning: password truncated to the length of 8.
      Verify:   
      Would you like to enter a view-only password (y/n)? n

      New 'X' desktop is raspberrypi:1

      Creating default startup script /home/pi/.vnc/xstartup
      Starting applications specified in /home/pi/.vnc/xstartup
      Log file is /home/pi/.vnc/raspberrypi:1.log
    • :1 is desktop number which stands for VNC port is 5901
  2. Setup virtual server on router/AP
    • Enter virtual server settings in router
    • Name: RPi
    • IP address: loca network address of RPi, 192.168.x.y for example
    • Public port: choose a valid port number, 8899 for example
    • Private port: 5901
    • Protocol: choose both TCP and UDP
  3. Connect to Raspberry Pi
    • Check your worldwide IP address on Internet, w.x.y.z
    • Open VNC client and enter address like w.x.y.z:8899
    • Connect and it should work