我正在尝试创建由5台计算机组成的临时wifi(一台Windows PC和4个带有树莓派的树莓派)。树莓派将通过mqtt进行对话,但这不是重点。我的问题是,wlan0
每次重新启动后,我始终需要执行以下操作才能拥有接口:
sudo ifdown wlan0
sudo ifup wlan0
你知道为什么吗?这是我的配置文件(除了IP地址,每个pi上都一样!)
~ % 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
任何的想法?
似乎可行,但并非总是如此-像10个靴子中的1个,真的很奇怪吗?
wlan0
没有IP
gateway 192.168.1.254
直接在文件的netmask 255.255.255.0
行下添加/etc/network/interfaces