My Raspberry Pi B+ is running Raspbian (Linux version 3.18.11+) updated, etc.

It's connected to the network by ethernet. I want a static IP, and have assigned it one in /etc/network/interfaces (shown below). However, every boot it requests an address via DHCP and is assigned one! Both the static and dynamic addresses work to access the machine on the network.

Where can I stop the DHCP address from being requested and assigned??

/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.7
netmask 255.255.255.0
gateway 192.168.1.1

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

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:44:bb:23 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.7/24 brd 192.168.1.255 scope global eth0
   valid_lft forever preferred_lft forever
inet 192.168.1.55/24 brd 192.168.1.255 scope global secondary eth0
   valid_lft forever preferred_lft forever

ifconfig

eth0      Link encap:Ethernet  HWaddr b8:27:eb:44:bb:23  
          inet addr:192.168.1.7  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11484 errors:0 dropped:4 overruns:0 frame:0
          TX packets:10212 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4178807 (3.9 MiB)  TX bytes:4019638 (3.8 MiB)

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)

wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
  • Can you tell us output of ifconfig ? – dhruvvyas90 Jun 15 '15 at 3:36
  • added ifconfig above – t0vana Jun 15 '15 at 4:13
  • My bad. I meant "ifconfig -a". Can you modify your log above ? – dhruvvyas90 Jun 15 '15 at 4:16
  • The output with the -a flag is identical to above. – t0vana Jun 15 '15 at 4:43
  • What's is the content of wpa_supplicant.conf ? – Tyson Jun 16 '15 at 1:51
up vote 8 down vote accepted

I had this same issue.

I assume you are using 2015-05-05 build of Rasbian. In this build, the static IP is set in /etc/dhcpcd.conf.

You should:

  1. Revert your changes in /etc/network/interfaces back to default
  2. Put the ip information in your /etc/dhcpcd.conf to configure a static IP, replacing whatever your interface is for wlan0
  3. Reboot

--

# what I did
# this goes in /etc/dchpcd.conf for static ip assignment 
interface wlan0
 static ip_address=10.3.2.8/24
 static routers=10.3.2.1
 static domain_name_servers=8.8.8.8

before

$ ip addr
.... <snip>
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether e8:4e:06:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 10.3.2.8/24 brd 10.3.2.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet 10.3.2.101/24 brd 10.3.2.255 scope global secondary wlan0
       valid_lft forever preferred_lft forever

after

$ ip addr
.... <snip>
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether e8:4e:06:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 10.3.2.8/24 brd 10.3.2.255 scope global wlan0
       valid_lft forever preferred_lft forever

These links are where I found my answer:

  • Thank you, success! I did have to remember to set eth0 to the new default of manual instead of the old default of dhcp in /etc/network/interfaces – t0vana Aug 31 '15 at 18:31

Looking at the Debian Network Configuration documentation and other documentation online, my understanding is that allow-hotplug is only necessary for removable network adapters, or if you're using dhcp on an adapter that might not be present at boot in order to avoid long dhcp timeouts. Try removing the allow-hotplug eth0 line if you're using a static configuration.

I tried replicating your problem with several variations, but only obtained a single IP address as show with ip addr. Do you by any chance have anything under the various /etc/network/if-* directories?

  • if-down.d: openvpn resolvconf upstart wpasupplicant if-post-down.d: avahi-daemon wireless-tools wpasupplicant if-pre-up.d: wireless-tools wpasupplicant if-up.d: 000resolvconf avahi-daemon mountnfs openssh-server openvpn upstart wpasupplicant – t0vana Jun 16 '15 at 4:18
  • commenting out the allow-hotplug eth0 line has no effect – t0vana Jun 16 '15 at 6:31

Another thing you could do to get a static IP (without all that) is to first find you MAC address by typing this:

ifconfig eth0

and looking for HWaddr (and after that is your mac address). After that go onto your router admin page and go to DHPC or IP reservations (on my router it was in LAN setup). Then add the MAC address and choose and IP. You don't have to add the MAC address as most router's have the option to just pick the IP (the name will be the name you set in raspi-config hostname).

Will :3

ask questions

  • I put the command ifconfig eth0 for other users (I know you know) – Panda Jun 15 '15 at 18:23
  • That's a great (round-about) solution to this: adding the MAC address to the router's DHCP reservations. However, that won't work for this setup... – t0vana Jun 16 '15 at 4:12
  • Yeh sorry, I just put it just in case you hadnt' thought of it ;) – Panda Jun 19 '15 at 20:08

I had the same problem. I had configured x.x.x.250 in /etc/network/interfaces and was getting x.x.x.20 as well, although that did not exist anywhere.

I'm using ethernet and because I don't need dhcp I disabled the dhcpcd service as follows:

sudo systemctl stop dhcpcd
sudo systemctl disable dhpcd
sudo systemctl daemon-reload
sudo systemctl restart networking

(Note that if you're doing this over SSH as I was, then the last command will probably hang your SSH. So ~.Enter to get a functioning local command prompt back then ssh in again.

This seems to have worked for me.

  • The dhcp package could probably be purged too if you're not going to put the static IP in /etc/dhcpcd.conf – FlippingBinary Jan 5 '17 at 15:03
  • i had the same problem. but did not want to delete the dhcpcd service. so i shutdown the raspi, pulled of the power cable, and started it again. the previously dynamically assigend ips finally disappeared. – lsblsb Nov 11 at 13:38

Here is the solution to configure multiple interfaces:Multiple IP addresses on one Interface.

  • 1
    Can you edit your answer to summarise the contents of the link, in case of future link death. Thanks. – Greenonline Nov 18 '15 at 16:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.