User avatar
DougieLawson
Posts: 37074
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Dec 23, 2015 2:56 pm

smithy468 wrote:Ok, will do, thanks.... But what should be used instead? Or should I just omit the line entirely?
Just take the line out or prefix it with #.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

smithy468
Posts: 10
Joined: Sun Jul 26, 2015 12:04 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Dec 23, 2015 6:03 pm

Ok thanks! It works just fine now...

wolf.z
Posts: 131
Joined: Thu Dec 24, 2015 8:34 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Thu Dec 24, 2015 8:55 pm

Sorry,

though this thread says solved, Itried the same with my Pi 2, no success. I have freshly installed Jessie. issue.txt says:

Code: Select all

Raspberry Pi reference 2015-11-21
Generated using Pi-gen, https://github.com/RPi-Distro/Pi-gen, jessie-stage4
This is my config in /etc/network/interfaces :

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

#iface eth0 inet static
#address 10.0.0.16
#netmask 255.255.255.0
#network 10.0.0.0
#broadcast 10.0.0.255
#gateway 10.0.0.1

auto eth0
allow-hotplug eth0
iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet static
address 10.0.0.6
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1
#iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
The method with assigning a static address to wlan0 works. The same method does not work with the eth0. So I commented it and tried the other method as described earlier. With the following in /etc/network/interfaces

Code: Select all

auto eth0
allow-hotplug eth0
iface eth0 inet manual
and the following at the end of an unchanged /etc/dhcpd.conf the Pi still gets a (DHCP) address from the router.

Code: Select all

interface eth0
static ip-address=10.0.0.16/24
static routers=10.0.0.1
static domain_name_servers=10.0.0.1
What am I missing?

Thanks a lot and merry christmas,
Wolfram

jbudd
Posts: 1078
Joined: Mon Dec 16, 2013 10:23 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sat Dec 26, 2015 12:11 am

You get a dhcp IP address, but do you also get the static one that you defined?
Try pinging your static IP, check your router client table, or run ipscan24 or similar tool to identify devices on your network.

The line in /etc/network/interfaces
" iface eth0 inet manual "
should prevent a DHCP address being assigned, but it doesn't work in Jessie.

haag
Posts: 14
Joined: Sat Dec 26, 2015 6:44 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sat Dec 26, 2015 6:52 pm

I have the same problem wit my new pi.
Ip address is not set properly and if i ping the static address doesnot come up.

Any ideas anyone?

fylloxera
Posts: 2
Joined: Sat Dec 26, 2015 9:46 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sat Dec 26, 2015 10:02 pm

I was telling my wife that in the world of computers nobody gives clear instructions, and that people tend to go off topic and then endlessly argue about the off topic. Then there are the pointless tidbit, or tibbit correctors, that don't solve the problem, but just want to make a pointless point.

Hope this is clear to all. :shock:

Change network interface to static ip
1. In your terminal type:
ifconfig

You will see several network interfaces like
eth0
lo
wlan0

eth0 is wired internet
lo is loopback --- don't change
wlan0 is wireless internet

I changed my wireless internet to static (I did not change the wired - it will remain dynamic, if you want to change the wired just replace "interface wlan0" with "interface eth0") You can also add both.

I use the typical class "C" 192.168.0.xxx Ip block. You may need to change to suit class "A" (10.0.x.x) or Class B

2. Type the following in terminal:

sudo nano /etc/dhcpcd.conf

{you may need a password}

3. Then add to the bottom of file

interface wlan0
static ip_address=192.168.0.100/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

4. Press Ctrl+O to save the file. Press Ctrl+X to exit "NANO"


then reboot. This works as of Dec 26, 2015 on Jessie

wolf.z
Posts: 131
Joined: Thu Dec 24, 2015 8:34 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Mon Dec 28, 2015 10:29 am

Thank you fylloxera,

your method does not work on my Raspi!
In mean time I succeeded. Yes, it is the GUI's assistant which is enabling static IP config. Yesterday evening it was my last try. After trying the old method using /etc/network/interfaces, after trying the method working on your raspbian in /etc/dhcpcd.conf, finally I tried this one in /etc/dhcp/dhclient.conf. from http://iwtechie.net/wordpress/author/gregg/ tried the lease and the alias method. No sucess.

The GUI's assistant puts lines in /etc/dhcpcd.conf with one big difference: keyword "inform". You might use it editing by hand as well. Works perfect!

What the GUI's assistant adds:
is not: static ip_address=192.168.0.100/24
instead: inform ip_address=192.168.0.100

Funny: I searched the web. There is no one single reference for "inform" concerning DHCP. This must be a Raspbian's special. Even more funny: There are Raspbians around, reacting as expected.

Great if someone could find out where the differences come from. Maybe it is my Fritz Box, might be a different update track of Jessie, maybe moon phase?

Wolfram

User avatar
Cancelor
Posts: 759
Joined: Wed Aug 28, 2013 4:09 pm
Location: UK

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sun Apr 17, 2016 5:55 pm

I would recommend following this post, it is clear and will help correct some previous edits:-

viewtopic.php?p=859763#p859763
Can't find the thread you want? Try googling : YourSearchHere site:raspberrypi.org

Andrei
Posts: 18
Joined: Tue Nov 13, 2012 8:38 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Mon May 23, 2016 3:14 pm

Great! Just tested newest Raspbian and realized that my tool which uses /etc/network/interfaces for changing network settings is broken now. Why on earth this needed to be changed? Why there can’t be just one config file for ALL networking related settings? I understand that "networking" is a broad term and different functionalities are implemented by different tools, but still, I think we could come to some consensus and define one place from where all these tools would read their settings. Or is it too much to ask from Linux community in the year 2016? BTW, I googled for "raspberry pi change ip" and the first up-to-date tutorial was the ninth link, not very convenient for beginners.

wilraz
Posts: 1
Joined: Fri May 27, 2016 2:25 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Fri May 27, 2016 2:34 am

I just now configured a static IP for my B+ with Jessie as the OS. You need not change ANYTHING in the pi's configuration. Everything should be done through your DHCP device or server. Reserve the IP you want, bind that IP to the MAC of the pi, etc... I am using a TP Link Archer C9, and after a bit of tweaking, have my pi configured to a static address without breaking my entire network.

I know this seems "dumbed down" for most of you network programmers out there, but it is simpler than killing your entire distro, and having to do fresh installs or recoveries until you get it right.

Hans60
Posts: 2
Joined: Wed Jun 01, 2016 10:11 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Jun 01, 2016 10:22 am

Works only if you actually *have* a DHCP server in your network. If you configure an ad hoc network connection you'll *have* to assign a static address to the RPi itself.

mythryll
Posts: 6
Joined: Fri Mar 22, 2013 11:25 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Thu Dec 15, 2016 3:51 pm

Guys please delete this post or change the title in "how to get things screwed up in home networking". From what I read only one person in the discussion knows what he is talking about for the networking part.
For everybody:
I found this post while looking for the right way to setup static DNS configuration in Raspbian Jessie Lite after setting up a static ip address.
When I tried to use the /etc/network/interfaces config file as it worked in the past, I came across the information that static addressing is also handled by /etc/dhcpcd.conf and that I should look there and at man dhcpcd.conf.
Now if you only follow the first route (/etc/dhcpcd.conf) and not the second you will not undestand much. So I took the second after the first and found what I was looking for. It's right in the explanation for the static option. There is a whole example inside the file.

Code: Select all

     static value
             Configures a static value.  If you set ip_address then dhcpcd will not attempt to
             obtain a lease and just use the value for the address with an infinite lease time.

             Here is an example which configures a static address, routes and dns.
                   interface eth0
                   static ip_address=192.168.0.10/24
                   static routers=192.168.0.1
                   static domain_name_servers=192.168.0.1

             Here is an example for PPP which gives the destination a default route.  It uses the
             special destination keyword to insert the destination address into the value.
                   interface ppp0
                   static ip_address=
                   destination routers
Now if that is not enough take a look here:
https://wiki.archlinux.org/index.php/dhcpcd

Now about the rest. The address you are using for the eth0 interface as the other person mentioned is the PIPA range (Private IP Address) used by the dhcp networking process to assign an address to your interface when no dhcp server responds to the client's request. It's supposed to happen that way so when two or more stations find themselves in a lan segment without a dhcp server or a dchp relay setup can still discover and talk to each other in the network. Of course that doesn't mean much if there no other services are not setup properly (name search, file sharing etc) but it's a base you can build on without touching the interfaces.
There is no reason to use a pipa address in a static setup. I am not making any sense also about the necessity of the routing and dnslookup for your pi if you are just connecting it to your pc. Do you even use the wireless interface? If not why don't you deactivate it? Either you are trying to setup an isolated lan with only your two stations (pc and raspberrypi) or you are trying to use your pi or your pc as bridge. In any case, pick a private lan address (such as 10.0.0.0/24) and use that for your stations (for example 10.0.0.2 for the pc and 10.0.0.3 for the pi and use 255.255.255.0 as mask and 10.0.0.1 as the gateway). No reason to pick a huge network for only two stations. The 10.0.0.0 address is the network address, not used for station as someone already mentioned. That network is routable and will be NATed (translated in public network addressing) when it crosses your router (or gateway, typicaly the internet modem/router in most home lans) and you will have internet access.
What you have been told about the necessity of nameservers and router (gateway) is true. You need those for the services you will be using for internet. For your home needs (if you wanted to use the hostnames in the network instead of the ip addresses for any services) you could use the /etc/hosts file but it's not necessary. You can use the ip addresses of the hosts just fine (it's just a .2 and .3 to remember).
Don't follow strange advices about how to force a linux machine to behave the way you want it to or the way your remember it should behave from an older version of the same os or a different linux flavor. In the last few years I have noticed that there is a direction things are evolving for services and daemons. A lot of things we used to put in config files ourselves are now generated by daemons and the actual configuration for those daemons takes place somewhere else. Dhcpcd is not different in this case. Don't try to force it out of the equation or your risk to make things fall apart or loose some functionnality you are not aware of.
For Jessie Lite, I don't thing you are supposed to use /etc/resolv.conf. The resolvconf command is called by the system to take care of that.
Take a look here:
https://www.howtoforge.com/debian-static-ip-address
It says in the DNS section:

Code: Select all

DNS configuration

DNS can be added in the file /etc/resolv.conf

nano /etc/resolv.conf

nameserver	8.8.8.8 
nameserver	8.8.4.4

Note : DNS entries with the debian system will only works if resolvconf is not installed. If resolvconf is installed then you need to append the DNS entries in the file /etc/network/interfaces only as follows:

[....]

#DNS configurations
dns-nameservers	8.8.8.8
dns-nameservers 8.8.4.4

You can check whether resolvconf is installed or not by

dpkg -l | grep resolvconf
resolvconf is installed in Jessie Lite. So I am still looking to see what must be done about it (static DNS contains more fields such as the search domain) as the use of /etc/network/interfaces is not an option.
If I do find a way I will come back here and complete this post.
If you guys find a way let me know.
Cheers,
John

mythryll
Posts: 6
Joined: Fri Mar 22, 2013 11:25 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Thu Dec 15, 2016 4:06 pm

Hello Wolf.z, I don't know if you will read this but this seems like manipulating the properties of a dhcp lease. It doesn't seem right.
The way described in man dhcpcd.conf which I just put up seems to be the right answer and is tested for latest jessie lite on raspberry pi B but not the Raspberrypi 2. I am using the B models at work but I got a pi2 at home. When I find time, I will give it a try and let you know.
One thing that confused me in my efforts is that it wouldn't assign the static ip on the eth0 if I didn't have a cable connected. I am guessing this happens on purpose somewhere in the dhcpcd.conf file. Mind you there are a lot of default options so take a good look in the man pages (man dhcpcd.conf).
Cheers, glad you made it work even though it seems awkward. I can't do the same as it's the lite version, those buggers are meant to be headless in my case.
wolf.z wrote:Thank you fylloxera,

your method does not work on my Raspi!
In mean time I succeeded. Yes, it is the GUI's assistant which is enabling static IP config. Yesterday evening it was my last try. After trying the old method using /etc/network/interfaces, after trying the method working on your raspbian in /etc/dhcpcd.conf, finally I tried this one in /etc/dhcp/dhclient.conf. from http://iwtechie.net/wordpress/author/gregg/ tried the lease and the alias method. No sucess.

The GUI's assistant puts lines in /etc/dhcpcd.conf with one big difference: keyword "inform". You might use it editing by hand as well. Works perfect!

What the GUI's assistant adds:
is not: static ip_address=192.168.0.100/24
instead: inform ip_address=192.168.0.100

Funny: I searched the web. There is no one single reference for "inform" concerning DHCP. This must be a Raspbian's special. Even more funny: There are Raspbians around, reacting as expected.

Great if someone could find out where the differences come from. Maybe it is my Fritz Box, might be a different update track of Jessie, maybe moon phase?

Wolfram

drgeoff
Posts: 10205
Joined: Wed Jan 25, 2012 6:39 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Fri Dec 16, 2016 10:54 am

For any model of RPi running either the full or lite versions of Raspbian Jessie, you should set up static addressing in dhcpcd.conf and leave the interfaces file alone.

mikeschoon
Posts: 1
Joined: Sat Feb 04, 2017 3:39 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sat Feb 04, 2017 3:47 am

Could someone explain who to contact at Pi Towers regarding the decision to manage static IP addresses through the dynamic host control protocol server? I'd like to follow up with some logic problems.

hunter-nl
Posts: 1
Joined: Mon Feb 06, 2017 6:47 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Mon Feb 06, 2017 6:59 pm

One static IPv4 through /etc/dhcpcd.conf file is clear. Many examples can be found on the Internet.

But how can I configure a static IPv6 and IPv4 on interface eth0 and wlan0 (two different networks and both with dual stack).
I need to configure a static IPv6. Not through auto config or dhcpv6.

Before raspbian jessie and with many different linux systems it is easy to configure it in /etc/network/interfaces. But why is this changed with jessie? And when it is changed, then where is the documentation? For only one interface and static IPv4 it can be done through dhcpcd.conf as you can find in examples on multiple websites. But for dual stack and/or multiple interfaces not.

Can someone tell me how to configure it?

gauravsharma0190
Posts: 125
Joined: Tue Oct 28, 2014 6:36 am

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Feb 15, 2017 6:41 am

Hello everyone
i just do the same
go to sudo nano /etc/dhcdcd.conf
and add
interface eth0
static ip_address=192.168.137.1/24
static routers=192.168.137.0
static domain_name_servers=192.168.137.0
and reboot this
but does't any effect
i am using pixel.

Ernst
Posts: 1272
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Feb 15, 2017 8:33 am

gauravsharma0190 wrote:Hello everyone
i just do the same
go to sudo nano /etc/dhcdcd.conf
and add
interface eth0
static ip_address=192.168.137.1/24
static routers=192.168.137.0
static domain_name_servers=192.168.137.0
and reboot this
but does't any effect
i am using pixel.
Why are you doing this ? If you have done everything right there is no need to configure static addresses.

Now a small bit of information on IP-subnets. The /24 indicates that the subnet mask is 255.255.255.0, the "name" of the subnet is 192.168.137.0 and the .0 address is not used (depending on where you may find the word illegal). With ICS installed you will find that the PC interface will be 192.168.137.1, the router address and domain name server address will also be set to this address. But if ICS is not installed configuring these addresses will not help.
The road to insanity is paved with static ip addresses

User avatar
DougieLawson
Posts: 37074
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Feb 15, 2017 8:41 am

gauravsharma0190 wrote:Hello everyone
i just do the same
go to sudo nano /etc/dhcdcd.conf
and add
interface eth0
static ip_address=192.168.137.1/24
static routers=192.168.137.0
static domain_name_servers=192.168.137.0
and reboot this
but does't any effect
i am using pixel.
It's dhcpcd.conf

any .0 address is unusable. Subnets run from .1 to .254 (.255 is the broadcast address).
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
rpdom
Posts: 16082
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Feb 15, 2017 8:47 am

DougieLawson wrote:any .0 address is unusable. Subnets run from .1 to .254 (.255 is the broadcast address).
in a /24 subnet. Some .0 addresses are fine in /16 or /8 subnets. But 192.168.x.x tend to be /24 as in this case.

User avatar
DougieLawson
Posts: 37074
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Feb 15, 2017 8:56 am

rpdom wrote:
DougieLawson wrote:any .0 address is unusable. Subnets run from .1 to .254 (.255 is the broadcast address).
in a /24 subnet. Some .0 addresses are fine in /16 or /8 subnets. But 192.168.x.x tend to be /24 as in this case.
Eh? How? Give an example.

There's no subnet that has a valid .0 as the last octet of the address regardsless of the netmask. The .0 is always the base address.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
rpdom
Posts: 16082
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Feb 15, 2017 9:03 am

[quote="DougieLawson"There's no subnet that has a valid .0 as the last octet of the address regardsless of the netmask. The .0 is always the base address.[/quote]
192.168.0.0/16 is just one example
Valid addresses are from 192.168.0.1 to192.168.255.254
192.168.1.0 is a valid address in that subnet.

I have servers where the last octet is 0.

Ernst
Posts: 1272
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Feb 15, 2017 9:43 am

rpdom wrote:
DougieLawson wrote:There's no subnet that has a valid .0 as the last octet of the address regardsless of the netmask. The .0 is always the base address.
192.168.0.0/16 is just one example
Valid addresses are from 192.168.0.1 to192.168.255.254
192.168.1.0 is a valid address in that subnet.

I have servers where the last octet is 0.
Depending on where you get your information the .0 in the last octet can be allowed but there are hints why it should not be used as it is subject to interpretation. In general .0 and .255 should not be used to avoid problems, this is good practice.

In your example above you do not mention that the subnet mask is /16 and therefor 192.168.1.0 is an address in the subnet 192.168.0.0/16 (192.168.0.1 to 192.168.255.254). But with an address like 192.168.1.0 most experienced administrators would expect the subnet to be 192.168.1.0/24 as per RFC 1918 (https://tools.ietf.org/html/rfc1918).
The road to insanity is paved with static ip addresses

Return to “Beginners”