1

I am trying to set a static ip address. The static ip is outside of my home dhcp range. But even after reboot, I can connect to the old dhcp ip address. Why does this happen? Take a look at the ip during login and in the ouput of ifconfig:

login as: pi
pi@192.168.0.205's password:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jan  5 20:54:59 2016 from flucky-pc.lan

pi@druckerpi:~ $ ifconfig

eth0      Link encap:Ethernet  Hardware Adresse b8:27:eb:7b:45:2b
          inet Adresse:192.168.0.3  Bcast:192.168.0.255  Maske:255.255.255.0
          inet6-Adresse: fe80::ba27:ebff:fe7b:452b/64 Gültigkeitsbereich:Verbindung
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metrik:1
          RX packets:11358 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1300 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:1000
          RX bytes:631413 (616.6 KiB)  TX bytes:133922 (130.7 KiB)

lo        Link encap:Lokale Schleife
          inet Adresse:127.0.0.1  Maske:255.0.0.0
          inet6-Adresse: ::1/128 Gültigkeitsbereich:Maschine
          UP LOOPBACK RUNNING  MTU:65536  Metrik:1
          RX packets:41 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
          Kollisionen:0 Sendewarteschlangenlänge:0
          RX bytes:5671 (5.5 KiB)  TX bytes:5671 (5.5 KiB)

pi@druckerpi:~ $ cat /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.3
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 192.168.0.1

#allow-hotplug wlan0
#iface wlan0 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#allow-hotplug wlan1
#iface wlan1 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
pi@druckerpi:~ $

Is there something I am missing? I DONT want to be able to connect to 192.168.0.205 and instead use the static ip 192.168.0.3 (as set in /etc/network/interfaces)

  • I assume you are running Raspbian? What version are you running? Did you see this line For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' in the /etc/network/interfaces file you included above? The method of configuring networking has changed. This forum thread raspberrypi.org/forums/viewtopic.php?f=63&t=110606has all the good/bad details. Note the title seems off topic, but the details of the new method of setting a static IP using /etc/dhcpcd.conf file are there. – Steve Robillard Jan 5 '16 at 22:52
  • 1
    Check whether there is some setting in your home router (e.g. dhcp with "fixed" ip address) if you find the Pi (or its former IP listed there) - try to delete it. – Ghanima Jan 5 '16 at 22:52
1

I assume that by now, your host computer ARP cache table no longer remember the 192.168.0.205 IP Address.

arp -in eth0

Will show you the association between IP and MAC addresses. Unless someone else reuse the same IP with a new MAC, the ARP protocol will keep it alive for some time. You can also clear that table, O/S dependent, with commands like:
Windows:

arp -d *  

Linux:

ip -s -s neigh flush all
  • My raspberry is still running (over a year now) and today I was able to connect via ssh to the old (wrong) ip from my question from another laptop. Over a year in arp cache? – feedc0de Feb 14 '17 at 19:09
1

The method of setting a static IP has changed (this has rasied some questions and ire from the community, but it is what it is). Evidence of this can be seen in the comments of the /etc/network/interfaces file you included above, namely these two lines:

Please note that this file is written to be used with dhcpcd

For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf

To set up a static IP using the new dhcpd system edit your /etc/wpa_supplicant/wpa_supplicant.conf file so that it only contains the SSID and psk:

network={
  ssid="xxxxx"
  psk="xxxxxx"
}

and the static IP details are in the /etc/dhcpcd.conf file:

# Static IP configuration
interface eth0
static ip_address=192.168.0.3/24
static routers=192.168.0.1
static domain_name_servers=8.8.8.8 8.8.4.4

You will also have to edit your /etc/network/interfaces file so that the eth0 entry looks like this:

auto eth0
allow-hotplug eth0
iface eth0 inet manual

More info can be found in this forum thread. Despite the title of the thread it does include the details of the new setup as well as some of the anger this change has caused.

  • Hi is connecting to 192.168.0.205 however, ifconfig shows 192.168.0.3 (in German adresse) – fcm Jan 5 '16 at 23:14
  • @Fcm One of the problems the switch in network config has made is double IP address assignment the forum thread is actually titled /etc/network/interfaces changed,weird 2 LAN IPs instead of 1 – Steve Robillard Jan 5 '16 at 23:17
  • 1
    For a less passionate and easier to follow answer see raspberrypi.stackexchange.com/a/37921/8697 (I agree the actions of certain Foundation developers making fundamental changes without updating the documentation is irresponsible.) – Milliways Jan 5 '16 at 23:18
  • @Milliwaysmy personal favorite is that to set a static Ip you use a file called dhcpd, and set the mode as manual not the most intuitive naming scheme – Steve Robillard Jan 5 '16 at 23:20
  • @SteveRobillard I could not agree more! Of course my personal favourite (hobby horse) is to NOT use static, and let the computer do the work. – Milliways Jan 5 '16 at 23:50

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.