Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

what is the best way to configure Ubuntu to use a SOCKS5 proxy for all network traffic? Server is ubuntu server. I want to push all outbound traffic through the proxy (apt-get, http, https, etc). Everything but ssh should hit the proxy server.

share|improve this question
up vote 0 down vote accepted

Each command has its own configuration parameters and/or configuration files to use proxy servers. For example, w3m recognizes the HTTP_PROXY environment variable and uses it as a proxy if defined. wget also has options related to proxy settings. apt-get can be configured also to use a proxy server (or better apt-cacher to cache your downloaded packages for future installs/upgrades).

At the very least, you can use iptables to redirect all you outgoing traffic to a specific proxy.

$ sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination proxy_ip:proxy_port

Adding a rules such as the above is enough to transparently redirect all outgoing traffic to your proxy server. Of course, you can customize the rule according to your needs like forwarding other ports.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.