Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

I'm in a network using a proxy. I've got machines using lots of scripts here and there accessing each other over HTTP.

  • The network is
  • My proxy is, so I set it up accordingly:

    export http_proxy=
  • I want to exclude my own range to be accessed with the proxy. I tried any combination available.

    export no_proxy='10.*'
    export no_proxy='10.*.*.*'
    export no_proxy=''

None of the above work!

I'm testing with wget and it always tries to query the proxy, whatever IP address I want to connect to.

  • Since lots of scripts lie everywhere in all systems the --no-proxy option is actually not an option. I want to set it system wide.

Many thanks.

share|improve this question
up vote 13 down vote accepted

You're looking at it the wrong way. The no_proxy environment variable lists the domain suffixes, not the prefixes. From the documentation:

no_proxy: This variable should contain a comma-separated list of domain extensions proxy should not be used for.

So for IPs, you have two options:

1) Add each IP in full:

printf -v no_proxy '%s,' 10.1.{1..255}.{1..255};
export no_proxy="${no_proxy%,}";

2) Rename wget to wget-original and write a wrapper script (called wget) that looks up the IP for the given URL's host, and determines if it should use the proxy or not:

for arg; do
   # parse arg; if it's a URL, determine the IP address
if [[ "$ip" =~ ^10\.1\. ]]; then
   wget-original --no-proxy "$@";
   wget-original "$@";
share|improve this answer
Thank's a lot, I'm going to wrap my wget (and use hostnames instead of IP addresses). – SamK Oct 28 '11 at 14:27
Will having 255*255 addresses in no_proxy risk performance issues? – jtpereyda Dec 16 '15 at 22:50
@dafrazzman: that could well be. After all, it's almost 800 kilobytes large, which is somewhat extreme for an environment variable. It also depends on how large your environment can be. For this extreme case, I would recommend the wrapper approach. – janmoesen Jan 21 at 10:13
Also, it should be 10.1.{0..255}.{0..255}, or at least 10.1.{0..255}.{1..255}. (I don't think the last bit can be 0 for "normal" devices, but I am not sure.) – janmoesen Jan 21 at 10:15
Do not add each IP in full - it will be too long and you won't be able to execute any commands in bash. – Ross Jun 1 at 18:47

info wget says:

     This variable should contain a comma-separated list of domain
     extensions proxy should _not_ be used for.  For instance, if the
     value of `no_proxy' is `.mit.edu', proxy will not be used to
     retrieve documents from MIT.

So the variable should contain a list of domains, not IP ranges. You'll need to set up proper local aliases for your local machines in /etc/hosts file(s).

Apart from this, bear in mind that setting an environment variable does not guarantee that a proxy will or will not be used. It is just an information that may be used by programs that support it.

share|improve this answer

Here's a slightly simpler (one-line) approach based on janmoesen's solution.

export no_proxy=`echo 10.1.1.{1..255} | sed 's/ /,/g'`

Unfortunately, sed chokes on all the arguments passed from the expansion of 10.1.{1..255}.{1..255}, either in his code or mine. So if you really need to expand to 256 * 256 IP addresses, you'll need a different approach, but if you merely need 256 or so, this should work perfectly for you.

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.