mpalomer
Posts: 26
Joined: Mon Dec 31, 2012 5:26 am

Static IP w/ DHCP enabled router?

Sat Jan 19, 2013 4:36 am

The router I'm using uses DHCP to assign IP addresses. I can't quite change this setting because I share this connection with other people. However I want to give my Pi a static IP address so I can SSH into it without having to look up the (possibly new) IP address of it every time I boot it up. Is there any way to do this?

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: Static IP w/ DHCP enabled router?

Sat Jan 19, 2013 4:57 am

Generally your router will only give out a range leaving a ton left over you would have to see how many IP's it has set for DHCP this can be anywhere from 1 to 253 but is sometimes only 50

If you get something like 192.168.x.1 as the IP to your router then you have a range from 192.168.x.2 to 192.168.x.254 look for a setting under the DHCP tab for a range and pick a static one not listed. Also if not set put a range that is realistic if you only expect to have 20 DHCP clients then set a similar range so you don't give out way more than you need.

For ease I typically set my static starting around 100 so I know what it is 100 is pc in living room, 101 is bedroom for example.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

Gordon2
Posts: 23
Joined: Wed Jan 16, 2013 10:45 pm

Re: Static IP w/ DHCP enabled router?

Sat Jan 19, 2013 11:02 pm

When you say you share the router, do you mean that you don't have control over it (it belongs to someone else?). If you do have control over it then it should be a simple matter to config it to assign a static IP to the pi based on its MAC address (and outside the DHCP range as mentioned above). You should elaborate on your situation. Can you config the router or not, what make and model is it.

Mobius
Posts: 238
Joined: Thu Aug 30, 2012 1:07 am
Location: San Angelo, Texas USA

Re: Static IP w/ DHCP enabled router?

Sun Jan 20, 2013 12:35 am

Generally, a router will be set up for a range of addresses to be used for DHCP. In my case, the range is from 192.168.1.100 and up. So I set all of my static addresses from 192.168.1.10 to 192.168.1.99. Other routers use a lower address range. You should be able to figure it out by looking at the DHCP address assigned to your Pi. Usually, you won't have a conflict anyway since there are so many addresses available. To set up a static IP on the Pi you need to edit the /etc/network/interfaces file something like this:

Code: Select all

auto wlan0
iface wlan0 inet static
address 192.168.1.67
netmask 255.255.255.0
gateway 192.168.1.1
wireless-essid myroutername
wireless-key mykey
This setup is for WEP encryption but you can search the net for the correct wording for SSID and Key lines for WPA encryption or go into the GUI interface (use the "startx" command) and there is a wireless setup wizard in there. If you are connected via ethernet cable, then the code lines would be like this:

Code: Select all

iface eth0 inet static
address 192.168.1.66
netmask 255.255.255.0
gateway 192.168.1.1

PiSi
Posts: 37
Joined: Mon Jan 14, 2013 9:41 am

Re: Static IP w/ DHCP enabled router?

Sun Jan 20, 2013 2:07 pm

I use a BT Home Hub and there is a setting to assign the same IP each time to a specific device - if i do this will I still need to set a static IP address in the Pi?

Thanks

Simon

Mobius
Posts: 238
Joined: Thu Aug 30, 2012 1:07 am
Location: San Angelo, Texas USA

Re: Static IP w/ DHCP enabled router?

Sun Jan 20, 2013 7:39 pm

Never seen that capability before but it sounds like it will be fine. You will need to take note of the assigned IP address so that you have that info if you want to do SSH from your PC to the Pi.

PiSi
Posts: 37
Joined: Mon Jan 14, 2013 9:41 am

Re: Static IP w/ DHCP enabled router?

Sun Jan 20, 2013 8:40 pm

It's a section under the device list on the network from connecting into the router.

Have selected to keep the ip assigned and seems ok so far.

Simon

Return to “Beginners”