I have a raspberry PI in a network where all clients get a DHCP IP address assigned automatically. DHCP-IPs are "192.168.0.X" with subnet mask ""

But for my raspberry (and other devices) I want to use a fixed IP address in another network. Desired IP "192.168.X.Y" with subnet mask ""

The raspberry should get the IP "" with subnet mask "".

My "/etc/network/interfaces" looks like

auto lo
iface lo inet loopback

iface eth0 inet static

This works ok so far, my raspberry gets the address "", but it also gets a DHCP address assigned (in my case "").

Output of "sudo ip addr show":

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:37:1d:30 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet brd scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:fe37:1d30/64 scope link
       valid_lft forever preferred_lft forever

But I want the raspberry to use my static address only. There should be no DHCP address.

Is there an error in my "interfaces" file? Can someone explain why I get a DHCP address although I configured a static address?

What do I have to change in my config file so that I don't get a DHCP address?

  • The netmask for that IP should be – schaiba Nov 20 '15 at 13:09
  • @schaiba Youre right, /24 would be the correct subnet, but in my case I have to use /16. But /24 would not make a difference to my "problem" – Boardwish Nov 20 '15 at 13:15

You are running a dhcpcd service that is giving you IP addresses no matter what the configuration you have.

imo you should not even have it installed, as dhclient normally does the job. (I am assuming Debian here, maybe I am a bit off) You probably installed it in substitution, so we won't be deinstalling it just in case in the future you define a dhcp enabled interface.

So we will be taking it out of boot configuration, and stopping it.

apt-get install chkconfig
chkconfig dhcpcd off
service dhcpcd stop

Would you please change /etc/network/interfaces it to:

auto eth0
iface eth0 inet static

And afterwards do a:

sudo service networking restart
  • I copied your config into my interfaces file and rebooted the raspberry. after booting the static ip works fine, but I again to have a DHCP ip... so there is no difference – Boardwish Nov 20 '15 at 13:44
  • It should not be happening. You must be calling dhclient somewhere else. Can you show me the output of "dpkg -l | grep dhcp" – Rui F Ribeiro Nov 20 '15 at 13:46
  • and also the output of "ps ax | grep dhclient" – Rui F Ribeiro Nov 20 '15 at 13:47
  • dpkg -l | grep dhcp: ii dhcpcd5 6.7.1-1+rpi3 armhf DHCPv4, IPv6RA and DHCPv6 client with IPv4LL support ii isc-dhcp-client 4.3.1-6 armhf DHCP client for automatically obtaining an IP address ii isc-dhcp-common 4.3.1-6 armhf common files used by all of the isc-dhcp packages ps ax | grep dhclient: 1023 pts/3 S+ 0:00 grep --color=auto dhclient – Boardwish Nov 20 '15 at 13:48
  • do a "ps ax | grep dhcp" please – Rui F Ribeiro Nov 20 '15 at 14:17

I found another solution where only a modification of the interfaces file is necessary:

Just added the following line at the end of the file:

iface default inet dhcp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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