Set Static IP address but also getting Dynamic


41 posts   Page 1 of 2   1, 2
by klavo » Thu May 28, 2015 2:10 am
Hi All,

I have configured the network card to have a static IP address which is assigned to the card but for some reason I am also getting an additional IP address from the DHCP server. This means I have 2 IP addresses bound to the network card.

I have downloaded the latest raspbian image and applied all updates including the Raspberry Pi firmware

# apt-get update
# apt-get -y upgrade
# apt-get -y dist-upgrade
# apt-get -y autoclean

I am completely at a loss here and any help would be greatly appreciated.

# cat /etc/network/interfaces
auto lo
auto eth0

iface lo inet loopback

iface eth0 inet static
address 192.168.17.252
netmask 255.255.255.0
network 192.168.17.0
broadcast 192.168.17.255
gateway 192.168.17.254


# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether b8:27:eb:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.17.252/24 brd 192.168.17.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.17.107/24 brd 192.168.17.255 scope global secondary eth0
valid_lft forever preferred_lft forever
Posts: 3
Joined: Thu May 28, 2015 1:58 am
Location: Brisbane, Australia
by rpdom » Thu May 28, 2015 6:21 am
This happens in the latest updates. It is caused by the new dhcp client ignoring what the interfaces files does and doing its own thing in addition... seems crazy to me. I'd look at how to reconfigure the dhcp client (can't rememeber which it is or how to do it, I'm still on the old one which works for me), disabling it, or removing it (if possible).
User avatar
Posts: 10290
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by klavo » Fri May 29, 2015 12:07 am
Thanks for the info. I din't think about looking at a dhcp client. I tried removing isc-dhcp-client and isc-dhcp-common with no success.

I then removed dhcpcd5 which required the removal of raspberrypi-net-mods which I was not too keen on until I saw other posts recommending it.

After removing dhcpd5 and raspberrypi-net-mods I now only get the static IP address. I'm not sure if isc-dhcp-client and isc-dhcp-common is also required to be removed.
Posts: 3
Joined: Thu May 28, 2015 1:58 am
Location: Brisbane, Australia
by rpdom » Fri May 29, 2015 5:56 am
klavo wrote:I then removed dhcpcd5 which required the removal of raspberrypi-net-mods which I was not too keen on until I saw other posts recommending it.

After removing dhcpd5 and raspberrypi-net-mods I now only get the static IP address. I'm not sure if isc-dhcp-client and isc-dhcp-common is also required to be removed.

You don't need to remove the isc-dhcp-* packages, but if you are using a static IP your won't need them anyway.

It's the dhcpd5 which causes the problems.
User avatar
Posts: 10290
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by sgon00 » Sat May 30, 2015 6:40 pm
Hi, I met the same problem. I am a newbie to Pi. Is there a bug opened for this issue? Where to open bugs? When will this problem get fixed? thanks a lot.
Posts: 1
Joined: Sat May 30, 2015 6:37 pm
by humberian » Sat Jun 06, 2015 11:08 pm
I did not have dhcpd5 installed but removed the raspberrypi-net-mods..unfortunately. no improvement. I am still getting two IP, one static one dynamic on eth0
Since I am using the box as OpenVPN server, I am not sure if I can go ahead and remove some of the dhcp packages without breaking the IP address pool for vpn clients.

busybox - Tiny utilities for small and embedded systems
dhcpdump - Parse DHCP packets from tcpdump
isc-dhcp-client - ISC DHCP client
isc-dhcp-client-dbg - ISC DHCP client (debugging symbols)
isc-dhcp-server - ISC DHCP server for automatic IP address assignment
isc-dhcp-server-dbg - ISC DHCP server for automatic IP address assignment (debug )
isc-dhcp-server-ldap - DHCP server able to use LDAP as backend
libtext-dhcpleases-perl - Perl module to parse DHCP leases file from ISC dhcpd
udhcpd - Provides the busybox DHCP server implementation
Posts: 20
Joined: Sun Mar 22, 2015 7:57 pm
by macaan » Mon Jun 08, 2015 9:16 am
I have the same issue with my raspberry PI B+

I have configured static ip on /etc/network/interfaces and looks like this

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0

iface eth0 inet static
address 192.168.1.115
netmask 255.255.255.0
gatway 192.168.1.1
broadcast 192.168.1.255
network 192.168.1.0

auto wlan0


but when I boot up the pi, it shows me two ip addresses check the screenshot

Image

ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether b8:27:eb:ea:bd:ec brd ff:ff:ff:ff:ff:ff
inet 192.168.1.115/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.1.120/24 brd 192.168.1.255 scope global secondary eth0
valid_lft forever preferred_lft forever
Posts: 9
Joined: Tue Jun 02, 2015 9:04 am
by macaan » Mon Jun 08, 2015 11:23 am
klavo wrote:Hi All,

I have configured the network card to have a static IP address which is assigned to the card but for some reason I am also getting an additional IP address from the DHCP server. This means I have 2 IP addresses bound to the network card.

I have downloaded the latest raspbian image and applied all updates including the Raspberry Pi firmware

# apt-get update
# apt-get -y upgrade
# apt-get -y dist-upgrade
# apt-get -y autoclean

I am completely at a loss here and any help would be greatly appreciated.

# cat /etc/network/interfaces
auto lo
auto eth0

iface lo inet loopback

iface eth0 inet static
address 192.168.17.252
netmask 255.255.255.0
network 192.168.17.0
broadcast 192.168.17.255
gateway 192.168.17.254


# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether b8:27:eb:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.17.252/24 brd 192.168.17.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.17.107/24 brd 192.168.17.255 scope global secondary eth0
valid_lft forever preferred_lft forever




Guys,

I got the solution from the member "DOUGIE"

Code this

auto lo
iface lo inet loopback

auto eth0
# allow-hotplug eth0

iface eth0 inet static
address 192.168.x.x
netmask 255.255.255.0 # or netmask 24
gateway 192.168.x.x # note the change from gatway to gateway


# auto wlan0


replace x with your network ip scheme.
Last edited by macaan on Sun Jun 21, 2015 6:39 am, edited 1 time in total.
Posts: 9
Joined: Tue Jun 02, 2015 9:04 am
by humberian » Mon Jun 08, 2015 2:19 pm
I can confirm, masking out auto hotplug removed the obsolete dhcp address.

Silght correction..
After reboot, the obsolete dhcp address does not respond anymore but..
arp -v shows

Address HW Type HW Address Flag Mask Iface
xxx.xxx.xx.78 ether (incomplete) eth0
xxx.xxx.xx.34 ether (incomplete) eth0

none of which can be reached. The .34 address was the former dhcp address and the static address (which is working) is not showing up in the list.
Posts: 20
Joined: Sun Mar 22, 2015 7:57 pm
by DougieLawson » Mon Jun 08, 2015 3:39 pm
Are you able to ping your gateway?

What does
ip addr show
ip route show
give you?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 26055
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by humberian » Sat Jun 20, 2015 8:54 pm
DougieLawson wrote:Are you able to ping your gateway?

What does
ip addr show
ip route show
give you?


Yes I can ping the gateway..

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:b9:11:qn brd ff:ff:ff:ff:ff:ff
inet 192.168.77.21/24 brd 192.168.77.255 scope global eth0
valid_lft forever preferred_lft forever
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 100
link/none
inet 10.99.99.8 peer 10.99.99.9/32 scope global tun0
valid_lft forever preferred_lft forever

ip route show

default via 192.168.77.1 dev eth0
default via 192.168.77.1 dev eth0 metric 202
10.99.99.0/24 via 10.99.99.2 dev tun0
10.99.99.2 dev tun0 proto kernel scope link src 10.99.99.1
192.168.77.0/24 dev eth0 proto kernel scope link src 192.168.77.2
192.168.77.0/24 dev eth0 proto kernel scope link src 192.168.77.2 metric 202
Posts: 20
Joined: Sun Mar 22, 2015 7:57 pm
by DougieLawson » Mon Jun 22, 2015 7:49 am
Your Raspberry Pi only has one address in the 192.168.77.0/24 subnet. (And a different one for the VPN tunnel.)

Can you ping 192.168.77.1?
Can you ping 8.8.8.8?
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 26055
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by humberian » Mon Jun 22, 2015 7:29 pm
DougieLawson wrote:Your Raspberry Pi only has one address in the 192.168.77.0/24 subnet. (And a different one for the VPN tunnel.)

Can you ping 192.168.77.1?
Can you ping 8.8.8.8?


Yes, that is working, I could not ping the DHCP address of eth0 anymore but essentially, the only issue appart from that is that eth0 has a 2nd IP assigned (DHCP) 77.21 DHCP / 77.2 Static and I did not find a way to get rid of the DHCP address even with removing the dhcp packages as suggested.
Posts: 20
Joined: Sun Mar 22, 2015 7:57 pm
by DougieLawson » Mon Jun 22, 2015 8:32 pm
humberian wrote:Yes, that is working, I could not ping the DHCP address of eth0 anymore but essentially, the only issue appart from that is that eth0 has a 2nd IP assigned (DHCP) 77.21 DHCP / 77.2 Static

There's only ONE address in the stuff you posted

192.168.77.0/24 dev eth0 proto kernel scope link src 192.168.77.2
192.168.77.0/24 dev eth0 proto kernel scope link src 192.168.77.2 metric 202
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 26055
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by hutauf » Tue Jul 14, 2015 7:17 pm
Hey,

I just fixed this issue for me, I had to deinstall "dhcpcd5", not "dhcpd5". Uninstalling this removed the /etc/network/interfaces, so make sure to backup it first and then replace it again after the deinstallation, otherwise your pi won't connect to any network which can be a pain in the .. if it is headless...

These are the commands:

sudo su
cp /etc/network/interfaces /etc/network/interfacesbackup
apt-get purge dhcpcd5
[accept with yes]
cp /etc/network/interfacesbackup /etc/network/interfaces
reboot

E voila, only 1 IP address left!

Good luck!
Posts: 2
Joined: Tue Jul 14, 2015 6:44 pm
by KLL » Wed Jul 15, 2015 7:09 am
good, but can you pls. tell us, is now the "dhcpcdui" network icon top right
still working? like for to connect WIFI?
i hate it because it constantly shows the wrong ( very first ?) eth0 address instead of my active/working "FIX IP"
but it is nice for WIFI.
Posts: 513
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
by hutauf » Wed Jul 15, 2015 7:14 pm
I do have this Icon and it says "dhcpcd is not running". I only use ethernet, so I don't need this icon. My other raspi, which is connected via wifi, is headless, so I don't have an icon there either. Sorry, I can't help you with this.
Posts: 2
Joined: Tue Jul 14, 2015 6:44 pm
by troccolino » Thu Jul 23, 2015 4:49 pm
Hi All,

I have two raspberry one with raspbian 2015-02-16 and the other with the last raspbian 2015-05-05.
I'm experiencing the same problem of two IP addresses (one static and the other DHCP) only on the one with raspbian 2015-05-05.

Code: Select all
    inet 192.168.0.19/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 192.168.0.163/24 brd 192.168.0.255 scope global secondary eth0
       valid_lft forever preferred_lft forever

Since there is no a real fix, reinstalling raspbian using the previous version (2015-02-16) solves the issue?
Posts: 2
Joined: Thu Jul 23, 2015 4:42 pm
by RichBrown » Mon Aug 10, 2015 9:22 am
Good Day Everyone,
I have tried the commenting out the hotplug command with no help. I really don't like to have to remove anything from a a clean install. Even if and when its "fully" removed, just doesnt give that warm and fuzzy feeling... Can anyone verify if this is fixed in the latest download? I must make a suggestion to this pi.org site.You list the release date of the image... but there are updates happening in front of that date! Please either ammend a new date when updates happen or add a field when last updated and it might be nice if this was a link to what was updated?? Having said that, I must thank you for all your hard work guys, its still a great image :) just please fix this network issue.

Best Regards,

Rich Brown
Posts: 4
Joined: Fri Jul 10, 2015 5:09 pm
by KLL » Mon Aug 10, 2015 12:59 pm
pls read https://www.raspberrypi.org/forums/viewtopic.php?p=798866#p798866
no network issue to fix, only that we did not know that now we have to use
/etc/dhcpcd.conf for using a fix IP, instead of interfaces.
Posts: 513
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
by spdugg01 » Mon Sep 28, 2015 11:26 am
I had the same problem, to fix it I did not remove anything, I simply disabled the dhcp client service as follows :-

sudo update-rc.d dhcpcd remove (this does not remove the service, it just stops it from automatically starting at startup)

you can then re-enable it at any time with the following:-

sudo update-rc.d dhcpcd defaults
Posts: 1
Joined: Mon Sep 28, 2015 11:21 am
by smith666 » Sat Oct 24, 2015 3:52 pm
I fixed the problem just by adding the following command into /etc/dhcpcd.conf
nodhcp

and in file /etc/network/interfaces must change the lines in the following way:

#iface lo inet loopback

#auto eth0
Posts: 1
Joined: Sat Oct 24, 2015 3:48 pm
by ds18s20 » Wed Oct 28, 2015 2:40 pm
What's the easiest way to identify whether one has DHCPCD5 installed or not?

I have 3 installed and do not see 5 on neither:

Code: Select all
Linux raspberrypi 3.12.20+ #686 PREEMPT Tue May 27 15:48:33 BST 2014 armv6l GNU/Linux

nor

Linux raspberrypi 4.1.6+ #810 PREEMPT Tue Aug 18 15:19:58 BST 2015 armv6l GNU/Linux

User avatar
Posts: 74
Joined: Fri Dec 23, 2011 5:44 am
Location: San Francisco
by DougieLawson » Wed Oct 28, 2015 2:52 pm
which dhcpcd5
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 26055
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by ds18s20 » Wed Oct 28, 2015 8:45 pm
oops I meant the client... the one which seems to be the source of double IP business when people setup static addresses
User avatar
Posts: 74
Joined: Fri Dec 23, 2011 5:44 am
Location: San Francisco