Skip to content

Run programs in a network namespace where all traffic go through proxy

License

Notifications You must be signed in to change notification settings

OkamiW/proxy-ns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

proxy-ns

proxy-ns is a Linux-specific command line tool to force any program to use your socks5 proxy server.

Features

It has several advantages over proxychains:

  • Supports both TCP and UDP
  • Works for statically linked programs

Installation

Arch Linux

proxy-ns is available at AUR.

Other

You can manually clone this repo, then use make install.

git clone https://github.com/OkamiW/proxy-ns.git
cd proxy-ns
make && sudo make install

Configuration

First, generate your config file:

proxy-ns -g

By default, proxy-ns uses config file at $XDG_CONFIG_HOME/proxy-ns/config.json. In case XDG_CONFIG_HOME is not set, it would be $HOME/.config/proxy-ns/config.json.

Here’s the default config file:

{
  "tun_name": "tun0",
  "tun_ip": "10.0.0.1/24",
  "socks5_address": "127.0.0.1:1080",
  "fake_dns": true,
  "fake_network": "240.0.0.0/4",
  "dns_server": "9.9.9.9"
}

Normally you only need to change socks5_address.

Notes about FakeDNS

FakeDNS can avoid a separate DNS roundtrip to improve latency, but it has its own limitations:

  • All domains are resolved to fake_network, some programs may not work as expected(eg. geoiplookup).
  • Some programs may not use your system DNS resolver. FakeDNS won’t work for them.

FAQ

Why can’t I ping as normal user inside proxy-ns?

Because proxy-ns creates a new network namespace.

For many distributions, /proc/sys/net/ipv4/ping_group_range defaults to 1 0 in new network namespace, which disallow ping for all groups.

Since socks5 doesn’t support icmp, ping would be meaningless inside proxy-ns anyway.

My program cannot resolve domain

Your socks5 server may not support UDP ASSOCIATE.

Usually, you can workaround this by enabling fake_dns (it’s enabled by default).

But some programs resolve domains themselves. You have to enable UDP support for your proxy server to use them.

About

Run programs in a network namespace where all traffic go through proxy

Resources

License

Stars

Watchers

Forks

Packages

No packages published