gordon901823
Posts: 6
Joined: Sat Jan 23, 2016 9:13 pm

Pi won't maintain static private IP

Sun Mar 20, 2016 2:21 am

No matter what I do, my Raspberry Pi (Raspbian Jessie, Raspberry Pi 3) does not maintain a static IP address on my local network. I have my router configured to assign the network interface (by MAC address) a specific IP, and I also have addressing set to manual for the eth0 interface. It should not be possible for it to even attempt to use any other address, and yet about 1 in 3 times I start up the Pi, it somehow ends up with a different IP (different IP even time). Rebooting again fixes the issue, but it's extremely annoying. Since I have dhcp off for that interface, I can't figure out how it's even getting an address.

/etc/network/interfaces:

Code: Select all

iface eth0 inet static
  address 192.168.14.11
  netmask 255.255.255.0
  network 192.168.14.0
  broadcast 192.168.14.255
  gateway 192.168.14.1

Higgs
Posts: 43
Joined: Tue May 26, 2015 2:17 pm

Re: Pi won't maintain static private IP

Sun Mar 20, 2016 4:05 am

Forget /etc/network/interfaces.

Edit/add to the end of the /etc/dhcpcd.conf file.

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

Re: Pi won't maintain static private IP

Sun Mar 20, 2016 8:25 am

Higgs wrote:Forget /etc/network/interfaces.

Edit/add to the end of the /etc/dhcpcd.conf file.
Put /etc/network/interfaces back to how it started

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
Put this stuff at the bottom of /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.14.11/24
static routers=192.168.14.1
static domain_name_servers=192.168.14.1 8.8.8.8
#
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.

zealousd
Posts: 93
Joined: Sun Mar 20, 2016 10:57 am

Re: Pi won't maintain static private IP

Sun Mar 20, 2016 11:05 am

i never altered these settings to set a static local IP, i didn't see much of a point really as DHCP could take over and cause issues if not done correctly.

I assigned mine by the router and added a static lease to the IP address and MAC address and so that device has a hardware attached IP assigned by the router. Some routers you may need to restart to take effect but mine took effect within a minute or so, let me know if you have questions on how to set this up.
Raspberry Pi 3
Ubuntu Mate
Web Server

gordon901823
Posts: 6
Joined: Sat Jan 23, 2016 9:13 pm

Re: Pi won't maintain static private IP

Mon Mar 21, 2016 6:53 pm

zealousd wrote:i never altered these settings to set a static local IP, i didn't see much of a point really as DHCP could take over and cause issues if not done correctly.

I assigned mine by the router and added a static lease to the IP address and MAC address and so that device has a hardware attached IP assigned by the router. Some routers you may need to restart to take effect but mine took effect within a minute or so, let me know if you have questions on how to set this up.
This is exactly how I prefer to do it, and every device on my network is set up in this way, including the Pi. For whatever reason, the Pi frequently gets the wrong IP address, even though the router should always be assigning it the right one. It usually (about 70% of the time) gets the right IP on boot, so clearly my static assignment is in effect - sort of. I've never seen this sort of issue with any device on my network before.
Last edited by gordon901823 on Tue Mar 22, 2016 3:38 am, edited 1 time in total.

gordon901823
Posts: 6
Joined: Sat Jan 23, 2016 9:13 pm

Re: Pi won't maintain static private IP

Mon Mar 21, 2016 7:14 pm

DougieLawson wrote:
Higgs wrote:Forget /etc/network/interfaces.

Edit/add to the end of the /etc/dhcpcd.conf file.
Put /etc/network/interfaces back to how it started

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
Put this stuff at the bottom of /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.14.11/24
static routers=192.168.14.1
static domain_name_servers=192.168.14.1 8.8.8.8
#
OK, giving this a try. So far it seems to be working fine, but we'll see if it sticks. Thanks.

Heater
Posts: 14294
Joined: Tue Jul 17, 2012 3:02 pm

Re: Pi won't maintain static private IP

Mon Mar 21, 2016 7:17 pm

The network configuration on Raspbian now is nothing like any other Linux installation I have seen. If you cooperate with it, it works fine. It's annoying to have to learn how to do that but there we go.
Memory in C++ is a leaky abstraction .

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: Pi won't maintain static private IP

Mon Mar 21, 2016 8:14 pm

gordon901823 wrote: For whatever reason, the Pi frequently gets the wrong IP address, even though the router should always be assigning it the right one. It usually (about 70% of the time) gets the right IP on boot, so clearly my static assignment is in effect - sort of. I've never seen this sort of issue with any device on my network before.
If you switch back and forth between wired and wireless they have different MAC addresses, that could be the problem. I know I sometimes use wireless, sometimes wired, on the same RPi depending on where I'm using it. And you won't be able to assign the same IP to two different MAC addresses in your router.

gordon901823
Posts: 6
Joined: Sat Jan 23, 2016 9:13 pm

Re: Pi won't maintain static private IP

Mon Mar 21, 2016 11:49 pm

JimmyN wrote:
gordon901823 wrote: For whatever reason, the Pi frequently gets the wrong IP address, even though the router should always be assigning it the right one. It usually (about 70% of the time) gets the right IP on boot, so clearly my static assignment is in effect - sort of. I've never seen this sort of issue with any device on my network before.
If you switch back and forth between wired and wireless they have different MAC addresses, that could be the problem. I know I sometimes use wireless, sometimes wired, on the same RPi depending on where I'm using it. And you won't be able to assign the same IP to two different MAC addresses in your router.
In my case, I have never even used the wireless interface, and it has never been connected to any network.

zealousd
Posts: 93
Joined: Sun Mar 20, 2016 10:57 am

Re: Pi won't maintain static private IP

Wed Mar 23, 2016 3:38 am

just stick with a network cable, it can manage a better flow of data.
Raspberry Pi 3
Ubuntu Mate
Web Server

Return to “General discussion”