I'm following these instructions to create an Ad-Hoc WiFi network from a Pi Zero W. It works great. Problem is, once I'm done I want to switch the Pi back to DHCP and log on to my house WiFi like normal.

1) Replace the old files: /etc/dhcpcd.conf and /etc/network/interfaces to their original states from a backup before the Ad-Hoc instructions were followed

2) I'm trying to restart networking with:

sudo ifdown wlan0
sudo ifup wlan0

... and I've tried all these commands as well following that:

sudo service networking restart
sudo /etc/init.d/networking restart
sudo systemctl daemon-reload

No matter what I try, I can't get the Pi to give up it's static IP and connect normally back to my home WiFi... UNTIL I restart the computer. How else can I force the network to reload /etc/network/interfaces without powering cycling?


Here's the interfaces file BEFORE adhoc, which is restored AFTER adhoc:

# 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 wlan0

auto lo usb0
iface lo inet loopback

iface eth0 inet manual

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

allow-hotplug usb0
iface usb0 inet manual

during adhoc the wlan0 part is changed to:

allow-hotplug wlan0
iface wlan0 inet static

...and that's the problem, I can't "clear" that static IP address so the Pi won't connect to my router.

  • How far did you get in the instructions, you have dnsmasq, dhcpcd, hostapd, and bridge network interface running in addition to the changes to network/interfaces. Some may be conflicting with normal use, hostapd will put your wlan0 into master mode and will be unable to bind to a wifi network.
    – crasic
    Aug 1, 2017 at 22:40
  • sorry yeah I also sudo systemctl stop dnsmasq and sudo systemctl stop hostapd
    – pinhead
    Aug 1, 2017 at 22:43
  • Do you have "auto wlan0" statement in /etc/network/interfaces
    – crasic
    Aug 1, 2017 at 22:44
  • getting closer! Adding auto wlan0 got the WiFi to connect (visible in iwconfig) but ifconfig still displays the static IP address, it won't work with my router with that static IP address. I'll try adding dhcp to `/etc/network/interfaces' next
    – pinhead
    Aug 1, 2017 at 22:48
  • nope, DHCPDISCOVER can't get an IP address
    – pinhead
    Aug 1, 2017 at 22:51

1 Answer 1


sudo service networking restart will DO NOTHING on a normal Raspbian, because it is not using networking it is using dhcpcd.

Try this:

sudo systemctl daemon-reload  
sudo systemctl start dhcpcd.service
# or if dhcpcd is already running:
sudo systemctl restart dhcpcd.service

It is not clear what other services you may have started, so you should investigate and stop these.

  • I think this might be it! Thank you. Funny thing, ifconfig still shows the static IP address but ip addr show shows BOTH the old static IP and new one that must have come from my router via dhcp. Trying to figure that out next...
    – pinhead
    Aug 2, 2017 at 2:33

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.