Transparent Tor proxy for Linux with exit-node geo selection and a terminal user interface.
GhostSurf redirects all outgoing TCP and DNS traffic of the host through Tor using Netfilter rules, lets you choose the exit country or city, rotates exits on a schedule, and restores the original network state on stop. It is written in Rust with no third-party crates and runs on any glibc or musl distribution, independent of init system, desktop environment, or window manager.
Inspired by AnonSurf.
- System-wide transparent proxying of TCP and DNS through Tor (
TransPort 9040,DNSPort 9053) - IPv6 disabled via sysctl while routing is active, restored on stop
- Local networks (
127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16) and active SSH / IDE sessions excluded from redirection - Exit selection modes: random exit, single country and city, multi-country pool
- Bundled relay directory (50 countries, 176 cities, 1431 exit relays) with on-demand refresh from Onionoo
- Scheduled exit rotation with free-form intervals:
30s,15m,2h,1d,1h 30m - Live Tor circuit list, exit IP verification, optional
nyxintegration - Pluggable transports:
obfs4(obfs4proxy/lyrebird) andsnowflake - Upstream HTTP / HTTPS proxy for reaching the Tor network, with optional HTTPS proxy authentication
- SafeKill: terminates browsers and messengers and runs BleachBit before start, stop, or restart
- Optional start on boot
- Uses the terminal's 16-color ANSI palette, so it follows the user's color scheme
| Component | Supported |
|---|---|
| C library | glibc, musl |
| Init system | systemd, runit, OpenRC, dinit, s6, SysVinit, none (direct Tor supervision) |
| Firewall | iptables (legacy / nft), nftables |
| DNS management | resolv.conf, resolvconf, NetworkManager, systemd-resolved, connman |
| Privilege elevation | sudo, doas, pkexec, root |
The init backend is detected at runtime and can be forced with INIT_BACKEND.
Build: rust (cargo), make
Runtime: tor, iptables or nftables, curl or wget
Optional: obfs4proxy or lyrebird, snowflake-client, nyx, bleachbit
| Distribution family | Command |
|---|---|
| Debian-based | sudo apt install tor iptables curl make rustc cargo |
| Arch-based | sudo pacman -S tor iptables-nft curl make rust |
| Fedora / RHEL-based | sudo dnf install tor nftables curl make rust cargo |
| Void | sudo xbps-install -S tor iptables curl make rust cargo |
| Alpine | doas apk add tor nftables curl make rust cargo |
| Gentoo | sudo emerge net-vpn/tor net-firewall/nftables net-misc/curl dev-lang/rust |
git clone https://github.com/ignicat/ghostsurf.git
cd ghostsurf
make
sudo make installPackaging variables: DESTDIR, PREFIX (default /usr), SYSTEMDDIR, RUNITBASE.
make DESTDIR="$pkgdir" PREFIX=/usr installUninstall:
sudo make uninstallghostsurfStarting and stopping routing asks for the administrator password inside the interface. Root is not required to launch it.
ghostsurf start the interface
ghostsurf -h show help
ghostsurf -v show version
| Key | Action |
|---|---|
1 - 4 |
Overview, Exits, Settings, Circuits |
S |
Start / stop routing |
R, Shift+R |
Restart / save settings and restart |
N |
Apply exit selection and build a new circuit |
G or / |
Select country |
C |
Select city (refresh circuits on the Circuits tab) |
P, E |
Select country pool / edit pool as text |
T, A |
Set rotation interval / toggle automatic rotation |
W, U |
Shuffle exit queue / update relay directory |
I, M |
Check exit IP / open nyx |
B, X |
Toggle start on boot / toggle SafeKill |
Ctrl+S, Esc |
Save settings / discard or close |
?, F1 |
Help |
Q, Ctrl+C |
Quit |
Mouse clicks and scrolling are supported.
Privileged operations are performed by a separate helper, which can also be used directly from scripts:
sudo /usr/lib/ghostsurf/daemon <command>| Command | Description |
|---|---|
start, stop, restart |
Control routing |
changeid |
Request a new Tor identity |
recover |
Restore firewall, DNS and IPv6 after an unclean shutdown |
restore-dns |
Restore clearnet DNS while routing is stopped |
boot-enable, boot-disable |
Manage start on boot |
monitor |
Open nyx |
| Exits | City selection |
|---|---|
![]() |
![]() |
| Settings | Circuits |
|---|---|
![]() |
![]() |
| Path | Purpose |
|---|---|
/etc/ghostsurf/routing.cfg |
Settings: sandbox, SafeSocks, bridges, plaintext port blocking, upstream proxy, LAN protection |
/etc/ghostsurf/bridges.txt |
Bridge lines |
/etc/ghostsurf/onion.pac |
Proxy auto-config for .onion and .i2p hosts |
/var/lib/ghostsurf/ |
Runtime state and backups of firewall and DNS configuration |
| Variable | Purpose |
|---|---|
INIT_BACKEND |
Force init backend: systemd, openrc, runit, dinit, s6, sysv, direct |
SVDIR |
runit service directory |
TOR_ROUTER_USER |
Tor system user, if not detected automatically |
PROTECT_CIDRS |
Extra comma-separated networks excluded from redirection |
SUDO_ASKPASS |
Askpass helper for privilege elevation |
NO_COLOR |
Disable colors in helper output |
- Linux only; requires Netfilter and root privileges for routing.
- Tor carries only TCP. Outgoing traffic that cannot be redirected, including UDP other than DNS, is rejected while routing is active.
- GhostSurf anonymizes the network path only. It does not protect against browser fingerprinting, WebRTC leaks in misconfigured applications, or identification through logged-in accounts. Use Tor Browser for web browsing.




