Search code examples
linuxnetwork-programmingraspberry-pidhcpstatic-ip-address

Raspberry Pi configured for static IP also gets a DHCP IP


I've configured my Raspberry Pi for static IP. My /etc/network/interfaces looks like this:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Yet for some strange reason, every time I reboot my Pi or my router, my Pi gets the requested IP (192.168.1.2) but ALSO a DHCP address (192.168.1.18). So my Pi has two addresses.

Of course, this isn't necessarily a problem, I just think it's strange. Am I doing something wrong? Or not enough? My router is almost completely locked down for management, but I can enter static IPs for devices - is this necessary, if I configure the Pi to do it?

The dynamic address isn't apparent in ifconfig:

eth0      Link encap:Ethernet  HWaddr b8:27:eb:5d:87:71
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:236957 errors:0 dropped:34 overruns:0 frame:0
          TX packets:260738 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:35215632 (33.5 MiB)  TX bytes:70023369 (66.7 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:27258 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27258 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3397312 (3.2 MiB)  TX bytes:3397312 (3.2 MiB)

yet I can ping, ssh and everything on .18 as well.


Solution

  • Since you can add multiple IP addresses to the interface eth0 as noted above, I believe the solution to your problem is to remove the auto eth0 line from your /etc/network/interfaces file.