准备SD卡
首先镜像下载
https://doc.openwrt.cc/2-OpenWrt-Rpi/1-Download/
macbook用户使用
# 查看磁盘挂载分区
$ diskutil list
/dev/disk3 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *31.7 GB disk3
1: Apple_HFS 123 31.7 GB disk3s1
# 卸载 U 盘挂载
$ diskutil unmountDisk /dev/disk3
Unmount of all volumes on disk3 was successful
# 如果不卸载挂载点就写入启动盘,则会提示dd: /dev/disk3: Resource busy
使用 dd 来来写入img
sudo dd bs=4M if=./immortalwrt-bcm27xx-bcm2709-rpi-2-squashfs-factory.img of=/dev/disk3
Password: <<<<----输入你的电脑密码
44+1 records in
44+1 records out
187389350 bytes transferred in 190.839793 secs (981920 bytes/sec)
确认是否写入
diskutil list
最后弹出u盘
$ diskutil eject /dev/disk3
Disk /dev/disk3 ejected`
或者使用现成烧录工具
https://www.raspberrypi.com/software/
####插入树莓派(我的是树莓派2代比较老)开机即可
第一还是修改网卡IP
# vim /etc/config/network
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.10.33'
option netmask '255.255.255.0'.
option gateway '192.168.10.1' <<<<<<---添加
option dns '114.114.114.114 8.8.8.8' <<<<<<---添加
option ip6assign '60'
#重启网卡生效
/etc/init.d/network restart
#顺便修改一下密码
root@OpenWrt:~# passwd
Changing password for root
New password:
Bad password: too weak
Retype password:
passwd: password for root changed by root
登录web 控制台
开始配置wireguard
- 创建公钥私钥
mkdir /wg
# 创建目录存放公钥私钥
cd /wg
# 进入文件夹
umask 077
# 配置创建密钥的权限
wg genpsk > sharekey
# 创建预共享密钥
cat sharekey
# 获取密钥复制保存
- 服务端公钥私钥
wg genkey | tee server_privatekey | wg pubkey > server_publickey
# 创建服务端公钥和私钥
cat server_privatekey
# 获取服务端私钥复制保存
cat server_publickey
# 获取服务端公钥复制保存
客户端公钥私钥 ( macOS 用户)
wg genkey | tee macos_privatekey | wg pubkey > macos_publickey
# 创建 macOS 客户端公钥和私钥
cat macos_privatekey
# 获取 macOS 客户端私钥复制保存
cat macos_publickey
# 获取 macOS 客户端公钥复制保存
前往“网络”-“接口”界面,添加新接口,接口名称可按需自定义,协议则选择 WireGuard VPN 协议。
全部通了,接下来你懂的了