树莓派搭配上了SIM卡模块,那么只能让树莓派上网,如果想要其他设备与树莓派连网线,通过树莓派代理上网,那该多好啊!
安装 dante-server
apt-get install dante-server
修改配置文件
备份
mv /etc/danted.conf /etc/danted.conf.bak
新建
nano /etc/danted.conf
配置如下:
#ifconfig 查看网卡, port 设置为自己想要的端口
##internal 表示进口 ip 设置。这里可以是网卡名,也可以是外网 ip
internal: eth0 port = 1080
external: 123.123.123.123 #填写外网 IP或出口网卡
#method 加入 none 可以实现匿名代理
method: username none
clientmethod: none
user.privileged: root
user.notprivileged: nobody
user.libwrap: nobody
client pass {
from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
log: connect disconnect error
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
protocol: tcp udp
}
启动 Dante
sudo systemctl start danted
如果直接启动成功,并没有报错那么下面的内容你可以不用在意,下面的报错只有树莓派用户才会遇到。
如果在树莓派上启动danted服务此时会报错,内容如下:
Job for danted.service failed because the control process exited with error code.
See "systemctl status danted.service" and "journalctl -xe" for details.
解决方案:
编辑danted.service
服务
nano /lib/systemd/system/danted.service
将第19行ReadOnlyDirectories
中的\lib64
删除掉,如下图。
保存后,执行sudo systemctl daemon-reload
重新加载所有systemd服务的配置文件
之后再次启动danted服务sudo systemctl start danted
OK,启动成功。这个问题在树莓派上出现的原因是Raspbian官方系统只有32位(虽然3B以上的板子是支持64位的),所以在使用lib64库的时候会报错,在配置文件中删掉lib64的支持即可。(可能表述不正确)
设置开机自启
sudo systemctl enable danted
取消开机自启
sudo systemctl disable danted
查看服务状态
sudo systemctl status danted
修改过配置文件后,记得重启danted服务:sudo systemctl restart danted
检测是否启动成功
netstat -anp | grep 1080
登陆是用本机用户名和密码即可。建议将用户的 shell 设置为 nologin