thelordmeatball
Posts: 12
Joined: Thu Jun 07, 2012 2:01 pm
Location: USA

VNC from an outside network

Thu Jun 14, 2012 11:28 pm

All,

I ran some searches on the forums and didn't find what I was looking for so hoping someone here can. I have VNC setup and can access the Pi perfectly, while I am on my Mint desktop on my home network. I have the Pi connected via LAN cable to my wireless router, then I just VNC in from from desktop that has a WLAN card installed. Pretty straight forward.

How can I get it so that I can access the Pi via VNC from any other computer. Is it something to do with the external IP? Because when I look into the external IP via a DNS lookup the Pi and my Mint desktop have the same IP.

If someone knows the trick please assist. Thanks!

-M

JeremyF
Posts: 515
Joined: Wed Jan 25, 2012 9:06 pm
Contact: Website

Re: VNC from an outside network

Fri Jun 15, 2012 12:18 am

You have to forward a port (generally 5900, 5901, or 5800) to the Pi on your router's settings page.
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge

thelordmeatball
Posts: 12
Joined: Thu Jun 07, 2012 2:01 pm
Location: USA

Re: VNC from an outside network

Fri Jun 15, 2012 12:34 am

JeremyF wrote:You have to forward a port (generally 5900, 5901, or 5800) to the Pi on your router's settings page.
Any help finding instructions?

JeremyF
Posts: 515
Joined: Wed Jan 25, 2012 9:06 pm
Contact: Website

Re: VNC from an outside network

Fri Jun 15, 2012 12:44 am

These are some good generic instructions:
http://www.youtube.com/watch?v=Kp-R-eHiQco
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge

thelordmeatball
Posts: 12
Joined: Thu Jun 07, 2012 2:01 pm
Location: USA

Re: VNC from an outside network

Fri Jun 15, 2012 12:50 am

Cool, thanks, I'll check it out.

thelordmeatball
Posts: 12
Joined: Thu Jun 07, 2012 2:01 pm
Location: USA

Re: VNC from an outside network

Fri Jun 15, 2012 12:58 am

I am logged into my router, but I need to know what ports need to be enabled...hmmm.

JeremyF
Posts: 515
Joined: Wed Jan 25, 2012 9:06 pm
Contact: Website

Re: VNC from an outside network

Fri Jun 15, 2012 1:28 am

thelordmeatball wrote:I am logged into my router, but I need to know what ports need to be enabled...hmmm.
Try the default 5900 first.
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge

Threlkeld
Posts: 26
Joined: Thu Jun 07, 2012 4:25 pm

Re: VNC from an outside network

Fri Jun 15, 2012 12:33 pm

Is your external IP fixed, or is it allocated dynamically by your ISP? If the latter, it's going to be more complicated to address your router remotely.
If it's fixed and you have sorted out which router port is allocated then AFAIK you can just type the IP address into your remote browser address bar in the form xxx.xxx.xxx.xxx:pp where the :pp denotes the port number and the xxx.xxx.xxx.xxx is the internet IP address

JeremyF
Posts: 515
Joined: Wed Jan 25, 2012 9:06 pm
Contact: Website

Re: VNC from an outside network

Fri Jun 15, 2012 3:17 pm

Threlkeld wrote:Is your external IP fixed, or is it allocated dynamically by your ISP? If the latter, it's going to be more complicated to address your router remotely.
If it's fixed and you have sorted out which router port is allocated then AFAIK you can just type the IP address into your remote browser address bar in the form xxx.xxx.xxx.xxx:pp where the :pp denotes the port number and the xxx.xxx.xxx.xxx is the internet IP address
DynDNS at some point offered an dynamic IP tracker so if you used a hostname, the IP it pointed to would automatically change.
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge

obarthelemy
Posts: 1399
Joined: Tue Aug 09, 2011 10:53 pm

Re: VNC from an outside network

Fri Jun 15, 2012 4:52 pm

Just to make it as beginner-friendly as I can:

In your house, you are on a local LAN, and all your computers have very similar local IP addresses, often 192.168.0.xx, with just xx being different for each PC, and between 0 and 255. These are local addresses only, good for talking to a local PC from another local PC, but they can't be used on the wider Internet.
To get on the Internet, you need a different address, with the same xx.xx.xx.xx format, but different numbers. That address is supplied by your Internet Service Provider, and grabbed by your Internet box, which acts has a bridge and router between your local network and the Internet.
When one of your PC gets on the Internet, your internet box sees the request, passes it on to the Internet, gets the result, and passes it back to the original PC.
When you want to get to your Pi or another home PC from the Internet, the only Internet address you have is that of your box, and upon getting your "foreign" request, your box has no way to know to which PC to forward it to. Hence, you need to set up "port forwarding" in your box/router, so that it knows that Internet stuff coming to port yyyy should be passed on to which PC.

To achieve that you need 2 things:
1- to know your "public" IP adress. That's the one reported for your Pi and Mint PCs by sites such as whatismyIP.com. It will be the same for both PCs.
2- to know which port you need to forward to your local PC. Your box will have an admin interface that will let you first, accept "packets" (info) that comes in a specific port or range of ports, and second, define to which PC and which port to pass it on to. So you need to know the local IP adress of you Pi, and the port which VNC uses (someone listed possibilities earlier). In your Internet box's admin interface, you forward that port to the same port on your PI's local IP adress. Then you save and reboot your internet box for the settings to take.

Caveats:
- Most ISPs will always give you he same public IP address, but some ISPs will change it from time to time, or even daily. Let's assume you have a fixed one (otherwise you'll need to use a dynamic DNS service)
- your local IP address may also change from time to time , depending on what your Internet box does. Again, usually they don't, but if they do there are ways to force your Pi to always use the same IP local address.
- for safety reasons, you may want to NOT use VNC's default port. That means changing the forwarding rule in your router, so that it listens to , say, port 12345 instead of port 5900, but then stills forwards it to port 5900 on your Pi; then to connect to your Pi from a foreign PC, you specify the 12345 port on top of your public IP adress, either in the "port" field if your VNC client has one, or by adding ":12345" after your public IP adress, ie 234.41.13.27:12345 in your clients "IP adress" field.

Hope this is understandable ^^

thelordmeatball
Posts: 12
Joined: Thu Jun 07, 2012 2:01 pm
Location: USA

Re: VNC from an outside network

Mon Jun 18, 2012 3:06 pm

Whoa, I let this slip a bit. Thanks for all the help. I'll take a look tonight and let everyone know.

Thanks again!

tRoller
Posts: 3
Joined: Wed Jan 30, 2013 5:00 pm
Location: Slovenia

Re: VNC from an outside network

Thu Jan 31, 2013 7:35 am

Hi all!

I have a similar problem. I can acces my Pi locally just fine. When I run TightVNC Viewer on my desktop, I connect to RPI using the RPI's IP followed by ":1".

Is this the port number on which the Pi's VNC server listens to for incoming connections? Or is this just the ":1" desktop?

I have forwarded all sorts of ports to my Pi, but I still can't access it from outside my network. I have a static IP address.

I tried these combinations, but nothing worked:
Listen on port ----------- Forward to port
1 --------- 1
1337 --- 1
1337 --- 5900
1337 --- 5901
5900 --- 5900
5900 --- 5901
5900 --- 1

I used these combinations on different occasions, not all at once.

Port forwarding for Remote Desktop (mstsc) on Win works fine and I can access my desktop normally.

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: VNC from an outside network

Thu Jan 31, 2013 8:25 am

Looks like the correct one is missing.
you need to forward port 5901 to 5901 (localip of the Pi).
The :1 indeed means display 1. Vnc uses 5900 for display 0 5901 for display 1 5902 for display2 ....

So, maybe forwarding 5900 to 5901 local works as well, but it means you have to connect to display:0 (so no :1 extension to the ip.)

Also note that some internet providers block port ranges and that some routers don't handle such port forwarding very well.

tRoller
Posts: 3
Joined: Wed Jan 30, 2013 5:00 pm
Location: Slovenia

Re: VNC from an outside network

Thu Jan 31, 2013 12:21 pm

Hi,

I found the problem. I'm currently at work and it seems our 5900 port is blocked here. I had to use 8080 and it works fine.
Router config:
Listen on port --- Forward to port
8080 --- 5900

After I've posted my previous message, I've set vncserver :0 on my RPI so it works on port 5900. Thanks anyway obcd ;)

omid429
Posts: 2
Joined: Mon May 06, 2013 1:50 pm

Re: VNC from an outside network

Mon May 06, 2013 1:53 pm

I am having a similar issue. I can access my pi from within my local network with no problem. If I set port forwarding on the router for 5900 --> 5900 then I can access my pi from an external network. However, if I switch and use port 8080 --> 5900, I get a timeout error. Any ideas?

I have a Netgear 3800 router.

Return to “Troubleshooting”