1

My Pi is set to a static IP. But after a few hours or days it is suddenly no longer reachable on this IP. I now figured out that when this happens the wlan0 interface is no longer on this static IP but on a different one...

This is my interfaces file

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

auto wlan0
iface wlan0 inet static
address 192.168.1.100
gateway 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

This morning it was on 192.168.1.100, but now it is on 192.168.1.105. How can this happen?

9
  • I always advise against setting the IP static in the PI, do so in your router if possible. What version of raspbian are you running? I had wifi issues with Wheezy in the past, moving to Jessie has resolved that for me. (Pi2)
    – Havnar
    Commented Feb 18, 2016 at 14:51
  • Unfortunately my router does not support static IP... I am on wheezy...
    – Reto
    Commented Feb 18, 2016 at 14:59
  • are you perhaps using the retropie image?
    – Havnar
    Commented Feb 18, 2016 at 15:35
  • I am using the wheezy image from raspberrypi.org
    – Reto
    Commented Feb 18, 2016 at 15:43
  • You have both auto wlan0 and allow-hotplug wlan0. Could it be that your usb draw too much power, the usb disconnects (maybe just for a few seconds). Then it falls back to eth0 which gets a new IP via DHCP. Then you're wlan0 card comes back up and your connection changes. In other words: 192.168.1.105 is probably eth0 not wlan0. Try sudo ifconfig to check
    – kba
    Commented Feb 18, 2016 at 15:45

1 Answer 1

2

"My Pi is set to a static IP" - No it isn't! You have 2 different settings for wlan0. It is unpredictable what would happen.

See https://raspberrypi.stackexchange.com/a/37921/8697 for a tutorial on how to setup.

9
  • Thank you for the link to your tutorial. But I cannot see why I have two different settings. Because of manual and static? Can I correct this without changing everything do dhcpcd?
    – Reto
    Commented Feb 19, 2016 at 8:15
  • iface wlan0 inet manual and iface wlan0 inet static are attempting to configure wlan0 in different ways. Pick one or the other. If you really want static I recommend the method in the tutorial. If you want to use the older (less robust) method you should disable dhcpcd . This is disabled because you invoke dhcp.
    – Milliways
    Commented Feb 19, 2016 at 8:41
  • I removed iface wlan0 inet manualbut now I have no more connection. So I will have to try the new method.
    – Reto
    Commented Feb 19, 2016 at 12:18
  • Where do netmask, broadcast etc. go? Is this not needed here? Compared with the above, is this what I should have in dhcpcd.conf? interface wlan0 static ip_address=192.168.1.100 static routers=192.168.1.2 static domain_name_servers=192.168.1.2
    – Reto
    Commented Feb 19, 2016 at 13:02
  • @Reto NOTE You should have removed iface wlan0 inet static and all reference to dhcp (as per the tutotial) NOT iface wlan0 inet manual. You have a choice to use dhcpcd or not. If not you should disable it.
    – Milliways
    Commented Feb 19, 2016 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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