disorientedp
Posts: 58
Joined: Mon Aug 03, 2015 11:43 pm

Static IP Address on Raspbian Jessie [SOLVED]

Tue Oct 27, 2015 11:19 pm

I've been having trouble setting up a static IP in Jessie. I can't find any guides that cover it, as the interfaces file has changed. I tried reading the man page suggested in a comment in the interfaces file, but couldn't figure it out.
Last edited by disorientedp on Wed Oct 28, 2015 12:07 pm, edited 1 time in total.

MrEngman
Posts: 3946
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Static IP Address on Raspbian Jessie

Tue Oct 27, 2015 11:47 pm

disorientedp wrote:I've been having trouble setting up a static IP in Jessie. I can't find any guides that cover it, as the interfaces file has changed. I tried reading the man page suggested in a comment in the interfaces file, but couldn't figure it out.
Looking at the /etc/network/interfaces file in jessie it includes the following two lines

Code: Select all

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

MrEngman
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

disorientedp
Posts: 58
Joined: Mon Aug 03, 2015 11:43 pm

Re: Static IP Address on Raspbian Jessie

Wed Oct 28, 2015 1:28 am

MrEngman wrote:
disorientedp wrote:I've been having trouble setting up a static IP in Jessie. I can't find any guides that cover it, as the interfaces file has changed. I tried reading the man page suggested in a comment in the interfaces file, but couldn't figure it out.
Looking at the /etc/network/interfaces file in jessie it includes the following two lines

Code: Select all

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

MrEngman
Right. I can't figure out how to configure dhcpcd.conf for a static IP.


disorientedp
Posts: 58
Joined: Mon Aug 03, 2015 11:43 pm

Re: Static IP Address on Raspbian Jessie

Wed Oct 28, 2015 2:02 am

I guess I'm not really sure how to find all the information I need for this configuration. How do I choose what IP address I should use?
Here is what I have in the /etc/dhcpcd.conf file (The full contents):

Code: Select all

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface wlan0
static ip_address=192.168.0.30/255.255.255.0
static routers=10.0.1.1
static domain_name_servers=10.0.1.1

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Static IP Address on Raspbian Jessie

Wed Oct 28, 2015 2:53 am

what you try to do?
why you want a static IP for WIFI
if you need to ask what IP to use you should not do a change in /etc/dhcpcd.conf at all
the reason for dhcpcd is to do it all for you
after the connection works ( like ethernet cable to router and wifi adapter to wifi ssid router )
you can document IP of router(s), and wlan0 IP and eth0 IP.

you can use that IPs to connect remotely from any computer in the same network

only if you have full knowledge / control over your network you can use static IP later, like if the RPI needs to be a network server...

so what was the router IP, the RPI eth0 IP and RPI wlan0 IP prior to your change?
if your WIFI router is at 10.0.1.1
your RPI IP could be 10.0.1.30 ( if free ) but never 192.168.0.30
if the .30 given by router automatically ( check router settings DHCP IP Address Range : from
to ) it is more nice to use a IP what is outside of the automatic range.
my ADSL router has IP 192.168.1.1, so i use ( at the end of ) /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.1.101/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
interface wlan0
static ip_address=192.168.1.201/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 
and in desktop top right i see
http://kll.engineering-news.org/kllfusi ... d_conf.png

klricks
Posts: 6794
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Static IP Address on Raspbian Jessie

Wed Oct 28, 2015 5:30 am

IMO it is much easier to setup a DHCP reservation for the RPi (MAC address) in your router. That way the router always assigns the same IP of your choice and there is no config changes at all to do on the RPi.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

disorientedp
Posts: 58
Joined: Mon Aug 03, 2015 11:43 pm

Re: Static IP Address on Raspbian Jessie

Wed Oct 28, 2015 12:05 pm

Okay, I got it to work. Thanks for the help; I'm a bit slow at times. Now I won't have to bother with memorizing an IP address that changes every few days...

JayS
Posts: 13
Joined: Sat Nov 07, 2015 8:24 pm
Location: Newberg, OR, USA

Re: Static IP Address on Raspbian Jessie

Sat Nov 07, 2015 9:09 pm

klricks wrote:IMO it is much easier to setup a DHCP reservation for the RPi (MAC address) in your router. That way the router always assigns the same IP of your choice and there is no config changes at all to do on the RPi.
I agree. I am new to all the network settings and I tried to set a static IP within Raspian for a print server but never quite got it right. I found the address reservation setting in my router and have had no problems since.

Enjoy the ride,
Jay
Fast enough to get there...slow enough to see

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Static IP Address on Raspbian Jessie

Sat Nov 07, 2015 10:02 pm

disorientedp wrote:Okay, I got it to work. Thanks for the help; I'm a bit slow at times. Now I won't have to bother with memorizing an IP address that changes every few days...
Usually you'd put that in your hosts file so that the name could then be used in most situations.

Henk B
Posts: 1
Joined: Sun Dec 06, 2015 6:57 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sun Dec 06, 2015 7:02 pm

I have managed the static ip address with the crontab, add to sudo crontab -e: @reboot sudo ifconfig eth0 192.168.2.1
and reboot the RPi, this solved mi problem to manage the IP address...

bobe001
Posts: 10
Joined: Wed Dec 09, 2015 11:01 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Dec 09, 2015 11:04 pm

Hi I've found that using the solution as explained above, while giving you a static address completely screws the ntp function

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Wed Dec 09, 2015 11:57 pm

bobe001 wrote:Hi I've found that using the solution as explained above, while giving you a static address completely screws the ntp function
When doing this, is there already a dhcp address set up for that adapter? I mean if you look at eth0, do you get something sane just something that you can't seem to stop from changing? Because, perhaps, you could modify the idea the other person had to the following:

sudo crontab -e: @reboot sudo ifconfig eth0:1 192.168.2.1

The idea would be to keep the dhcp address but then add in your own static one. I also would think about changing the static address from ending in .1 since that is often what routers are set at. Find out also where your dhcp addresses are and avoid those.

bobe001
Posts: 10
Joined: Wed Dec 09, 2015 11:01 pm

Re: Static IP Address on Raspbian Jessie [SOLVED]

Thu Dec 10, 2015 9:18 am

Hi no I do get a sane ip allotted to me but because the pic will be working headless in a remote location I have to have a static ip to reach it. Using frontal does work for me however to not be able to use the documented method must mean Jessie has a bug.

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

Re: Static IP Address on Raspbian Jessie [SOLVED]

Thu Dec 10, 2015 12:05 pm

Hi no I do get a sane ip allotted to me but because the pic will be working headless in a remote location I have to have a static ip to reach it. Using frontal does work for me however to not be able to use the documented method must mean Jessie has a bug.
I agree, Raspbian Jessie does appear to have a bug.

This is my limited understanding of how we should assign a static IP within Jessie:
/etc/network/interfaces should be the original unedited:

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 manual

allow-hotplug wlan0
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
/etc/wpa_supplicant/wpa_supplicant.conf contains your router ssid and password

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="BTHub3-FR0B"
    psk="09a87b65cd"
}
And at the bottom of /etc/dhcpcd.conf define your static IP setup. Of course the actual values have to match your network setup

Code: Select all

...
...
interface wlan0
static ip_address=192.168.1.140/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8

interface eth0
static ip_address=192.168.1.147/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
If you do the above you may end up with two IP addresses, your static one and a variable DHCP one.
I think that in /etc/network/interfaces "iface xxxx inet manual" means that the interface should not be assigned a DHCP IP address, but it is. This is where the bug is in Raspbian, imho.

User avatar
karrika
Posts: 1088
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: Static IP Address on Raspbian Jessie [SOLVED]

Thu Dec 10, 2015 12:15 pm

In the Ubuntu world the /etc/network/interfaces is honored by the automatic wizardry of Network Manager. It would be nice if Jessie would do the same.

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

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sun Dec 20, 2015 8:31 am

I messed around with this for a while and found that I was able to get a static IP by adding only

Code: Select all

interface eth0
static ip_address=192.168.1.101/24
interface wlan0
static ip_address=192.168.1.201/24
to the dhcpcd.conf file. Could someone explain what the static routers IP and static domain_name_servers IP are there for? I'm sure they have some purpose, but it seems to work without them..

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

Re: Static IP Address on Raspbian Jessie [SOLVED]

Sun Dec 20, 2015 9:00 am

smithy468 wrote:Could someone explain what the static routers IP and static domain_name_servers IP are there for? I'm sure they have some purpose, but it seems to work without them.
Without those entries you shouldn't be able to get to anything outside your own 192.168.1.0 network range (the routers entry), and shouldn't be able to access any remote service by name, like raspberrypi.org (the domain_name_servers entry).

Unless you have added in a router/gateway with the route command, and added a DNS entry to /etc/resolv.conf.

Out of interest, what do "ip route" and "cat /etc/resolv.conf" show?

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

Re: Static IP Address on Raspbian Jessie [SOLVED]

Tue Dec 22, 2015 6:02 am

Thank you, you are right... Doing

Code: Select all

sudo ping 8.8.8.8 
(Google DNS) gives a "network is unreachable" error.
ip route shows:

Code: Select all

10.0.0.0/8 dev wlan0  proto kernel  scope link  src 10.0.0.98  metric 303
169.254.0.0/16 dev eth0  proto kernel  scope link  src 169.254.81.98  metric 202 
cat /etc/resolv.conf shows:

Code: Select all

# Generated by resolvconf
nameserver 2001:558:feed::1
nameserver 2001:558:feed::2

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

Re: Static IP Address on Raspbian Jessie [SOLVED]

Tue Dec 22, 2015 6:28 am

Ok, something is very wrong with your networking setup.

You have set a static address of 192.168.1.101 for wired and 192.168.1.201 for wireless, but your routing is showing a 10.x.x.x subnet for the wireless and a 169.254.x.x (can't get a real address via DHCP) subnet for the wired.

The entries in resolv.conf show only ipv6 addresses, no ipv4.

Please post the full contents of /etc/network/interfaces and /etc/dhcpcd.conf

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

Re: Static IP Address on Raspbian Jessie [SOLVED]

Tue Dec 22, 2015 6:58 am

So the IP addresses I posted above were just from the examples... For eth0 I'm using 169.254.81.98 and wlan0 is 10.0.0.98.

Here is the /etc/dhcpcd.conf file contents:

Code: Select all

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface eth0
static ip_address=169.254.81.98
static routers=169.254.1.1
static domain_name_servers=169.254.1.1

interface wlan0
static ip_address=10.0.0.98
static routers=10.0.0.1
static domain_name_servers=10.0.0.1



Here is my /etc/network/interfaces file:

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 manual

allow-hotplug wlan0
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

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

Re: Static IP Address on Raspbian Jessie [SOLVED]

Tue Dec 22, 2015 10:04 am

You can't have a static router in the 169.254.xxx.xxx/16 subnet. That network block is not routable.
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 2:49 am

I guess I should clarify, I'm connecting the Pi directly to my PC via ethernet. The IP of my laptop's ethernet adapter is 169.254.81.99, so I changed the last number of it when assigning the static IP of my Pi. I did get it to work with:

Code: Select all

interface eth0
static ip_address=169.254.81.98
static routers=169.254.0.0
static domain_name_servers=75.75.75.75 75.75.76.76 2001:558:feed::1 2001:558:feed::2

interface wlan0
static ip_address=10.0.0.98
static routers=10.0.0.1
static domain_name_servers=75.75.75.75 75.75.76.76 2001:558:feed::1 2001:558:feed::2
I copied the domain name servers from the resolv.conf file on a clean install of Jessie. Do you see any conflicts/ problems doing it this way?

User avatar
DougieLawson
Posts: 37134
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 8:12 am

Get rid of

Code: Select all

static routers=169.254.0.0
because it will break your networking. 169.254.xxx.xxx/16 is the link-local address block and shouldn't be used as a default route.
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 11:50 am

Ok, will do, thanks.... But what should be used instead? Or should I just omit the line entirely?

Return to “Beginners”