Different IP Addresses on Different Networks


6 posts
by neosilky » Tue Nov 06, 2012 5:47 pm
First off, hi!

I'm an intermediate Linux user which is why I can't manage to figure this out. Basically, I have a Raspberry Pi (obviously) with a small WiFi adapter and my final idea is to run it headless wirelessly. Originally I had to connect it via monitor to get the WiFi connected and that went okay.

(I want to be able to connect to a range of selected WiFi networks on my travels and SSH in from my phone or Laptop).

PS. I'm running Raspbian Wheezy latest version.

So I have one of two problems;
1) Editing the /etc/wpa_supplicant/wpa_supplicant.conf is very hit and miss. Sometimes the Pi connects to WiFi after boot, sometimes it just skips all Access Points, I need to investigate more but I added priorities and such. Any ideas? I'll be open to supplying files or outputs.

2) MAIN ISSUE: So once I have my RPi connected, I need the IP to SSH in but obviously this could be a problem when I cannot get hold of the IP. So I want to give it a Static IP. Only problem is is that the AP I will be connecting to have different gateways and subnets so all my settings will be different. My /etc/network/interfaces has been left as the default (dhcp for WiFi) and I know you can change static settings but any idea how to do it for multiple AP's?

Thanks in advance and I'll try and supply anything you want!
Posts: 3
Joined: Tue Nov 06, 2012 5:36 pm
by bredman » Wed Nov 07, 2012 11:09 am
There are two main methods to get around this...

1. Turn your RPi into a WiFi hotspot and let it assign its own IP addresses to itself and any device that connects to it. This is very useful if you want to SSH in to do some work because you don't need a WiFi access point available. However, you lose the ability to connect to the internet, unless you have two WiFi devices on the RPI, one as a hotspot and one to connect to the internet.

2. Use hostnames instead of IP addresses. Unfortunately, some WiFi Access Points are very bad at handling hostnames so this may be hit-and-miss.
Posts: 1413
Joined: Tue Jan 17, 2012 2:38 pm
by broo0ose » Wed Nov 07, 2012 5:19 pm
If you have access to the DHCP servers at each location then you can set them to give you the same IP address whenever they see the RPi's MAC address.

Alternatively, you could get the Pi to post its address somewhere. Say to a twitter account.
Posts: 241
Joined: Wed Dec 14, 2011 3:59 pm
Location: Wirral, UK
by neosilky » Thu Nov 08, 2012 5:50 pm
broo0ose wrote:If you have access to the DHCP servers at each location then you can set them to give you the same IP address whenever they see the RPi's MAC address.

Alternatively, you could get the Pi to post its address somewhere. Say to a twitter account.


I have access to the DHCP list page at my home router but in general, I probably won't have access but thanks for the suggestion!
Posts: 3
Joined: Tue Nov 06, 2012 5:36 pm
by neosilky » Thu Nov 08, 2012 5:51 pm
bredman wrote:There are two main methods to get around this...

1. Turn your RPi into a WiFi hotspot and let it assign its own IP addresses to itself and any device that connects to it. This is very useful if you want to SSH in to do some work because you don't need a WiFi access point available. However, you lose the ability to connect to the internet, unless you have two WiFi devices on the RPI, one as a hotspot and one to connect to the internet.

2. Use hostnames instead of IP addresses. Unfortunately, some WiFi Access Points are very bad at handling hostnames so this may be hit-and-miss.


Thanks for replying, I think I'll do the first one, it allows the greatest portablity and I use mini WiFi dongles anyway so getting two is not a problem, thanks a lot!
Posts: 3
Joined: Tue Nov 06, 2012 5:36 pm
by daviewales » Mon Nov 12, 2012 2:39 pm
Try installing the avahi-daemon.
Code: Select all
sudo apt-get install avahi-daemon

It will allow you to connect to your Raspberry Pi by typing "PiName.local" instead of the IP address. (Replace "PiName" with whatever the name of your Raspberry Pi is.)

Check out this site for more detail on the setup:

http://blog.marxy.org/2012/06/headless-raspberry-pi-on-network.html.

I have heard suggestions that it doesn't work for all setups, but it works for me, so it might save you some time.
Posts: 19
Joined: Wed Apr 25, 2012 12:22 am