This seems like a pretty simple use case, but it would depend on some pretty recently added functionality which I might not understand yet:

A python script gets populated by configuration management on a few monitoring servers within a specific IP range.

def main():
    args = get_args()
    user, password = args.redis_credentials
    ... store creds in a local file owned by root, do stuff with this...

It should change to this:

def main():
    args = get_args()
    vault_token = args.approle_token_for_vault
    user, password = get_creds_from_vault(token=vault_token, path="/secrets/redis/redis_credentials")
    ... store creds in a local file owned by root, do stuff with this...

This script needs a user/pass auth to a datastore.

Let's say that anything passed to the script goes into a file (e.g. an access token), shared on a bunch of machines. Provisioning is unpredictable, except for a specific subnet or IP address range.

Anyway, can I use Vault to restrict access to these shared credentials based on some kind of network identifier like MAC address or IP address?

Yes, I know, IP address restrictions are a "defense in depth" approach, and IP addresses can be spoofed. But the idea is to quickly make an incremental improvement to the existing security situation.

  • // , Since this use case refers largely to simple automation, feel free to migrate to SO if appropriate – Nathan Basanese May 3 '18 at 18:02
  • 1
    Because you are asking about a specific function of a commercial product, I think it is better asked of the vendor. – schroeder May 3 '18 at 18:54
  • // , This is an open source product, to which I've already contributed code. But thanks for the comment. I've also reached out to them, in addition to the wider open source community for this – Nathan Basanese May 4 '18 at 17:34
  • 1
    "Open source" does NOT mean non-commercial. Free as in beer, free as in speech. hashicorp.com/products/vault – schroeder May 5 '18 at 16:27
  • 1
    Definitely FOSS: github.com/hashicorp/vault/blob/master/LICENSE - there is also a commercial offering adding on to the open source product. – Ryan Long Aug 2 '18 at 4:02

It turns out that, as of 0.6.4 of the open source version of HashiCorp Vault, I can restrict access to AppRoles based on CIDR ranges, although I couldn't do this with the other authentication methods, as it happened.

Later versions of HashiCorp Vault have added the CIDR range binding capability to more and more authentication methods. HashiCorp added the ability to not only bind Vault Auth methods to CIDR ranges, but also allows binding any Vault Tokens produced to configurable CIDR ranges.

When the feature was enabled:


Where the magic happens:


What is a CIDR?

CIDR (Classless Inter-Domain Routing, sometimes called supernetting) is a way to allow more flexible allocation of Internet Protocol (IP) addresses than was possible with the original system of IP address classes.
A CIDR network address looks like this under IPv4:
Because it's just a bitwise way to specify IP address ranges, would correspond to the IP address range of to

Links about CIDRs


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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