I'm trying to create an ad-hoc wifi made of 5 computers (one Windows PC and 4 raspberry pi's loaded with a raspbian). The raspberry pi will talk through mqtt, but that's not the point. The problem I have is that I always need to do the following in order to have the wlan0 interface after each reboot:
sudo ifdown wlan0
sudo ifup wlan0
Do you know why? Here is my conf (the same on each pi except the IP address obviously!)
~ % ifconfig
eth0 Link encap:Ethernet HWaddr b8:27:eb:ff:88:99
inet addr:192.168.1.41 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:951 errors:0 dropped:0 overruns:0 frame:0
TX packets:266 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:66321 (64.7 KiB) TX bytes:43663 (42.6 KiB)
wlan0 Link encap:Ethernet HWaddr 00:0f:13:51:05:8c
inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:2520 (2.4 KiB)
~ % iwconfig
wlan0 IEEE 802.11bgn ESSID:"mirroir"
Mode:Ad-Hoc Frequency:2.412 GHz Cell: 42:B1:44:EB:D2:C1
Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:on
lo no wireless extensions.
eth0 no wireless extensions.
~ % more /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
address 192.168.0.2
netmask 255.255.255.0
wireless-channel 1
wireless-essid mirroir
wireless-mode ad-hoc
wireless-key 967136deac
~ % sudo route add -net 192.168.0.0 netmask 255.255.255.0 wlan0
~ % netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default 192.168.1.254 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
Any idea?
It seems to work, but not always -- like 1 boot out of 10, really weird?!
wlan0has no ipgateway 192.168.1.254directly under thenetmask 255.255.255.0line in your/etc/network/interfacesfile