我正在尝试设置网状网络,为此,我在设备启动时配置网络。这是在启动期间加载的服务的启动脚本:
#!/bin/bash
/sbin/ifconfig wlan0 down &>> /var/log/meshnet
/sbin/ip link set down dev wlan0 &>> /var/log/meshnet
/sbin/iwconfig wlan0 mode ad-hoc &>> /var/log/meshnet
/sbin/iwconfig wlan0 channel 7 &>> /var/log/meshnet
/sbin/iwconfig wlan0 essid mesh2 &>> /var/log/meshnet
/sbin/ifconfig wlan0 up &>> /var/log/meshnet
/sbin/ip link set up dev wlan0 &>> /var/log/meshnet
/sbin/ip addr add 192.168.4.3/24 dev wlan0 &>> /var/log/meshnet
/sbin/ip route add default via 192.168.4.1 &>> /var/log/meshnet
但是,我收到以下错误(在日志文件中):
Error for wireless request "Set Mode" (8B06) : SET failed on device wlan0 ; Operation not permitted.
Error for wireless request "Set ESSID" (8B1A) : SET failed on device wlan0 ; Operation not permitted.
当我使用 sudo 运行脚本时,它工作得很好。
我能做些什么来让这项工作成功吗?
在芯片上运行 (getchip.com)
chip@chip:~$ cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
答案1
将用户添加到netdev
组:
usermod -a -G netdev USERNAME