-1

I followed the instructions from this link to set up an ad hoc network. I get the following strange behaviour.

If my /etc/network/interfaces file is the "wifi - regular" file on boot then everything is great. I can switch between the ad hoc configuration and the wifi one using ifup and ifdown and copying the settings over. However, if I boot with the adhoc configurations the following strange thing happens:

  • I cannot switch to the wifi settings successfully. What happens is that although I do ifdown wlan0 copy the interface file over and then ifup wlan0. The wifi does not connect to any networks. I've connected a monitor to the Pi so that's how I'm checking that.

I'm running a Raspberry Pi B+ and the uname -a output is:

Linux raspberrypi 4.1.7+ #817 PREEMPT armv6l GNU/Linux

Any help much appreciated.

These are my configuration files.

/etc/network/interfaces-adhoc:

auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
iface wlan0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  wireless-channel 1
  wireless-essid RPiwireless
  wireless-mode ad-hoc

/etc/network/interfaces-wifi:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface etho0 inet manual

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

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/dhcp/dhcpd.conf:

ddns-update-style interim;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.5 192.168.1.150;
}

EDIT

To switch the settings once logged in I do:

sudo cp /etc/network/interface-<DESIRED> /etc/network/interface
sudo ifdown wlan0
sudo ifup wlan0

EDIT 2

| on boot          | wifi        | Ad hoc      |
|----------------------------------------------|
| DHCP on boot?    | failed      | active      |
| can switch?      | yes         | no          |
| IP on boot       | 10.0.0.114  | 192.168.1.1 |
| after 1 switch   | 192.168.1.1 | 192.168.1.1 |
| after 2 switches | 192.168.1.1 | 192.168.1.1 |
|----------------------------------------------|
  • DHCP on boot: sudo service isc-dhcp-server status
  • Whether I can switch between the two interfaces and connect succesfully to the internet.
  • What the IP is when I first boot
  • What the IP is after 1 switch
  • What the IP is after 2 switches

I read the IP from ifconfig wlan0. This is a bit strange given the network is in the 10.0.0.XX range.

1 Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!

6
  • So you basically say, that if you start with /etc/network/interfaces with the content of /etc/network/interfaces-wifi then you can switch as many times as you like? But if you boot with /etc/network/interfaces having the content of /etc/network/interfaces-adhoc, it fails, right?
    – techraf
    Dec 14, 2016 at 3:45
  • it fails to switch. correct. Thanks for the comments, I corrected the plural. Let me know if you have other suggestions.
    – evan54
    Dec 14, 2016 at 3:45
  • edited the question to show how I would do that
    – evan54
    Dec 14, 2016 at 3:48
  • To confirm: if started "with" -wifi you can then switch 10 times?
    – techraf
    Dec 14, 2016 at 4:08
  • that is correct. I've been trying to debug some more and it's related to the static IP address in some way. I'll see if I can post more useful information.
    – evan54
    Dec 14, 2016 at 4:11

1 Answer 1

0

If you boot with your interfaces-adhoc which contains iface eth0 inet dhcp you effectively disable dhcpcd. This would prevent the interfaces-wifi from running, because this depends on dhcpcd.

You are trying to run 2 incompatible services. It MAY be possible to write a script which shuts down all the services not needed and start others, but you are on your own. It is going to be easier to just reboot.

3
  • so is the "right" way to set up a rasbperry pi to serve a website so you can configure it's wifi settings by doing what I've been doing above and then forcing it to restart?
    – evan54
    Dec 15, 2016 at 0:50
  • @evan54 I can't say what is "right", I was pointing out why your approach didn't work, and how I would have done it (indeed I have experimented with an Access Point this way). There are hundreds of ways of configuring networking on Linux.
    – Milliways
    Dec 15, 2016 at 2:00
  • thanks for the response. just to make sure I understand. Is the way you would have done it simply rebooting?
    – evan54
    Dec 15, 2016 at 2:11

Your Answer

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

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