griopas
Posts: 5
Joined: Fri May 15, 2015 2:16 am

Pi2 gets static IP but also DHCP IP is assigned

Fri May 15, 2015 9:03 am

I have set-up Pi2 through NOOBS and setup for static ip. The device gets assigned the static ip but also receives a secondary dhcp address!! I can access the device by both!! How can I stop it from rebinding to the old dhcp IP?

Towards the end of booting it gives:
dhcpcd[2052]: eth0: rebinding lease of 10.1.1.52
My IP address is 10.1.1.11 10.1.1.52


The /etc/network/interfaces content is :
# The loopback interface
auto lo
iface lo inet loopback

auto eth0
# allow-hotplug eth0
# iface eth0 inet manual
iface eth0 inet static
# my static ip
address 10.1.1.11
# my gateway IP
gateway 10.1.1.1
netmask 255.255.255.0
# my network address "family"
network 10.1.1.0
broadcast 10.1.1.255


I would appreciate your help with this funny thing!!!

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

Re: Pi2 gets static IP but also DHCP IP is assigned

Fri May 15, 2015 11:00 am

Can you post the results from
ifconfig -a
ip show addr
ip route

Also try deleting anything you find in /var/lib/dhcpd [I think the DHCP stuff goes there.]
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.

griopas
Posts: 5
Joined: Fri May 15, 2015 2:16 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Fri May 15, 2015 11:44 am

Hi DL
Tx for your help. Here it is :

----------------------------------------
ifconfig -a
eth0 Link encap:Ethernet HWaddr b8:27:eb:b1:25:ea
inet addr:10.1.1.11 Bcast:10.1.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:861 errors:0 dropped:25 overruns:0 frame:0
TX packets:176 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:72156 (70.4 KiB) TX bytes:20785 (20.2 KiB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

----------------------------------------
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether b8:27:eb:b1:25:ea brd ff:ff:ff:ff:ff:ff
inet 10.1.1.11/24 brd 10.1.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet 10.1.1.52/24 brd 10.1.1.255 scope global secondary eth0
valid_lft forever preferred_lft forever

----------------------------------------
ip route
default via 10.1.1.1 dev eth0
default via 10.1.1.1 dev eth0 metric 202
10.1.1.0/24 dev eth0 proto kernel scope link src 10.1.1.52 metric 202

There was no "var/lib/dhcpd" directory, but one called "dhcp" and another "dhcpcd5". I erased "dhcpcd5/dhcpcd-eth0.lease" but on reboot it asked again for a new DHCP IP on top of my static assigned one.

Gregory

mmmi
Posts: 1
Joined: Thu May 14, 2015 3:43 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Sat May 16, 2015 5:58 am

+1 here

I've even go to extent of deleting completely /etc/network/interfaces with no difference, raspberry is obstinate in getting a DHCP lease via eth0.


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

Re: Pi2 gets static IP but also DHCP IP is assigned

Sat May 16, 2015 8:45 pm

Get rid of the "network" and "broadcast" lines in /etc/network/interfaces they aren't needed.
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.

griopas
Posts: 5
Joined: Fri May 15, 2015 2:16 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun May 17, 2015 12:51 am

have done so, but no change. Reading from the other fellow above can this be a persistent rasbian bug?

G.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun May 17, 2015 2:23 am

At this point, there is the usual split in terms of where the thread is heading.

Are you just interested in coming up with a fix/workaround, or are you interested in flagging it as a general bug?

If the former, then the best solution is to disable the built-in networking, and do it yourself in code. The steps are (from the terminal, as root; when you get it working, throw it in /etc/rc.local or whatever):
  1. update-rc.d networking disable
  2. reboot
  3. ifconfig eth0 192.168.whatever.whatever
  4. route add default gw 192.168.whatever.1
Last edited by Joe Schmoe on Sun May 17, 2015 8:31 am, edited 1 time in total.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

griopas
Posts: 5
Joined: Fri May 15, 2015 2:16 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun May 17, 2015 8:27 am

Joe Schmoe wrote:At this point, there is the usual split in terms of where the thread is heading.

Are you just interested in coming up with a fix/workaround, or are you interested in flagging it as a general bug?

If the former, then the best solution is to disable the built-in networking, and do it yourself in code. The steps are (from the terminal, as root; when you get it working, throw it in /etc/rc.local or whatever):
  • update-rc.d networking disable
  • reboot
  • ifconfig eth0 192.168.whatever.whatever
  • route add default gw 192.168.whatever.1
Hey thnx!, no hidden intentions here, just aiming to fix this.
I am not that skilled, so can you get this a bit more detailed? Does this sequence of commands produce a file which i will throw in /etc/rc.local ???
Cheers, G.

badhairday
Posts: 1
Joined: Wed May 20, 2015 6:22 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Wed May 20, 2015 6:39 pm

I am having the same problem. Configured the Raspberry Pi with a static IP.

Code: Select all

auto lo
iface lo inet loopback

#auto eth0
#allow-hotplug eth0
iface eth0 inet static
address 172.16.100.35
netmask 255.255.255.0
gateway 172.16.100.254
#manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Now that it is headless and a hour away I see that I am also getting a DHCP assigned IP to eth0. I tried

Code: Select all

:/home/chris# dhcpcd -S ip_address=172.16.100.35/24 -S routers=172.16.100.254 -S domain_name_servers = 172.16.100.110 eth0

And got
dhcpcd[6569]: static assignment required
How can I get it to stop requesting a dynamic address?

Thanks,
Chris

ben2202
Posts: 2
Joined: Thu May 21, 2015 12:40 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Thu May 21, 2015 1:02 pm

Hello,
i have 1 good news, 1 bad news and maybe a solution :)
1) you have a blank space in your command between domain name server and equal and again between equal and your ip address :
dhcpcd -S ip_address=172.16.100.35/24 -S routers=172.16.100.254 -S domain_name_servers_space_=_space_172.16.100.110 eth0

if you enter this command without blank Space you don't have the message about "static assignment required"
2) But the bad new is this doesn't work to have a static ip address :(
3) I have maybe a solution by editing your /etc/dhcpcd.conf and add the resevation at this end like this :

Code: Select all

interface eth0
static ip_address=192.168.0.210
static routers=192.168.0.254
static domain_name_servers=192.168.0.254
static domain_search =
and reboot

This is a reverse engineering by make the configuration with gui and search the configuration.
regards,
Ben

dmatzen
Posts: 2
Joined: Fri Oct 02, 2015 7:22 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Fri Oct 02, 2015 7:54 pm

I found the answer in a related post.


viewtopic.php?f=63&t=110606

by xelius » Wed Sep 02, 2015 10:26 pm
I got this solved by editing /etc/network/interfaces as usual and added the line below to /etc/dhcpcd.conf

denyinterfaces eth0

ashishbajaj99
Posts: 4
Joined: Thu Dec 24, 2015 7:45 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Thu Dec 24, 2015 8:19 am

The best solution I've seen is:
1. Leave the Raspbian system configurations in /etc/network/interfaces remain unchanged as it came from the download
2. Modify the wpa-supplicant.conf file with your WiFi details (or use the GUI to set this up if you're more comfortable with that)

With the above 2 steps you should be able to allocate a DHCP IP address to your Rasp-Pi. To configure the Rasp-Pi with a static IP address, just configure your router with DHCP reservations for your Rasp-Pi.

Use

Code: Select all

ifconfig
to get your MAC address that is needed to configure your router. Example of how to setup the Apple Time capsule can be found here: http://www.macinstruct.com/node/553

You should be able to find this for all the other routers in the market as well. Super slick and works like a charm! Enjoy.

jeffvader
Posts: 2
Joined: Sun Jan 03, 2016 1:49 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun Jan 03, 2016 1:59 am

Hey ppl :)

I been getting this same issue and I have found a solution to this problem.
My solution/workaround is to remove the symlink for DHCPCD so that it doesn't start at boot. Simple :D

You will need to go into the directory: "/etc/rc2.d/" or "/etc/rc5.d" and delete the symlink for: "dhcpcd". (My symlink was called "S01dhcpcd".)

If you are running the Pi in non-graphical mode:
Use these commands as root (as all things with using root, please be careful):
cd /etc/rc2.d/
ls -l (find the link that points to: "/etc/init.d/dhcpcd". Mine was called "S01dhcpcd".)
rm S01dhcpcd

Now reboot and you should be ok. You won't get an IP address with dhcp because the dhcp-client is no longer running at boot.

If you are running the Pi in graphical mode, substitute "rc2.d" for "rc5.d".

Hope this works for you and helps :D

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

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun Jan 03, 2016 11:03 am

Wrong answer and what you've suggested will break systems and leave them without an active network.

The fix (as can be seen if you bothered to search for this with Google) is to define every interface as "manual" in your /etc/network/interfaces file and define the static addresses in /etc/dhcpcd.conf

It is not done by ripping dhcpcd out of the startup folders without using the update-rc.d program.
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.

usermod
Posts: 1
Joined: Sun Jan 03, 2016 8:11 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun Jan 03, 2016 8:28 pm

Rpi2 running Jessie (2015-11-21)

Ran across this "bug" recently, I had no need for DHCP so I resolved the issue by....

adding the following to /etc/network/interfaces

auto eth0
iface eth0 inet static
address 192.168.1.161
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4


then adding the following to /etc/dhcpcd.conf

denyinterfaces eth0

Worked for me, hope it helps...

jeffvader
Posts: 2
Joined: Sun Jan 03, 2016 1:49 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun Jan 03, 2016 8:44 pm

Well it worked for me.
...and thanks for being a dick about it. (sarcasm)

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

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun Jan 03, 2016 9:39 pm

jeffvader wrote:Well it worked for me.
...and thanks for being a **** about it. (sarcasm)
The trouble is that you've effectively undone everything that was added with the raspberrypi-net-mods package. Suggesting that will break systems, it's not hard to do it the right way.

Replying to ancient threads doesn't help anyone.
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.

devonnull
Posts: 1
Joined: Sun Jan 24, 2016 4:59 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun Jan 24, 2016 4:40 pm

The behavior is definitely not optimal. In my case, I already had webmin installed and just disabled the luckily detected dhcpcd 'service' it was detecting. Considering that the package for dhcpcd is not installed when you go to purge it, it does present quite a bit confusion. Then you're wondering if something has been compromised, but when you run ifconfig on that server you only see 1 address, unless you use the "new" way, "ip addr show", to get that info. Considering for years if you have something listed as "static" in /etc/network/interfaces, it ignores any DHCP requests for that interface. Raspbian is based on Debian, and dhcpcd isn't part of the standard Debian install, it uses dhcp3-client (as of 7.x which I know is "old") on a non GUI install. So it would stand to reason that it would follow that convention however it doesn't appear to.

Chris_G_Miller
Posts: 23
Joined: Sat Nov 14, 2015 3:45 pm
Location: Kent, England

Re: Pi2 gets static IP but also DHCP IP is assigned

Tue Apr 05, 2016 5:17 pm

I too fell slightly foul of dhcpcd (not to be confused with dhcpd - which I was, for several minutes)
I too am doing "headless" stuff so need complete control over the IP addressing, and sometimes on networks where DHCP cannot be relied on to do this via reservations.
And to make it even more confusing for me, I'm really a Redhat man, rather than Debian!

BUT After reading tfm, I discovered that it no longer appears to be possible to set static IPs in the file /etc/network/interfaces.

Instead, this now needs to be done in /etc/dhcpcd.conf by adding lines like this at the end:

Code: Select all

# Set a static IP address on eth0
interface eth0
static ip_address=192.168.100.56
static routers=192.168.100.1
static domain_name_servers=192.168.100.200

Blcksheep
Posts: 1
Joined: Sun May 08, 2016 4:47 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Sun May 08, 2016 5:10 pm

Installed jessie on a new Pi and was struggling with the same issue and ended up here. Took a glance at the dhcpcd.conf manual and decided to add following lines to it:

interface eth0
static ip_address=

So leaving the actual address empty and gave it a try. Left my original configuration in the /etc/network/interfaces file intact. Now I get my fixed and only 1 ip-address again as defined in the interfaces file. Just as I am used to on my other Pi's running wheezy. This is likely not how it is intended but it works anyway. On a personal note, I find having parts of the network configuration specifics spread over various configuration files in different places not very user friendly.... :-(

metzz71
Posts: 23
Joined: Wed Jan 20, 2016 12:04 am

Re: Pi2 gets static IP but also DHCP IP is assigned

Tue May 10, 2016 7:43 pm

Is this truly a bug? If not, what is the proper way to set a static IP address? The methods I have tried have not been working thus far.

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

Re: Pi2 gets static IP but also DHCP IP is assigned

Tue May 10, 2016 8:00 pm

The proper way with Jessie is
1. Leave /etc/network/interfaces exactly as supplied
2. Update /etc/dhcpcd.conf with the static stuff (as above)
3. Add wifi networks to /etc/wpa_supplicant/wpa_supplicant.conf (or use the WiFi GUI)

It's a bit quirky (you could call it completely wrong), but that was a decision made by the Raspberry Pi Foundation folks to make network configuration easier for the folks coming to a Linux GUI from Windows. I don't like it, but it works for my RPis.

If you can set static addresses by using your router's configuration pages use that instead.
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.

jayminer
Posts: 44
Joined: Sun Jul 07, 2013 3:33 pm

Re: Pi2 gets static IP but also DHCP IP is assigned

Tue May 17, 2016 7:31 am

If this is the (totally wrong IMO) way they intend for this to work, there really should be some information about it in the interfaces file. Something simple like
# Do not edit this file, if you want to configure a static IP edit dhcpcd.conf

Because this will be an issue for lots of people.

reinhardtjh
Posts: 3
Joined: Wed Jun 01, 2016 3:41 pm
Location: Southwest Ohio, USA

Re: Pi2 gets static IP but also DHCP IP is assigned

Thu Jun 23, 2016 5:19 am

jayminer wrote: Because this will be an issue for lots of people.

Like me... lol I lost 2 days working with Raspbian Jesse on my Pi Model B. See Raspbian Jessie VLAN dhcpd I finally got smart and concentrated on this message board for answers rather than general Debian searches. Now I know about the new rules but it would have been nice if someone had put such a warning line in the interfaces file.

Oh well, onward to other battles.
John H. Reinhardt

Return to “Networking and servers”