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

Re: Set Static IP address but also getting Dynamic

Postby DougieLawson » Wed Oct 28, 2015 10:00 pm

Use the which command and the dpkg command.
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
ds18s20
Posts: 80
Joined: Fri Dec 23, 2011 5:44 am
Location: San Francisco

Re: Set Static IP address but also getting Dynamic

Postby ds18s20 » Thu Oct 29, 2015 1:57 pm

Got it. dpkg --list did it for me. Thanks:

Code: Select all

ii  isc-dhcp-client                       4.2.2.dfsg.1-5+deb70u6                 armhf        ISC DHCP client
User avatar
DougieLawson
Posts: 28479
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact:

Re: Set Static IP address but also getting Dynamic

Postby DougieLawson » Thu Oct 29, 2015 2:08 pm

That's not dhcpcd5. That's the old package that was superseded by 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.
kez
Posts: 1
Joined: Wed Jul 25, 2012 8:34 pm

Re: Set Static IP address but also getting Dynamic

Postby kez » Sat Oct 31, 2015 9:59 am

This problem was plaguing me for ages. dhcpcd5 simply seems to ignore the interfaces file so you have to set exclusions in the dhcpcd.conf file. Really quick and easy to do.

Try adding the line:

Code: Select all

denyinterfaces eth0
to /etc/dhcpcd.conf (change eth0 as required).

No need to make any extra changes in /etc/network/interfaces or uninstall anything.

man dhcpcd.conf for more info.

Sorry if I missed someone else posting this already or within a link to another post.

Kez
htodd
Posts: 2
Joined: Tue Nov 17, 2015 4:33 pm

Re: Set Static IP address but also getting Dynamic

Postby htodd » Tue Nov 17, 2015 4:45 pm

You can stop the client from starting at boot by......

# stop the dhcp client service
sudo /usr/sbin/update-rc.d dhcpcd stop

# clean up dhcp leases
sudo rm /var/lib/dhcp/*

# disable the service from running at startup
# you could substitute remove for disable if you like ot remove it permanently
sudo /usr/sbin/update-rc.d dhcpcd disable

reboot
hdoucet
Posts: 1
Joined: Tue Feb 09, 2016 9:04 pm

Re: Set Static IP address but also getting Dynamic

Postby hdoucet » Tue Feb 09, 2016 9:07 pm

For more information on setting IP addresses in RASPBIAN JESSIE "LITE" ..
See https://wiki.archlinux.org/index.php/dh ... ic_profile
User avatar
AndyWhittaker
Posts: 2
Joined: Sat Nov 23, 2013 7:28 am
Location: Macclesfield, UK
Contact:

Re: Set Static IP address but also getting Dynamic

Postby AndyWhittaker » Wed Mar 02, 2016 10:25 am

hdoucet wrote:For more information on setting IP addresses in RASPBIAN JESSIE "LITE" ..
See https://wiki.archlinux.org/index.php/dh ... ic_profile
Thanks, that worked for me.... I thought I was going crazy!

Andy
Andy Whittaker
Macclesfield, UK
http://www.ecufix.com/
flyvert
Posts: 10
Joined: Sun Jan 18, 2015 7:19 pm
Location: Vaesteraas, Sweden

Re: Set Static IP address but also getting Dynamic

Postby flyvert » Mon Mar 07, 2016 10:59 pm

THANKS!!!
If the tractor overturns, hold the steering wheel - do not jump!
Henry Sprog
Posts: 1
Joined: Wed Apr 20, 2016 5:51 pm

Re: Set Static IP address but also getting Dynamic

Postby Henry Sprog » Wed Apr 20, 2016 6:15 pm

Hi all
This has been driving me nuts. However if I had just read the manual page of dhcpcd.conf and its quite straight forward. For some reason setting a static address in interfaces has no effect apart from creating a static and DHCP ip addresses. To get over this you need to edit the file /etc/dhcpcd.conf and add the following to the bottom of the file:

interface eth0
static ip_address=192.168.0.7/24 # static address you want the pi to have
static routers=192.168.0.1 # the address of your dhcp server (normally your router)
static domain_name_servers=192.168.0.1 # same as above so it can use a DNS service

This will stop the DHCP server trying to obtain a lease and instead will use the static address with an infinite lease time.

Still you learn something new everyday. Today it was that you can have one interface with multiple addresses.

Hope this helps?
dubakdubak
Posts: 1
Joined: Mon Apr 25, 2016 10:10 am

Re: Set Static IP address but also getting Dynamic

Postby dubakdubak » Mon Apr 25, 2016 10:52 am

Hi,
this is driving me totally insane. How can it be so difficult to set just the static IP on the raspberry pi?
I've tried everything (disabling/deleting dhcpcd, dhcpcd5, raspberrypi-net-mods , isc-dhcp-client isc-dhcp-common ) and pretty much everything mentioned in this forum also concerning /etc/networking/interfaces
I've also tried the "nodhcp" in /etc/dhcpcd.conf
Whatever I do, I always end up with some bogus IPv6 address on my eth0, which I see in ifconfig
My /etc/network/interfaces looks like this:

iface eth0 inet manual
address 192.168.3.155
netmast 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.1
gateway 192.168.3.1

But whatever I write in /etc/network/interfaces is just ignored.

I'm really desperate!!
User avatar
KLL
Posts: 777
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact:

Re: Set Static IP address but also getting Dynamic

Postby KLL » Mon Apr 25, 2016 1:27 pm

dubakdubak wrote:How can it be so difficult to set just the static IP on the raspberry pi?
for some time now we use for static IP:
example i want for my RPI2: 102 ethernet cable, and 202 WIFI

sudo nano /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.1.102/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
interface wlan0
static ip_address=192.168.1.202/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1.
i still do change the
sudo nano /etc/network/interfaces

Code: Select all

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
wpa-ssid "aaaa"
wpa-psk "xxxx".
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
but only to fix the SSID there instead at wpa
but if possible use better dhcpcdui from desktop desktop
hippy
Posts: 2012
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Set Static IP address but also getting Dynamic

Postby hippy » Mon Apr 25, 2016 3:15 pm

dubakdubak wrote: My /etc/network/interfaces looks like this:

iface eth0 inet manual
If you want to set a static IP address in /etc/network/interfaces you need "iface eth0 inet static", but you may also need to prevent dhcpcd from also getting an IP address.

Or, the recommended way for most cases, is to use "iface eth0 inet manual" and then set the static IP address through dhcpcd configuration, not in /etc/network/interfaces.
cpc464
Posts: 171
Joined: Tue Jul 08, 2014 5:10 pm
Contact:

Re: Set Static IP address but also getting Dynamic

Postby cpc464 » Fri Apr 29, 2016 10:38 am

I also had the two IP addresses on the same interface problem. In case it helps anyone, this fixed it for me:

Code: Select all

# systemctl disable dhcpcd.service 
Synchronizing state for dhcpcd.service with sysvinit using update-rc.d...
Executing /usr/sbin/update-rc.d dhcpcd defaults
Executing /usr/sbin/update-rc.d dhcpcd disable
insserv: warning: current start runlevel(s) (empty) of script `dhcpcd' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `dhcpcd' overrides LSB defaults (0 1 6).
Followed by a reboot. "ip addr" before and after showed that eth0 had the two IP addresses before (DHCP and static) but just one after (static), which is what I wanted. Also during the reboot I monitored the log on my BT Home Hub. Whereas before it would report DHCP requests from the Pi, none were reported after the change. Also after the above change, the dhcpcd daemon was no longer running.
Unix engineer since 1989
shinnra
Posts: 1
Joined: Fri Nov 04, 2016 10:28 am

Re: Set Static IP address but also getting Dynamic

Postby shinnra » Fri Nov 04, 2016 10:36 am

I just went back from ArchLinux to Raspbian (lite version) and that was annoying as this was messing my pi router. My solution was to disable dhcpcd service:

Code: Select all

systemctl stop dhcpcd
systemctl disable dhcpcd
and then create template service:
/etc/systemd/system/dhcpcd@.service:

Code: Select all

[Unit]
Description=DHCPCD service for %I
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=forking
PIDFile=/run/dhcpcd-%I.pid
ExecStart=/sbin/dhcpcd -q -b %I
ExecStop=/sbin/dhcpcd -x %I

[Install]
WantedBy=multi-user.target
this way I can do something like this:

Code: Select all

systemctl enable dhcpcd@eth0
systemctl start dhcpcd@eth0
and dhcpcd will request IP only for eth0
Human_Robot
Posts: 1
Joined: Sat Nov 26, 2016 3:09 pm

Re: Set Static IP address but also getting Dynamic

Postby Human_Robot » Sat Nov 26, 2016 3:15 pm

I fought the static IP battle for a while, I used the nodhcp in /etc/dhcpcd.conf and added the static settings in /etc/network/interfaces
I would get a 169.X.X.X address (instead of the 192.168.X.X address I tried to use)

The fix was to leave off the network X.X.X.X and broadcast X.X.X.X setting in interfaces. Using these settings always seemed unnecessary to me since the OS should be able to figure them out without you defining them.

Do not use network X.X.X.X
Do not use broadcast X.X.X.X

Hope this helps,
User avatar
ds18s20
Posts: 80
Joined: Fri Dec 23, 2011 5:44 am
Location: San Francisco

Re: Set Static IP address but also getting Dynamic

Postby ds18s20 » Wed Dec 07, 2016 4:04 pm

So it sounds like either disable dhcpd5 or even remove its package, then interfaces would behave as expected for static config scenarios