LocalSOCKS is a simple SOCKS5 proxy written in Go that allows you to bind client application traffic to a specific local network interface.
This is useful for applications that do not support explicit network interface binding, allowing you to control their network path through their proxy settings.
- SOCKS5 Proxy: A fully functional SOCKS5 proxy server.
- Specific Interface Binding: Binds all upstream connections to a chosen network interface.
- Dynamic Port Allocation: Automatically finds an available port to run on, starting from port 10800.
- Resilient: Gracefully handles temporary network interface outages with an exponential backoff retry mechanism.
- Environment-based Configuration: The network interface is easily configured via an environment variable.
To build the application, you need to have Go installed (version 1.18 or later).
Clone the repository and then run the following command from the project root:
go buildThis will create a localsocks executable in the project directory.
To run the proxy, you must set the LOCALSOCKS_INTERFACE environment variable to the name of the network interface you want to use.
For example, on macOS, your Wi-Fi interface might be en0. On Linux, it might be eth0 or wlan0. You can find your interface names by running ifconfig (on macOS) or ip addr (on Linux).
# Example for macOS
LOCALSOCKS_INTERFACE="en0" ./localsocks
# Example for Linux
LOCALSOCKS_INTERFACE="eth0" ./localsocksIf the LOCALSOCKS_INTERFACE is not set, the proxy will run but will use the system's default interface for outbound connections.
Upon startup, the application will log the address and port it is listening on, for example:
SOCKS proxy listening on 127.0.0.1:10800
To use the proxy, you need to configure your client application's SOCKS proxy settings to point to the address and port logged by the LocalSOCKS application.
- Host/Address:
127.0.0.1 - Port: The port number logged on startup (e.g.,
10800)
For example, in Firefox's network settings, you would configure it like this:
- Go to
Settings->General->Network Settings->Settings... - Select
Manual proxy configuration. - Set the
SOCKS Hostto127.0.0.1. - Set the
Portto the one provided by thelocalsocksapplication. - Make sure
SOCKS v5is selected.
All traffic from that application will now be routed through the LocalSOCKS proxy and will exit your system via the network interface you specified.