Step1 设置树莓派,启动usb0接口
编辑/boot/config.txt
,尾部添加:
1 | dtoverlay=dwc2 |
编辑/boot/cmdline.txt
,在rootwait
后添加
1 | modules-load=dwc2,g_ether |
Step2 启动树莓派后设置网络
编辑/etc/network/interfaces
,内容修改为
1 | auto lo |
再安装dnsmasq
1 | apt install dnsmasq |
编辑dnsmasq的配置文件/etc/dnsmasq.conf
,去掉最后两行,改为:
1 | interface=usb0 |
之后启动dnsmasq的开机自启动:
1 | sudo systemctl enable dnsmasq |
再创建端口转发用的脚本forward.sh
,位置任意,内容为
1 | ! /bin/bash |
保存后在/etc/rc.local
中在exit 0
一行之前添加该脚本,
1 | bash 脚本位置 |
修改/boot/wpa.conf,添加需要连接的热点,l例如:
1 | network={ |
enjoy it
重启后在mac和linux下可以直接识别该网路并且自动连接。需要修改热点只需要取出内存卡修改根目录下/wpa.conf
文件即可。