Similar to the setup of Squid for HTTP proxy: https://gist.github.com/gmeeker/5e9af73fcf213c67cd86794f506520e6
OpenWRT can be used for SOCKS proxy as well using Dante. No custom builds are required, but some configuration files are currently missing.
opkg install sockd
Add /etc/init.d/sockd
#!/bin/sh /etc/rc.common
# Copyright (C) 2019 OpenWrt.org
USE_PROCD=1
START=90
STOP=10
PROG=/usr/sbin/sockd
USER="root"
GROUP="root"
PIDFILE=/var/run/sockd.pid
CONFFILE=/etc/sockd.conf
. /lib/functions.sh
start_service() {
procd_open_instance
procd_set_param command "$PROG" -f "$CONFFILE" -p "$PIDFILE"
procd_set_param user "$USER"
procd_set_param pidfile "$PIDFILE"
procd_close_instance
}
chmod 755 /etc/init.d/sockd
ln -s ../init.d/sockd /etc/rc.d/S90sockd
Simple config with authentication (change external interface as needed)
logoutput: stderr
#debug: 1
internal: 0.0.0.0 port = 1080
external: eth1.2
user.privileged : root
user.notprivileged : nobody
clientmethod: none
#socksmethod: none
socksmethod: username
client pass {
from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
}
socks block {
from: 0.0.0.0/0 to: 127.0.0.0/8
}
socks block {
from: 0.0.0.0/0 to: 192.168.0.0/16
}
socks block {
from: 0.0.0.0/0 to: 0.0.0.0/0
command: bind
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
socksmethod: username
}
socks block {
from: 0.0.0.0/0 to: 0.0.0.0/0
}
User accounts are used for authentication, but useradd is not installed. Edit /etc/passwd with:
username:x:500:500:nobody:/var:/bin/false
And /etc/shadow with this:
username:x:0:0:99999:7:::
Then
passwd username