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 thenifup 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!
/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?-wifi
you can then switch 10 times?