Page 1 of 1

VNC access with static IP address issues...

Posted: Thu May 12, 2016 12:12 pm
by toddak
So I'm having some issues connecting to my pi via VNC (pi 2B, with raspbian Jessie).

It all works fine when I used the assigned IP address, but when I change it so that it has a static IP it doesn't work at all.

To set up my static IP, I've been using: sudo nano/network/interfaces, and then altering the wlan0 settings as follows:

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.105
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
gateway 10.1.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

This has all worked ok with a previous project that used static IP addresses to get Pi's to talk to each other. Any ideas as to why its not working in this scenario?

Re: VNC access with static IP address issues...

Posted: Thu May 12, 2016 12:26 pm
by topguy
For Raspbian Jessie avoid using /etc/network/interfaces.

Read up:
viewtopic.php?f=66&t=140252

Re: VNC access with static IP address issues...

Posted: Fri May 13, 2016 12:33 pm
by toddak
Thanks!

Might be a dumb question, but why do all the IP addresses their using have a backslash at the end with another digit?

And I'm guessing this means I need to know the IP address of my router before I can assign a static IP, is that right? Unless I don't plan on using a router, and just connect directly to a network created by my laptop?

Re: VNC access with static IP address issues...

Posted: Fri May 13, 2016 12:55 pm
by drgeoff
The backslash followed by another number is a way of saying the subnet size. /24 is the same as saying netmask=255.255.255.0

You need to know the start and end addresses of the router's DHCP pool. You should pick an IP address outside that range and not allocated to another device.

Re: VNC access with static IP address issues...

Posted: Sat May 14, 2016 3:16 am
by toddak
That makes sense, and thanks!

However, while an understandably better way of assigning a static IP address has been suggested, the issue was not setting up the IP address, as this method has worked for another project I'm currently working on (but I'll be doing it that other way from now on, as it was causing other problems when switching networks!). Apart from the possibility of .105 being unassignable in this network, is there anything else that might cause it to not connect?

Something else I can't seem to figure out, is that I was hoping to connect to my rpi from my Macbook pro while traveling. If there was no wifi, I was hoping to just create a network from my laptop, and have the rpi connect to that. When I create a network, it is selectable in the rpi, but when I choose it the wifi icon changes to the two computers with an 'x' in the corner, and states that 'Wlan0: Disassociated from the <my home wifi network name>', and can't connect.

Am I asking the impossible or is there something obvious I'm missing? I'm thinking probably the later ;)

Re: VNC access with static IP address issues...

Posted: Mon May 16, 2016 8:26 am
by toddak
I've kept researching in the meantime, I'm now contemplating using avahi-daemon and avahi-autoipd. Its not the best solution, as for other purposes I need to know the IP address in advance, but it might be a short term fix for this project if I can't figure it out soon.

Again, any suggestions would be great. I'll be trying another IP in the interim to see if it works, but wold really like to understand why these issues are occurring.

Re: VNC access with static IP address issues...

Posted: Tue May 17, 2016 12:39 am
by ajk
toddak wrote:
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.105
netmask 255.255.255.0
network 10.1.1.0
broadcast 10.1.1.255
gateway 10.1.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Should the above not be

Code: Select all

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.105
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Re: VNC access with static IP address issues...

Posted: Tue May 17, 2016 3:52 am
by toddak
@ajk

I'm not sure, should it?

When connected to my wifi network, I used 'sudo ifconfig' and 'sudo route -n' in order to determine the values. The values above are what are given when the RPI is connected to my home network.

I can't determine values for the local network created by my laptop, as the RPI can't connect to it. Are they the values that you have suggested?

Re: VNC access with static IP address issues...

Posted: Tue May 17, 2016 7:22 am
by broe23
Yes. You cannot assign a /24 with a /8. It is like trying to force a Square Peg into a Round hole. The two do not go together.

Re: VNC access with static IP address issues...

Posted: Thu May 19, 2016 12:35 pm
by toddak
Ah, right. Still learning about all this, networking is not my strong point. So I've updated the details as suggested by AJK, and it still won't connect. I tested this by connecting both rpi and laptop to my home network, and then creating a network from my Mac. Neither worked.

Just to back track a little. If two computers are connected to the same wifi network, obviously a VNC connection can be made. I've had this work, just for some reason not with a static IP address (and in all honestly, I'm still unsure about the /24 and /8 stuff, will be googling that again in a second). But if the RPI is allowed to create its own IP, then I can get this system to work. I assume then there is some issues with the details that are being suggested, as it can't connect using them either. Still unsure as to why at the moment...

If I create a network from my laptop, without using a wifi network or router, can a RPI connect to it? I know I've been able to send OSC data between laptop and ipad this way, but just wanted to make sure that this is actually possible.